Skip to content

Commit 3905b91

Browse files
authored
feat: adding stable tag to container images in release workflow and g… (#1882)
# Description This Pull Request resolves #1563 by ensuring that the `stable` Docker tag is only created for properly versioned tags following Semantic Versioning in the format `MAJOR.MINOR.PATCH` (e.g., `2.0.0`). Tags such as `v2.0.0`, `2.0.0-beta`, or any non-compliant version will not be considered stable. # Changes - Added step in `goreleaser.yml` (GitHub Actions release workflow) to detect whether the current tag is a **stable semantic version** with the help of regex, the result is stored in the `STABLE` environment variable. - In `.goreleaser.yml` file, added `docker_manifests` entry for the `stable` tag and used `skip_push` to skip pushing docker manifests in amd64 and arm64 of osv-scanner image when the `STABLE` environment variable is false.
1 parent 23a9ae0 commit 3905b91

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

.github/workflows/goreleaser.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ jobs:
3838
registry: ghcr.io
3939
username: ${{ github.repository_owner }}
4040
password: ${{ secrets.GITHUB_TOKEN }}
41+
- name: Detect stable tag
42+
id: detect_stable
43+
# Extracts tag name from git ref and check tag is stable
44+
# semantic version pattern (MAJOR.MINOR.PATCH, e.g., 1.2.3)
45+
run: |
46+
TAG="${GITHUB_REF_NAME}"
47+
if [[ "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
48+
echo "STABLE=true" >> $GITHUB_ENV
49+
else
50+
echo "STABLE=false" >> $GITHUB_ENV
51+
fi
4152
- name: Run GoReleaser
4253
id: run-goreleaser
4354
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
@@ -47,6 +58,7 @@ jobs:
4758
args: release --clean
4859
env:
4960
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
STABLE: ${{ env.STABLE }}
5062
- name: Generate subject
5163
id: hash
5264
env:

.goreleaser.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ docker_manifests:
140140
image_templates:
141141
- "ghcr.io/google/osv-scanner:{{ .Tag }}-amd64"
142142
- "ghcr.io/google/osv-scanner:{{ .Tag }}-arm64"
143+
- name_template: "ghcr.io/google/osv-scanner:stable"
144+
image_templates:
145+
- "ghcr.io/google/osv-scanner:{{ .Tag }}-amd64"
146+
- "ghcr.io/google/osv-scanner:{{ .Tag }}-arm64"
147+
skip_push: "{{ ne .Env.STABLE `true` }}"
143148

144149
archives:
145150
- formats: binary

0 commit comments

Comments
 (0)