From 61b8812808312610ca5120d208d4c62b792d5981 Mon Sep 17 00:00:00 2001 From: Daniel Volz Date: Sun, 8 Feb 2026 16:57:40 +0100 Subject: [PATCH] ci: fix release workflow ordering and remove redundant workflows (#135) - Tag builds now also set 'latest' Docker tag (fixes race condition where main-push build could overwrite latest with older version) - Remove duplicate release.yml (create-release job in docker-build.yml already handles GitHub releases) - Remove redundant version-bump.yml (release.sh already bumps versions in the release PR) - Change update-test-badges.yml trigger to workflow_run after successful docker-build (prevents parallel execution and ensures correct ordering) - Update agent instructions and CI documentation to reflect changes --- .github/agents/release-manager.agent.md | 4 +- .github/copilot-instructions.md | 15 +++-- .github/workflows/docker-build.yml | 5 +- .github/workflows/release.yml | 78 ------------------------ .github/workflows/update-test-badges.yml | 11 ++-- .github/workflows/version-bump.yml | 57 ----------------- 6 files changed, 22 insertions(+), 148 deletions(-) delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/version-bump.yml diff --git a/.github/agents/release-manager.agent.md b/.github/agents/release-manager.agent.md index 0b5adaf..ca2c1d5 100644 --- a/.github/agents/release-manager.agent.md +++ b/.github/agents/release-manager.agent.md @@ -179,8 +179,8 @@ The version number is displayed in the **About modal** (Settings → About) as a ### After Tagging -- The `docker-build.yml` workflow automatically builds and pushes Docker images to GHCR. -- The `version-bump.yml` workflow automatically updates `package.json` versions if needed. +- The `docker-build.yml` workflow automatically builds and pushes Docker images to GHCR with both versioned tags (`1.8.7`, `1.8`) and `latest`. +- The `update-test-badges.yml` workflow runs automatically after a successful Docker build to update test count badges in the README. - Track progress: `https://github.com/DanielVolz/medassist-ng/actions` --- diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 1d6a689..a3c8f45 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -138,11 +138,16 @@ Push to main / Tag created ↓ ┌─────────────────────────────────────┐ │ docker-build.yml │ -│ ├─ backend-test (parallel) │ -│ ├─ frontend-build (parallel) │ -│ └─ build-and-push (after tests) │ +│ └─ build-and-push │ │ ├─ Build Docker images │ │ └─ Push to GHCR │ +│ (Tag builds also set "latest") │ +└─────────────────────────────────────┘ + ↓ After successful build +┌─────────────────────────────────────┐ +│ update-test-badges.yml │ +│ (workflow_run after docker-build) │ +│ └─ Run tests, update badge counts │ └─────────────────────────────────────┘ ``` @@ -179,7 +184,9 @@ gh pr merge --squash --delete-branch | File | Trigger | Purpose | |------|---------|--------| | `.github/workflows/test.yml` | Pull Requests | Run tests, block PR on failures | -| `.github/workflows/docker-build.yml` | Push to main, Tags | Tests + Build and push Docker images | +| `.github/workflows/docker-build.yml` | Push to main, Tags | Build and push Docker images (+ create GitHub release on tags) | +| `.github/workflows/update-test-badges.yml` | After successful docker-build | Update test count badges in README | +| `.github/workflows/codeql.yml` | Push to main, PRs, Weekly | Security analysis | ## Key Patterns diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index c3b64f9..a5befee 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -29,6 +29,9 @@ jobs: # Tests are NOT run here — branch protection on main requires all PR checks # (backend-test + frontend-build from test.yml) to pass before merge. # Tags are created from main, so code is already tested. + # + # Tag builds (v*) always set "latest" in addition to the semver tags. + # This ensures "latest" always points to the most recent release. # ============================================================================= build-and-push: runs-on: ubuntu-latest @@ -68,7 +71,7 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=raw,value=${{ github.event.inputs.tag || 'latest' }},enable=${{ github.event_name == 'workflow_dispatch' }} - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} - name: Build and push uses: docker/build-push-action@v5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 61a56c3..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Create Release - -on: - push: - tags: ['v*'] - -permissions: - contents: write - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Get version info - id: version - run: | - CURRENT_TAG=${GITHUB_REF#refs/tags/} - VERSION=${CURRENT_TAG#v} - echo "tag=$CURRENT_TAG" >> $GITHUB_OUTPUT - echo "version=$VERSION" >> $GITHUB_OUTPUT - - # Get previous tag - PREV_TAG=$(git tag --sort=-v:refname | grep -A1 "^${CURRENT_TAG}$" | tail -1) - if [ "$PREV_TAG" = "$CURRENT_TAG" ]; then - PREV_TAG="" - fi - echo "previous_tag=$PREV_TAG" >> $GITHUB_OUTPUT - - - name: Generate release template - run: | - cat > release_notes.md << 'EOF' - ## What's New - - - - ### New Features - - - - **Feature Name**: Description of the feature - - ### Improvements - - - - **Improvement**: Description - - ### Where to Find It - - - - --- - - ## Docker Images - - ```bash - docker pull ghcr.io/danielvolz/medassist-ng-backend:${{ steps.version.outputs.version }} - docker pull ghcr.io/danielvolz/medassist-ng-frontend:${{ steps.version.outputs.version }} - ``` - - **Full Changelog**: https://github.com/DanielVolz/medassist-ng/compare/${{ steps.version.outputs.previous_tag }}...${{ steps.version.outputs.tag }} - EOF - - - name: Create Draft Release - uses: softprops/action-gh-release@v1 - with: - body_path: release_notes.md - draft: true - generate_release_notes: false - name: "Release ${{ steps.version.outputs.tag }}" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-test-badges.yml b/.github/workflows/update-test-badges.yml index ec2c060..978f3b5 100644 --- a/.github/workflows/update-test-badges.yml +++ b/.github/workflows/update-test-badges.yml @@ -2,13 +2,10 @@ name: Update Test Badges on: workflow_dispatch: - push: + workflow_run: + workflows: ["Build and Push Docker Images"] + types: [completed] branches: [main] - paths: - - 'backend/src/**' - - 'frontend/src/**' - - 'backend/package.json' - - 'frontend/package.json' permissions: contents: write @@ -17,6 +14,8 @@ jobs: update-badges: name: Update Test Count Badges runs-on: ubuntu-latest + # Only run after successful docker builds, not failed ones + if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout repository diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml deleted file mode 100644 index c93514f..0000000 --- a/.github/workflows/version-bump.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Version Bump on Release - -on: - release: - types: [published] - -permissions: - contents: write - -jobs: - version-bump: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: main - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Get version from tag - id: version - run: | - # Extract version from tag (e.g., v1.6.0 -> 1.6.0) - VERSION="${GITHUB_REF_NAME#v}" - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "Extracted version: $VERSION" - - - name: Update package.json versions - run: | - VERSION="${{ steps.version.outputs.version }}" - - # Update backend/package.json - jq --arg v "$VERSION" '.version = $v' backend/package.json > backend/package.json.tmp - mv backend/package.json.tmp backend/package.json - - # Update frontend/package.json - jq --arg v "$VERSION" '.version = $v' frontend/package.json > frontend/package.json.tmp - mv frontend/package.json.tmp frontend/package.json - - echo "Updated versions to $VERSION" - cat backend/package.json | head -5 - cat frontend/package.json | head -5 - - - name: Commit and push - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - git add backend/package.json frontend/package.json - - # Only commit if there are changes - if git diff --staged --quiet; then - echo "No version changes needed" - else - git commit -m "chore: bump version to ${{ steps.version.outputs.version }} [skip ci]" - git push origin main - fi