|
2 | 2 | push: |
3 | 3 | branches: |
4 | 4 | - '**' |
| 5 | + tags: |
| 6 | + # Release + rc semver tags. Prereleases build & publish but never move `latest`. |
| 7 | + - '[0-9]+.[0-9]+.[0-9]+' |
| 8 | + - '[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+' |
5 | 9 | pull_request: |
6 | 10 | branches: |
7 | 11 | - '**' |
@@ -68,10 +72,31 @@ jobs: |
68 | 72 | with: |
69 | 73 | submodules: recursive |
70 | 74 |
|
| 75 | + # Decide whether this tag is the newest release (final versions only, no rc), |
| 76 | + # so we only move `latest` when it actually is. Done locally from git tags — |
| 77 | + # no API calls, so no rate-limit / network failure can block the publish. |
| 78 | + - name: Determine if this is the newest release |
| 79 | + id: latest-tag |
| 80 | + if: github.ref_type == 'tag' |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + set -euo pipefail |
| 84 | + git fetch --tags --force --quiet |
| 85 | + newest="$(git tag --list --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -n1 || true)" |
| 86 | + echo "Newest release tag: ${newest:-<none>}; this ref: ${GITHUB_REF_NAME}" |
| 87 | + if [ "$newest" = "$GITHUB_REF_NAME" ]; then |
| 88 | + echo "is-latest=true" >> "$GITHUB_OUTPUT" |
| 89 | + else |
| 90 | + echo "is-latest=false" >> "$GITHUB_OUTPUT" |
| 91 | + fi |
| 92 | +
|
71 | 93 | - uses: ./.github/actions/containerize |
72 | 94 | with: |
73 | 95 | registry: ghcr.io |
74 | 96 | registry-path: ${{ github.repository_owner }}/frontend |
75 | 97 | registry-username: ${{ github.actor }} |
76 | 98 | registry-password: ${{ secrets.GITHUB_TOKEN }} |
77 | | - push-image: ${{ github.ref_type == 'branch' && github.event_name != 'pull_request' && (github.ref_name == 'master' || github.ref_name == 'develop') }} |
| 99 | + # Push on tag pushes (semver releases) and on master/develop branch pushes. Never on PRs. |
| 100 | + push-image: ${{ github.event_name != 'pull_request' && (github.ref_type == 'tag' || github.ref_name == 'master' || github.ref_name == 'develop') }} |
| 101 | + # Move `latest` only when this tag is the newest release (not an rc, not a hotfix to an old version). |
| 102 | + latest: ${{ steps.latest-tag.outputs.is-latest == 'true' }} |
0 commit comments