Skip to content

Commit 20879eb

Browse files
committed
ci: create release on push tag
1 parent f24f23f commit 20879eb

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release Docker Image
2+
3+
on:
4+
push:
5+
tags: ['v.*.*']
6+
7+
jobs:
8+
push_to_registries:
9+
name: Push Docker image to multiple registries
10+
runs-on: ubuntu-latest
11+
permissions:
12+
packages: write
13+
contents: read
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v3
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Login to Docker Hub
25+
uses: docker/login-action@v3
26+
with:
27+
username: ${{ secrets.DOCKERHUB_USERNAME }}
28+
password: ${{ secrets.DOCKERHUB_TOKEN }}
29+
30+
- name: Log in to GHCR
31+
uses: docker/login-action@v2
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Extract Docker tags
38+
id: meta
39+
run: |
40+
version_tag="${{github.ref_name}}"
41+
tags=($version_tag)
42+
if [[ "$version_tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
43+
# prerelease tags like `v2.0.0-alpha.1` should not be released as `latest` nor `v2`
44+
tags+=("latest")
45+
tags+=($(echo "$version_tag" | cut -d. -f1))
46+
fi
47+
releases=""
48+
for tag in "${tags[@]}"; do
49+
releases="${releases:+$releases,}hywax/mafl:$tag,ghcr.io/hywax/mafl:$tag"
50+
done
51+
echo "releases=$releases" >> "$GITHUB_OUTPUT"
52+
53+
- name: Build and push Docker images
54+
uses: docker/build-push-action@v4
55+
with:
56+
context: .
57+
push: true
58+
platforms: linux/amd64,linux/arm64,linux/arm/v7
59+
tags: ${{ steps.meta.outputs.releases }}

0 commit comments

Comments
 (0)