Skip to content

Commit 3f9ae10

Browse files
committed
add tag publishing
1 parent 46a12af commit 3f9ae10

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

.github/actions/containerize/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ inputs:
1616
push-image:
1717
required: true
1818
description: If true, pushes the image to the registry
19+
latest:
20+
required: false
21+
default: 'false'
22+
description: If true, also tags the image as `latest` (set when the pushed tag is the newest release)
1923

2024
runs:
2125
using: composite
@@ -39,6 +43,7 @@ runs:
3943
latest=false
4044
tags: |
4145
type=raw,value={{branch}},enable=${{ github.ref_type == 'branch' && github.event_name != 'pull_request' }}
46+
type=raw,value=latest,enable=${{ inputs.latest == 'true' }}
4247
type=ref,event=branch
4348
type=ref,event=pr
4449
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0') && !startsWith(github.ref, 'refs/tags/0') }}

.github/workflows/ci-build.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ on:
22
push:
33
branches:
44
- '**'
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]+'
59
pull_request:
610
branches:
711
- '**'
@@ -68,10 +72,31 @@ jobs:
6872
with:
6973
submodules: recursive
7074

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+
7193
- uses: ./.github/actions/containerize
7294
with:
7395
registry: ghcr.io
7496
registry-path: ${{ github.repository_owner }}/frontend
7597
registry-username: ${{ github.actor }}
7698
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

Comments
 (0)