@@ -3,50 +3,88 @@ name: Release
33on :
44 push :
55 tags :
6- - ' v* ' # Trigger only when a tag starting with 'v' is pushed (e.g., v1.0.0)
6+ - " v* " # Trigger only when a tag starting with 'v' is pushed (e.g., v1.0.0)
77
88permissions :
99 contents : write
1010
11+ env :
12+ ALPINE_GIT_VERSION : v2.47.2
13+
1114jobs :
1215 build :
13- name : Build Go Binaries
16+ name : Publish binaries
1417 runs-on : ubuntu-20.04
1518
1619 steps :
17- - name : Get release version from tag
18- run : echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
19-
2020 - name : Checkout code
2121 uses : actions/checkout@v4
2222
2323 - name : Set up Go
2424 uses : actions/setup-go@v5
2525 with :
26- go-version : ' 1.21' # Change to the required Go version
26+ go-version : " 1.21" # Change to the required Go version
2727
2828 - name : Install dependencies
2929 run : go mod tidy
3030
3131 - name : Build binaries for multiple platforms
3232 run : |
3333 mkdir -p dist
34- GOOS=linux GOARCH=amd64 go build -o dist/app -linux-amd64 .
35- GOOS=linux GOARCH=arm64 go build -o dist/app -linux-arm64 .
36- GOOS=darwin GOARCH=arm64 go build -o dist/app -macos-arm64 .
34+ GOOS=linux GOARCH=amd64 go build -o dist/maskcmd -linux-amd64 .
35+ GOOS=linux GOARCH=arm64 go build -o dist/maskcmd -linux-arm64 .
36+ GOOS=darwin GOARCH=arm64 go build -o dist/maskcmd -macos-arm64 .
3737
3838 - name : Create GitHub Release
3939 id : create_release
4040 uses : softprops/action-gh-release@v2
4141 with :
42- tag_name : ${{ env.RELEASE_VERSION }}
43- name : Release ${{ env.RELEASE_VERSION }}
44- body : " Automated release for version ${{ env.RELEASE_VERSION }}"
42+ tag_name : ${{ github.ref_name }}
43+ name : Release ${{ github.ref_name }}
44+ body : " Automated release for version ${{ github.ref_name }}"
4545 draft : false
4646 prerelease : false
4747 files : |
48- dist/app -linux-amd64
49- dist/app -linux-arm64
50- dist/app -macos-arm64
48+ dist/maskcmd -linux-amd64
49+ dist/maskcmd -linux-arm64
50+ dist/maskcmd -macos-arm64
5151 env :
52- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
52+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
53+
54+ docker :
55+ name : Publish docker image
56+ runs-on : ubuntu-20.04
57+ needs : build
58+ steps :
59+ - name : Checkout
60+ uses : actions/checkout@v4
61+
62+ - name : Set up Docker Buildx
63+ uses : docker/setup-buildx-action@v3
64+
65+ - name : Log in to Docker Hub
66+ uses : docker/login-action@v3
67+ with :
68+ username : ${{ secrets.DOCKERHUB_USERNAME }}
69+ password : ${{ secrets.DOCKERHUB_PAT }}
70+
71+ - name : Extract metadata (tags, labels)
72+ id : meta
73+ uses : docker/metadata-action@v5
74+ with :
75+ images : caseycs/maskcmd
76+ tags : |
77+ type=semver,pattern=${{ env.ALPINE_GIT_VERSION }}-{{major}}{{minor}}{{patch}}
78+
79+ - name : Build and Push Docker image
80+ uses : docker/build-push-action@v6
81+ with :
82+ context : .
83+ platforms : |
84+ linux/amd64
85+ linux/arm64
86+ build-args : |
87+ ALPINE_GIT_VERSION=${{ env.ALPINE_GIT_VERSION }}
88+ MASKCMD_VERSION=${{ github.ref_name }}
89+ push : true
90+ tags : ${{ steps.meta.outputs.tags }}
0 commit comments