Skip to content

Commit 93fc8b3

Browse files
committed
Make release workflow dispatch-driven
Invert the release process by switching the trigger from `push: tags` to `workflow_dispatch`. Previously, a developer would push a tag to trigger the release build. This could lead to a tag existing for a failed build. With this change, the workflow is triggered manually. It builds and pushes the Docker images first. Only after the multi-arch manifest is successfully created does a final job run to create the GitHub Release and the associated tag, making tagging a byproduct of a successful release.
1 parent 887b9ed commit 93fc8b3

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

.github/workflows/release.yml

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
name: Release
22

33
on:
4-
push:
5-
tags:
6-
# Example: 1.1.21.3
7-
- '\d+\.\d+\.\d+\.\d+'
84
workflow_dispatch:
95
inputs:
106
version:
11-
description: 'Release version (e.g. 1.1.21.3)'
7+
description: 'Release version (e.g. 1.1.21.4)'
128
required: true
139
type: string
1410

@@ -31,11 +27,19 @@ jobs:
3127
- name: Check out the repository
3228
uses: actions/checkout@v4
3329

34-
- name: Prepare
30+
- name: Check version format
31+
run: |
32+
VERSION="${{ github.event.inputs.version }}"
33+
if [[ ! "$VERSION" =~ ^\d+\.\d+\.\d+(\.\d+)?$ ]]; then
34+
echo "Invalid version format: $VERSION"
35+
exit 1
36+
fi
37+
echo "Version format OK: $VERSION"
38+
39+
- name: Derive platform pair
3540
run: |
3641
platform=${{ matrix.platform }}
3742
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
38-
echo "VERSION=${{ github.event.inputs.version || github.ref_name }}" >> $GITHUB_ENV
3943
4044
- name: Docker meta
4145
id: meta
@@ -56,8 +60,8 @@ jobs:
5660
id: build
5761
uses: docker/build-push-action@v6
5862
with:
59-
context: ${{ env.VERSION }}
60-
file: ${{ env.VERSION }}/Dockerfile
63+
context: ${{ github.event.inputs.version }}
64+
file: ${{ github.event.inputs.version }}/Dockerfile
6165
platforms: ${{ matrix.platform }}
6266
labels: ${{ steps.meta.outputs.labels }}
6367
tags: ${{ env.REGISTRY_IMAGE }}
@@ -98,18 +102,14 @@ jobs:
98102
- name: Set up Docker Buildx
99103
uses: docker/setup-buildx-action@v3
100104

101-
- name: Prepare
102-
run: |
103-
echo "VERSION=${{ github.event.inputs.version || github.ref_name }}" >> $GITHUB_ENV
104-
105105
- name: Docker meta
106106
id: meta
107107
uses: docker/metadata-action@v5
108108
with:
109109
images: ${{ env.REGISTRY_IMAGE }}
110110
tags: |
111-
${{ env.VERSION }}-alpine
112-
${{ env.VERSION }}
111+
${{ github.event.inputs.version }}-alpine
112+
${{ github.event.inputs.version }}
113113
latest
114114
115115
- name: Create manifest list and push
@@ -120,4 +120,21 @@ jobs:
120120
121121
- name: Inspect image
122122
run: |
123-
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
123+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ github.event.inputs.version }}-alpine
124+
125+
release:
126+
runs-on: ubuntu-latest
127+
needs: merge
128+
permissions:
129+
contents: write
130+
steps:
131+
- name: Check out the repository
132+
uses: actions/checkout@v4
133+
with:
134+
fetch-depth: 0
135+
136+
- name: Create release and tag with gh
137+
run: gh release create "$VERSION" --title "$VERSION"
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
VERSION: ${{ github.event.inputs.version }}

0 commit comments

Comments
 (0)