ci: standardize CI/CD workflows and add Renovate

- CI: single sequential job, local-ubuntu-latest runner, Node 22, workflow_call trigger, npm run commands
- Release: CI gate via reusable workflow, concurrency protection, dynamic package name, tarball validation, gh CLI
- Retain tns-csi-specific appVersion sync from upstream releases
- Add renovate.json with recommended config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
DevContainer User
2026-03-04 00:41:36 +00:00
parent 5960cc521e
commit 71abc6792d
3 changed files with 74 additions and 117 deletions
+24 -48
View File
@@ -5,61 +5,37 @@ on:
branches: [main] branches: [main]
pull_request: pull_request:
branches: [main] branches: [main]
workflow_call:
jobs: jobs:
lint: ci:
runs-on: ubuntu-latest runs-on: local-ubuntu-latest
timeout-minutes: 10 timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm run lint
typecheck:
runs-on: ubuntu-latest
timeout-minutes: 10
steps: steps:
- uses: actions/checkout@v4 - name: Checkout
- uses: actions/setup-node@v4 uses: actions/checkout@v4
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm run tsc
test: - name: Setup Node.js
runs-on: ubuntu-latest uses: actions/setup-node@v4
timeout-minutes: 10
permissions:
checks: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: with:
node-version: '22' node-version: '22'
cache: 'npm' cache: 'npm'
- run: npm ci
- run: npx vitest run --reporter=default --reporter=junit --outputFile=test-results.xml
- uses: dorny/test-reporter@v1
if: always()
with:
name: Test Results
path: test-results.xml
reporter: java-junit
build: - name: Install dependencies
runs-on: ubuntu-latest run: npm ci
timeout-minutes: 10
needs: [lint, typecheck, test] - name: Build plugin
steps: run: npx @kinvolk/headlamp-plugin build
- uses: actions/checkout@v4
- uses: actions/setup-node@v4 - name: Lint
with: run: npm run lint
node-version: '22'
cache: 'npm' - name: Type-check
- run: npm ci run: npm run tsc
- run: npm run build
- name: Format check
run: npm run format:check
- name: Run tests
run: npm test
+46 -69
View File
@@ -4,61 +4,51 @@ on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
version: version:
description: 'Version to release (without v prefix, e.g., 0.2.0)' description: 'Release version (e.g. 1.0.0)'
required: true required: true
type: string type: string
permissions:
contents: write
concurrency: concurrency:
group: release group: release
cancel-in-progress: false cancel-in-progress: false
jobs: jobs:
ci: ci:
runs-on: ubuntu-latest uses: ./.github/workflows/ci.yaml
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run tsc
- run: npm test
release: release:
runs-on: ubuntu-latest needs: ci
needs: [ci] runs-on: local-ubuntu-latest
permissions: timeout-minutes: 10
contents: write
steps: steps:
- name: Validate version format - name: Validate version format
run: | run: |
if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Version must be in format X.Y.Z (e.g., 0.2.0)" echo "Error: Version must be in X.Y.Z format"
exit 1 exit 1
fi fi
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Configure git - name: Configure Git
run: | run: |
git config user.name "github-actions[bot]" git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com" git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Update package.json version - name: Update version in package.json
run: | run: npm version ${{ inputs.version }} --no-git-tag-version
jq --arg version "${{ inputs.version }}" '.version = $version' package.json > package.json.tmp
mv package.json.tmp package.json
- name: Update artifacthub-pkg.yml version and URL - name: Update artifacthub-pkg.yml
run: | run: |
VERSION="${{ inputs.version }}" VERSION="${{ inputs.version }}"
RELEASE_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}/tns-csi-${VERSION}.tar.gz" PKG_NAME=$(jq -r .name package.json)
RELEASE_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}/${PKG_NAME}-${VERSION}.tar.gz"
sed -i "s|^version:.*|version: \"${VERSION}\"|" artifacthub-pkg.yml sed -i "s/^version:.*/version: \"${VERSION}\"/" artifacthub-pkg.yml
sed -i "s|headlamp/plugin/archive-url:.*|headlamp/plugin/archive-url: \"${RELEASE_URL}\"|" artifacthub-pkg.yml sed -i "s|headlamp/plugin/archive-url:.*|headlamp/plugin/archive-url: \"${RELEASE_URL}\"|" artifacthub-pkg.yml
- name: Update appVersion from latest tns-csi release - name: Update appVersion from latest tns-csi release
@@ -81,59 +71,46 @@ jobs:
run: npm ci run: npm ci
- name: Build plugin - name: Build plugin
run: npm run build run: npx @kinvolk/headlamp-plugin build
- name: Package plugin - name: Package plugin
run: npx @kinvolk/headlamp-plugin package run: npx @kinvolk/headlamp-plugin package
- name: Prepare release tarball
run: |
VERSION="${{ inputs.version }}"
PKG_NAME=$(jq -r .name package.json)
TARBALL="${PKG_NAME}-${VERSION}.tar.gz"
mv *.tar.gz "$TARBALL"
echo "TARBALL=$TARBALL" >> $GITHUB_ENV
echo "PKG_NAME=$PKG_NAME" >> $GITHUB_ENV
- name: Validate tarball - name: Validate tarball
run: | run: |
EXPECTED="tns-csi-${{ inputs.version }}.tar.gz" echo "Tarball: ${{ env.TARBALL }}"
if [ ! -f "$EXPECTED" ]; then ls -lh "${{ env.TARBALL }}"
echo "::error::Expected tarball not found: $EXPECTED" tar -tzf "${{ env.TARBALL }}" | head -20
exit 1 tar -tzf "${{ env.TARBALL }}" | grep -q "main.js" || { echo "Error: main.js not found in tarball"; exit 1; }
fi
echo "Tarball validated: $EXPECTED"
- name: Compute checksum - name: Compute checksum
id: compute_checksum
run: | run: |
TARBALL="tns-csi-${{ inputs.version }}.tar.gz" CHECKSUM=$(sha256sum "${{ env.TARBALL }}" | awk '{print $1}')
CHECKSUM=$(sha256sum "$TARBALL" | awk '{print $1}') echo "CHECKSUM=$CHECKSUM" >> $GITHUB_ENV
echo "checksum=${CHECKSUM}" >> $GITHUB_OUTPUT sed -i "s|headlamp/plugin/archive-checksum:.*|headlamp/plugin/archive-checksum: sha256:${CHECKSUM}|" artifacthub-pkg.yml
echo "Checksum: sha256:${CHECKSUM}"
- name: Update checksum in metadata - name: Commit and tag
run: | run: |
CHECKSUM="${{ steps.compute_checksum.outputs.checksum }}" VERSION="${{ inputs.version }}"
sed -i "s|headlamp/plugin/archive-checksum:.*|headlamp/plugin/archive-checksum: \"sha256:${CHECKSUM}\"|" artifacthub-pkg.yml git add package.json package-lock.json artifacthub-pkg.yml
git commit -m "release: v${VERSION}"
- name: Commit version bump and metadata git tag "v${VERSION}"
run: | git push origin main --tags
git add package.json artifacthub-pkg.yml
git commit -m "chore: release v${{ inputs.version }}"
git push origin main
- name: Create and push tag
run: |
git tag "v${{ inputs.version }}"
git push origin "v${{ inputs.version }}"
- name: Create GitHub Release - name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ inputs.version }}"
files: tns-csi-${{ inputs.version }}.tar.gz
fail_on_unmatched_files: true
draft: false
prerelease: false
generate_release_notes: true
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ github.token }}
- name: Summary
run: | run: |
echo "Version bumped to ${{ inputs.version }}" VERSION="${{ inputs.version }}"
echo "Metadata updated with checksum sha256:${{ steps.compute_checksum.outputs.checksum }}" gh release create "v${VERSION}" "${{ env.TARBALL }}" \
echo "Tag v${{ inputs.version }} created" --title "v${VERSION}" \
echo "GitHub release published with tarball" --generate-notes
+4
View File
@@ -0,0 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"]
}