Skip to content

Commit fae4267

Browse files
committed
Update release workflow
1 parent c4c2286 commit fae4267

5 files changed

Lines changed: 154 additions & 92 deletions

File tree

.github/workflows/build.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,41 @@
11
name: Build
2-
on: pull_request
2+
3+
on:
4+
push:
5+
pull_request:
36

47
jobs:
5-
build:
6-
name: Build
8+
go-build:
9+
name: Build Go Binary
710
runs-on: ubuntu-latest
11+
812
steps:
9-
- name: Checkout Repo
13+
- name: Checkout
1014
uses: actions/checkout@v4
1115

12-
- name: Build
16+
- name: Setup Go
1317
uses: actions/setup-go@v5
1418
with:
15-
go-version: '^1.22.0'
16-
- run: |
17-
cd cmd/dss
18-
go build -o dss
19+
go-version: '1.25.x'
20+
21+
- name: Build binary
22+
run: make dev
23+
24+
docker-build:
25+
name: Build Docker Image
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Build Docker image (no push)
36+
uses: docker/build-push-action@v5
37+
with:
38+
context: .
39+
file: Dockerfile
40+
push: false
41+
tags: test-image:ci # Just a local tag.

.github/workflows/cleanup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: '^1.22.0' # The Go version to download (if necessary) and use.
16+
go-version: '^1.25.0' # The Go version to download (if necessary) and use.
1717

1818
- name: Install gofumpt
1919
run: go install mvdan.cc/gofumpt@latest

.github/workflows/docker.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 120 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: Release
22
on:
33
release:
4-
types: [published]
4+
types: [ released ]
55

66
jobs:
7-
build:
7+
binary:
88
name: Build and Release Binaries
99
runs-on: ubuntu-latest
1010
steps:
@@ -14,7 +14,7 @@ jobs:
1414
- name: Setup Go Environment
1515
uses: actions/setup-go@v5
1616
with:
17-
go-version: '^1.22.0'
17+
go-version: '^1.25.0'
1818

