Skip to content

Commit 6e7fcfa

Browse files
committed
ci: gate production image builds on release tags and add release workflow
1 parent 7b1578f commit 6e7fcfa

2 files changed

Lines changed: 67 additions & 3 deletions

File tree

.github/workflows/build-and-push.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ name: Build and Push Container
77

88
on:
99
push:
10-
branches:
11-
- main
10+
tags:
11+
- 'v*'
12+
release:
13+
types: [published]
1214
workflow_dispatch:
1315

1416
concurrency:
@@ -145,7 +147,9 @@ jobs:
145147
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
146148
tags: |
147149
type=raw,value=latest
148-
type=sha,prefix={{branch}}-
150+
type=semver,pattern={{version}}
151+
type=semver,pattern={{major}}.{{minor}}
152+
type=semver,pattern={{major}}
149153
150154
- name: Create manifest list and push
151155
if: steps.check.outputs.has_digests == 'true'

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Workflow: Release
2+
# Description: Generates a release tag and GitHub release
3+
# Why: Provides versioned releases for production deployments
4+
5+
name: Create Release
6+
7+
on:
8+
workflow_dispatch:
9+
10+
jobs:
11+
create-release:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
outputs:
17+
released: ${{ steps.changelog.outputs.skipped == 'false' }}
18+
tag: ${{ steps.changelog.outputs.tag }}
19+
steps:
20+
- name: Checkout Repository
21+
uses: actions/checkout@v6
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Conventional Changelog Action
26+
id: changelog
27+
uses: TriPSs/conventional-changelog-action@v5
28+
with:
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
git-user-name: 'github-actions[bot]'
31+
git-user-email: 'github-actions[bot]@users.noreply.github.com'
32+
git-message: 'chore(release): {version}'
33+
preset: 'angular'
34+
tag-prefix: 'v'
35+
version-file: 'package.json'
36+
skip-on-empty: 'false'
37+
skip-ci: 'true'
38+
create-summary: 'true'
39+
git-push: 'false'
40+
release-count: 0
41+
42+
- name: Commit release artifacts
43+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
44+
run: |
45+
git config user.name 'github-actions[bot]'
46+
git config user.email 'github-actions[bot]@users.noreply.github.com'
47+
git add package.json
48+
git tag -d "${{ steps.changelog.outputs.tag }}" 2>/dev/null || true
49+
git commit -m "chore(release): ${{ steps.changelog.outputs.tag }}"
50+
git tag "${{ steps.changelog.outputs.tag }}"
51+
git push origin HEAD:main --tags
52+
53+
- name: Create GitHub Release
54+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
55+
uses: softprops/action-gh-release@v2
56+
with:
57+
tag_name: ${{ steps.changelog.outputs.tag }}
58+
name: ${{ steps.changelog.outputs.tag }}
59+
body: ${{ steps.changelog.outputs.clean_changelog }}
60+
prerelease: false

0 commit comments

Comments
 (0)