From e884894840c4630089b5650ea40b15e8916d4622 Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Thu, 12 Feb 2026 15:20:17 -0500 Subject: [PATCH] ci: consolidate release workflow into single step Merged prepare-release and release workflows into a single workflow that handles everything in one job. This eliminates the need for separate tokens or manual intervention. Single workflow now: - Validates version format - Updates package.json and artifacthub-pkg.yml - Builds and packages plugin - Computes checksum - Updates metadata with real checksum - Commits all changes to main - Creates and pushes tag - Creates GitHub release with tarball No more tag push triggers, no separate tokens needed. Everything runs in one workflow_dispatch job. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- .github/workflows/prepare-release.yaml | 67 ---------------- .github/workflows/release.yaml | 101 ++++++++++++++----------- 2 files changed, 55 insertions(+), 113 deletions(-) delete mode 100644 .github/workflows/prepare-release.yaml diff --git a/.github/workflows/prepare-release.yaml b/.github/workflows/prepare-release.yaml deleted file mode 100644 index 41ddc72..0000000 --- a/.github/workflows/prepare-release.yaml +++ /dev/null @@ -1,67 +0,0 @@ -name: Prepare Release - -on: - workflow_dispatch: - inputs: - version: - description: 'Version to release (without v prefix, e.g., 0.4.0)' - required: true - type: string - -jobs: - prepare: - runs-on: local-ubuntu-latest - permissions: - contents: write - steps: - - name: Validate version format - run: | - if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then - echo "::error::Version must be in format X.Y.Z (e.g., 0.4.0)" - exit 1 - fi - - - name: Checkout - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Configure git - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - - name: Update package.json version - run: | - jq --arg version "${{ inputs.version }}" '.version = $version' package.json > package.json.tmp - mv package.json.tmp package.json - - - name: Update artifacthub-pkg.yml version - run: | - VERSION="${{ inputs.version }}" - RELEASE_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}/polaris-${VERSION}.tar.gz" - - 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 - - # Set placeholder checksum - will be updated after release - sed -i "s|headlamp/plugin/archive-checksum:.*|headlamp/plugin/archive-checksum: sha256:PLACEHOLDER_WILL_BE_UPDATED_AFTER_RELEASE|" artifacthub-pkg.yml - - - name: Commit version bump - run: | - git add package.json artifacthub-pkg.yml - git commit -m "chore: bump version to ${{ inputs.version }}" - git push origin main - - - name: Create and push tag - run: | - git tag "v${{ inputs.version }}" - git push origin "v${{ inputs.version }}" - - - name: Summary - run: | - echo "✓ Version bumped to ${{ inputs.version }}" - echo "✓ Tag v${{ inputs.version }} created" - echo "" - echo "The release workflow will now run automatically." - echo "After it completes, the checksum will be updated on main." diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 50aa398..c27b864 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,28 +1,46 @@ name: Release on: - push: - tags: - - 'v*' + workflow_dispatch: + inputs: + version: + description: 'Version to release (without v prefix, e.g., 0.4.0)' + required: true + type: string jobs: - build-and-release: + release: runs-on: local-ubuntu-latest permissions: contents: write - outputs: - version: ${{ steps.extract_version.outputs.version }} - checksum: ${{ steps.compute_checksum.outputs.checksum }} steps: + - name: Validate version format + run: | + if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then + echo "::error::Version must be in format X.Y.Z (e.g., 0.4.0)" + exit 1 + fi + - name: Checkout uses: actions/checkout@v4 - - name: Extract version from tag - id: extract_version + - name: Configure git run: | - VERSION=${GITHUB_REF_NAME#v} - echo "version=${VERSION}" >> $GITHUB_OUTPUT - echo "Version: ${VERSION}" + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Update package.json version + run: | + jq --arg version "${{ inputs.version }}" '.version = $version' package.json > package.json.tmp + mv package.json.tmp package.json + + - name: Update artifacthub-pkg.yml version + run: | + VERSION="${{ inputs.version }}" + RELEASE_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}/polaris-${VERSION}.tar.gz" + + 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 - name: Setup Node.js uses: actions/setup-node@v4 @@ -41,7 +59,7 @@ jobs: - name: Validate tarball name run: | - EXPECTED="polaris-${{ steps.extract_version.outputs.version }}.tar.gz" + EXPECTED="polaris-${{ inputs.version }}.tar.gz" ACTUAL=$(ls *.tar.gz) if [ "$EXPECTED" != "$ACTUAL" ]; then echo "::error::Tarball name mismatch! Expected: $EXPECTED, Got: $ACTUAL" @@ -52,15 +70,32 @@ jobs: - name: Compute checksum id: compute_checksum run: | - TARBALL="polaris-${{ steps.extract_version.outputs.version }}.tar.gz" + TARBALL="polaris-${{ inputs.version }}.tar.gz" CHECKSUM=$(sha256sum "$TARBALL" | awk '{print $1}') echo "checksum=${CHECKSUM}" >> $GITHUB_OUTPUT echo "Checksum: sha256:${CHECKSUM}" + - name: Update checksum in metadata + run: | + CHECKSUM="${{ steps.compute_checksum.outputs.checksum }}" + sed -i "s|headlamp/plugin/archive-checksum:.*|headlamp/plugin/archive-checksum: sha256:${CHECKSUM}|" artifacthub-pkg.yml + + - name: Commit version bump and metadata + run: | + 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 uses: softprops/action-gh-release@v2 with: - files: polaris-${{ steps.extract_version.outputs.version }}.tar.gz + tag_name: "v${{ inputs.version }}" + files: polaris-${{ inputs.version }}.tar.gz fail_on_unmatched_files: true draft: false prerelease: false @@ -68,35 +103,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - update-metadata: - needs: build-and-release - runs-on: local-ubuntu-latest - permissions: - contents: write - steps: - - name: Checkout main branch - uses: actions/checkout@v4 - with: - ref: main - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Configure git + - name: Summary run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - - name: Update checksum in metadata - run: | - VERSION="${{ needs.build-and-release.outputs.version }}" - CHECKSUM="${{ needs.build-and-release.outputs.checksum }}" - - sed -i "s|headlamp/plugin/archive-checksum:.*|headlamp/plugin/archive-checksum: sha256:${CHECKSUM}|" artifacthub-pkg.yml - - git add artifacthub-pkg.yml - if ! git diff --cached --quiet; then - git commit -m "ci: update checksum for v${VERSION}" - git push origin main - echo "✓ Checksum updated on main branch" - else - echo "✓ Checksum already up to date" - fi + echo "✓ Version bumped to ${{ inputs.version }}" + echo "✓ Metadata updated with checksum sha256:${{ steps.compute_checksum.outputs.checksum }}" + echo "✓ Tag v${{ inputs.version }} created" + echo "✓ GitHub release published with tarball"