1919
- name: Build Binaries
2020
run: |
@@ -25,44 +25,136 @@ jobs:
2525
cd ../../builds
2626
find . -maxdepth 1 -type f -execdir zip 'compressed/{}.zip' '{}' \;
2727
28-
- name: Upload Binaries
29-
run: |
30-
go install github.com/tcnksm/ghr@latest
31-
ghr -t ${{ secrets.GITHUB_TOKEN }} --delete Latest builds/compressed/
32-
docker:
33-
name: Build and Release Docker Image
28+
- name: Upload Release Assets
29+
uses: softprops/action-gh-release@v2
30+
with:
31+
files: builds/compressed/*.zip
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
35+
setup:
36+
name: Setup Build Metadata
3437
runs-on: ubuntu-latest
38+
outputs:
39+
image_id: ${{ steps.setenv.outputs.image_id }}
40+
cache_tags: ${{ steps.setenv.outputs.cache_tags }}
41+
tags: ${{ steps.setenv.outputs.tags }}
42+
tags_latest: ${{ steps.setenv.outputs.tags_latest }}
3543
steps:
3644
- name: Checkout Repo
3745
uses: actions/checkout@v4
3846

39-
- name: Setup Image Name
47+
- id: setenv
4048
run: |
41-
echo "IMAGE_ID=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
49+
IMAGE_ID=${GITHUB_REPOSITORY,,}
50+
TAG_NAME="${{ github.ref_name }}"
51+
52+
# Support both specific version (from release tag) and latest
53+
TAGS="ghcr.io/${IMAGE_ID}:${TAG_NAME}"
54+
TAGS_LATEST="ghcr.io/${IMAGE_ID}:latest"
55+
CACHE_TAGS="ghcr.io/${IMAGE_ID}:buildcache"
56+
57+
echo "image_id=$IMAGE_ID" >> $GITHUB_OUTPUT
58+
echo "tags=$TAGS" >> $GITHUB_OUTPUT
59+
echo "tags_latest=$TAGS_LATEST" >> $GITHUB_OUTPUT
60+
echo "cache_tags=$CACHE_TAGS" >> $GITHUB_OUTPUT
61+
62+
build-amd64:
63+
name: Build amd64 image
64+
runs-on: ubuntu-latest
65+
needs: setup
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- name: Login to GHCR
70+
uses: docker/login-action@v3
71+
with:
72+
registry: ghcr.io
73+
username: ${{ github.actor }}
74+
password: ${{ secrets.GITHUB_TOKEN }}
75+
76+
- name: Set up Docker Buildx
77+
uses: docker/setup-buildx-action@v3
78+
with:
79+
install: true
80+
driver-opts: |
81+
network=host
82+
83+
- name: Build amd64 image
84+
uses: docker/build-push-action@v5
85+
with:
86+
context: .
87+
file: Dockerfile
88+
push: true
89+
platforms: linux/amd64
90+
tags: ghcr.io/${{ needs.setup.outputs.image_id }}:amd64
91+
cache-from: type=registry,ref=${{ needs.setup.outputs.cache_tags }}
92+
cache-to: type=registry,ref=${{ needs.setup.outputs.cache_tags }},mode=max
93+
build-args: |
94+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
95+
96+
build-arm64:
97+
name: Build arm64 image
98+
runs-on: ubuntu-24.04-arm
99+
needs: setup
100+
steps:
101+
- uses: actions/checkout@v4
42102

43-
- name: Login to GitHub Packages
103+
- name: Login to GHCR
44104
uses: docker/login-action@v3
45105
with:
46106
registry: ghcr.io
47107
username: ${{ github.actor }}
48108
password: ${{ secrets.GITHUB_TOKEN }}
49109

50-
- name: Docker Metadata
51-
id: meta
52-
uses: docker/metadata-action@v5
110+
- name: Set up Docker Buildx
111+
uses: docker/setup-buildx-action@v3
53112
with:
54-
images: |
55-
ghcr.io/${{ env.IMAGE_ID }}
56-
tags: |
57-
type=semver,pattern=v{{version}}
58-
type=semver,pattern=v{{major}}.{{minor}}
59-
type=semver,pattern=v{{major}}
60-
flavor: |
61-
latest=true
62-
63-
- name: Build and Push to GitHub Packages
64-
id: docker_build
65-
uses: docker/build-push-action@v6
113+
install: true
114+
driver-opts: |
115+
network=host
116+
117+
- name: Build arm64 image
118+
uses: docker/build-push-action@v5
66119
with:
120+
context: .
121+
file: Dockerfile
67122
push: true
68-
tags: ${{ steps.meta.outputs.tags }}
123+
platforms: linux/arm64
124+
tags: ghcr.io/${{ needs.setup.outputs.image_id }}:arm64
125+
cache-from: type=registry,ref=${{ needs.setup.outputs.cache_tags }}
126+
cache-to: type=registry,ref=${{ needs.setup.outputs.cache_tags }},mode=max
127+
build-args: |
128+
GITHUB_TOKEN=${{ secrets.GH_ACCESS_TOKEN }}
129+
130+
merge:
131+
name: Merge multi-arch image
132+
runs-on: ubuntu-latest
133+
needs: [ setup, build-amd64, build-arm64 ]
134+
outputs:
135+
image_tag: ${{ needs.setup.outputs.tags }}
136+
steps:
137+
- name: Login to GHCR
138+
uses: docker/login-action@v3
139+
with:
140+
registry: ghcr.io
141+
username: ${{ github.actor }}
142+
password: ${{ secrets.GITHUB_TOKEN }}
143+
144+
- name: Get tag values
145+
run: |
146+
echo "Image ID: ${{ needs.setup.outputs.image_id }}"
147+
echo "Tags: ${{ needs.setup.outputs.tags }}"
148+
echo "Tags Latest: ${{ needs.setup.outputs.tags_latest }}"
149+
150+
- name: Create and push multi-arch manifest
151+
run: |
152+
docker buildx imagetools create \
153+
-t ${{ needs.setup.outputs.tags }} \
154+
-t ${{ needs.setup.outputs.tags_latest }} \
155+
ghcr.io/${{ needs.setup.outputs.image_id }}:amd64 \
156+
ghcr.io/${{ needs.setup.outputs.image_id }}:arm64
157+
158+
- name: Verify manifest
159+
run: |
160+
docker buildx imagetools inspect ${{ needs.setup.outputs.tags }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24-alpine3.21 AS build
1+
FROM golang:1.25.3-alpine3.22 AS build
22

33
RUN apk add git make \
44
&& apk cache clean

0 commit comments

Comments
 (0)