From 85ff7cbbf5738fc843f2ba3207025b5217ec25a8 Mon Sep 17 00:00:00 2001 From: Frederic Cabassut Date: Sat, 7 Mar 2026 07:44:03 +0100 Subject: [PATCH] fix: consolidate release pipeline into bump workflow - Update release.sh to also bump docker-compose.yml image tag in the same commit, keeping the tagged commit in sync - Add CI and Docker release jobs to bump.yml so it's self-contained (GITHUB_TOKEN pushes don't trigger other workflows) - Remove "Pin docker-compose" post-step from release.yml since it's now handled by release.sh Co-Authored-By: Claude Opus 4.6 --- .github/workflows/bump.yml | 62 ++++++++++++++++++++++++++++++++++- .github/workflows/release.yml | 12 ------- scripts/release.sh | 3 +- 3 files changed, 63 insertions(+), 14 deletions(-) diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml index c94d79e..242a27d 100644 --- a/.github/workflows/bump.yml +++ b/.github/workflows/bump.yml @@ -18,6 +18,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + outputs: + tag: ${{ steps.release-tag.outputs.tag }} steps: - uses: actions/checkout@v4 with: @@ -34,4 +36,62 @@ jobs: node-version: 22 - name: Run release script - run: bash scripts/release.sh ${{ github.event.inputs.bump }} + env: + BUMP_TYPE: ${{ github.event.inputs.bump }} + run: bash scripts/release.sh "$BUMP_TYPE" + + - name: Output new tag + id: release-tag + run: echo "tag=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT" + + ci: + needs: bump + uses: ./.github/workflows/ci.yml + + release: + name: Build & Push Docker Image + runs-on: ubuntu-latest + needs: [bump, ci] + permissions: + contents: write + packages: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.bump.outputs.tag }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{version}},value=${{ needs.bump.outputs.tag }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.bump.outputs.tag }} + type=raw,value=latest + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ needs.bump.outputs.tag }} + generate_release_notes: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 73b9905..dc0c5ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,15 +54,3 @@ jobs: uses: softprops/action-gh-release@v2 with: generate_release_notes: true - - - name: Pin docker-compose image to released version - env: - VERSION: ${{ github.ref_name }} - run: | - VERSION="${VERSION#v}" - sed -i "s|image: ghcr.io/bretzel-app/crumbs:.*|image: ghcr.io/bretzel-app/crumbs:${VERSION}|" docker-compose.yml - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add docker-compose.yml - git commit -m "chore: pin docker-compose to v${VERSION} [skip ci]" - git push origin HEAD:main diff --git a/scripts/release.sh b/scripts/release.sh index dc73cc3..711e9cb 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -60,7 +60,8 @@ echo "Bumping $BUMP version..." npm version "$BUMP" -m "chore: bump version to %s" --no-git-tag-version NEW_VERSION=$(node -p "require('./package.json').version") -git add package.json +sed -i'' -e "s|image: ghcr.io/bretzel-app/crumbs:.*|image: ghcr.io/bretzel-app/crumbs:${NEW_VERSION}|" docker-compose.yml +git add package.json docker-compose.yml git commit -m "chore: bump version to $NEW_VERSION" git tag "v$NEW_VERSION"