Skip to content

Commit 3e7fe4b

Browse files
committed
feat: added docker release action
1 parent 8975a4f commit 3e7fe4b

File tree

4 files changed

+79
-3
lines changed

4 files changed

+79
-3
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release Docker Image
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
permissions:
8+
contents: read
9+
10+
on:
11+
push:
12+
tags:
13+
- '\d+\.\d+\.\d+'
14+
15+
jobs:
16+
build-and-push:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Extract Docker image metadata
26+
id: meta
27+
uses: docker/metadata-action@v5
28+
with:
29+
images: |
30+
${{ vars.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}
31+
ghcr.io/${{ vars.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}
32+
tags: |
33+
type=ref,event=branch
34+
type=ref,event=pr
35+
type=semver,pattern={{version}}
36+
type=semver,pattern={{major}}.{{minor}}
37+
38+
- name: Set frontend and backend versions
39+
run: |
40+
VERSION=${{ steps.meta.outputs.version }}
41+
sed -i "s/^version = \".*-git\"/version = \"${VERSION}\"/" ./backend/Cargo.toml
42+
jq ".version = \"${VERSION}\"" ./frontend/package.json > ./frontend/package.tmp.json
43+
mv ./frontend/package.tmp.json ./frontend/package.json
44+
45+
- name: Log in to Docker Hub
46+
if: github.event_name != 'pull_request'
47+
uses: docker/login-action@v3
48+
with:
49+
username: ${{ vars.DOCKERHUB_USERNAME }}
50+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
51+
52+
- name: Login to GitHub Container Registry
53+
if: github.event_name != 'pull_request'
54+
uses: docker/login-action@v3
55+
with:
56+
registry: ghcr.io
57+
username: ${{ github.repository_owner }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Set up QEMU
61+
uses: docker/setup-qemu-action@v3
62+
63+
- name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v3
65+
66+
- name: Build and push Docker image
67+
uses: docker/build-push-action@v6
68+
with:
69+
platforms: linux/amd64,linux/arm64
70+
context: .
71+
push: ${{ github.event_name != 'pull_request' }}
72+
tags: ${{ steps.meta.outputs.tags }}
73+
labels: ${{ steps.meta.outputs.labels }}
74+
annotations: ${{ steps.meta.outputs.annotations }}
75+
provenance: true
76+
sbom: true

backend/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "backend"
3-
version = "0.1.0"
3+
version = "0.0.0-git"
44
edition = "2024"
55

66
[dependencies]

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unifi-voucher-manager",
3-
"version": "0.1.0",
3+
"version": "0.0.0-git",
44
"private": true,
55
"scripts": {
66
"dev": "next dev --turbopack",

0 commit comments

Comments
 (0)