11name : Release
22on :
33 release :
4- types : [published ]
4+ types : [ released ]
55
66jobs :
7- build :
7+ binary :
88 name : Build and Release Binaries
99 runs-on : ubuntu-latest
1010 steps :
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 }}
0 commit comments