@@ -23,34 +23,26 @@ permissions:
2323
2424jobs :
2525 build-binary :
26- strategy :
27- fail-fast : true
28- matrix :
29- os : [ubuntu-latest, macos-14, macos-13]
30- arch : [amd64, arm64]
31- include :
32- - os : ubuntu-latest
33- platform : linux
34-
35- - os : macos-13
36- platform : darwin
37-
38- - os : macos-14
39- platform : darwin
40- exclude :
41- - os : macos-14
42- arch : amd64
43- - os : macos-13
44- arch : arm64
45-
46- name : Building run-${{ matrix.platform }}-${{ matrix.arch }}
26+ # strategy:
27+ # fail-fast: true
28+ # matrix:
29+ # runner: ubuntu-latest
30+ # arch:
31+ # - amd64
32+ # - arm64
33+ # os:
34+ # - linux
35+ # - darwin
36+ # - windows
37+
38+ name : Building run-${{ matrix.os }}-${{ matrix.arch }}
4739 runs-on : ${{ matrix.os }}
4840 steps :
4941 - uses : actions/checkout@v4
5042
5143 - uses : nxtcoder17/actions/setup-cache-go@v1
5244 with :
53- cache_key : " run-${{ matrix.platform }}-${{ matrix.arch }}"
45+ cache_key : " run-${{ matrix.os }}-${{ matrix.arch }}"
5446 working_directory : .
5547
5648 - uses : nxtcoder17/actions/generate-image-tag@v1
@@ -62,86 +54,62 @@ jobs:
6254 cachix_cache_name : ${{ secrets.CACHIX_CACHE_NAME }}
6355 cachix_auth_token : ${{ secrets.CACHIX_AUTH_TOKEN }}
6456
57+ - uses : nxtcoder17/actions/metadata@main
58+ id : meta
59+
6560 - name : Build Binary
6661 shell : bash
6762 env :
6863 CGO_ENABLED : 0
64+ GOOS : ${{matrix.os}}
65+ GOARCH : ${{ matrix.arch }}
6966 run : |+
70- binary=bin/run-${{ matrix.platform }}-${{ matrix.arch }}
71- go build -o $binary -ldflags="-s -w" -tags urfave_cli_no_docs ./cmd/run
72-
73- if [ "${{ matrix.platform }}" = "linux" ]; then
74- upx $binary
75- fi
67+ arch_list=("amd64" "arm64")
68+ os_list=("linux" "darwin" "windows")
7669
77- - name : Upload Artifact
78- uses : actions/upload-artifact@v4
79- with :
80- name : run-${{ matrix.platform }}-${{ matrix.arch }}
81- path : bin/*
70+ for os in "${os_list[@]}"; do
71+ for arch in "${arch_list[@]}"; do
72+ echo "🚧 building binary for os=$os arch=$arch"
73+ export GOARCH=$arch
74+ export GOOS=$os
8275
83- release :
84- needs : build-binary
85- runs-on : ubuntu-latest
86- steps :
87- - name : Download all artifacts
88- uses : actions/download-artifact@v4
89- with :
90- path : ${{ github.workspace }}/binaries
91- pattern : " run-*"
92-
93- - name : flattening all the executable artifacts
94- shell : bash
95- run : |+
96- ls -R ${{ github.workspace }}/binaries
97- mkdir -p ${{ github.workspace }}/upload/binaries
98- shopt -s globstar
99- file ./** | grep 'executable,' | awk -F: '{print $1}' | xargs -I {} cp {} ${{ github.workspace }}/upload/binaries
100- shopt -u globstar
101-
102- - uses : nxtcoder17/actions/generate-image-tag@v1
76+ binary=bin/run-$GOOS-$GOARCH
77+ go build -o $binary -ldflags="-s -w -X main.Version=${{ steps.meta.outputs.version }}-${{steps.meta.outputs.short_sha}}" -tags urfave_cli_no_docs ./cmd/run
78+ done
79+ done
10380
10481 - name : running for master branch
105- if : startsWith(github.ref, 'refs/heads/master ')
82+ if : startsWith(github.ref, 'refs/heads/')
10683 env :
10784 GH_TOKEN : ${{ github.token }}
85+ version : ${{steps.meta.outputs.version}}
10886 run : |+
109- echo "running for master branch, will delete nightly release, and recreate in case it exists"
110- IMAGE_TAG=nightly
111- echo "IMAGE_TAG=$IMAGE_TAG" | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT
112- gh release list -R ${{ github.repository }} | grep -i $IMAGE_TAG
113- exit_code=$?
114- if [ $exit_code -eq 0 ]; then
115- gh release delete $IMAGE_TAG -y --cleanup-tag -R ${{ github.repository }}
116- fi
87+ echo "running for a branch, will delete it's nightly release"
88+ gh release delete ${{steps.meta.outputs.version}} -y --cleanup-tag -R ${{ github.repository }} || echo "cleaned up nightly tag"
11789
11890 - name : ensure github release exists
11991 shell : bash
12092 env :
12193 GH_TOKEN : ${{ github.token }}
94+ version : ${{steps.meta.outputs.version}}
12295 run : |+
123- set +e
124- gh release list -R ${{ github.repository }} | grep -i $IMAGE_TAG
125- exit_code=$?
126- if [ $exit_code -ne 0 ]; then
127- gh release create $IMAGE_TAG -R ${{ github.repository }} --generate-notes --prerelease --draft=false
128- fi
96+ echo "creating release for tag $version"
97+ gh release create $version -R ${{ github.repository }} --generate-notes --prerelease --draft=false || echo "release ($version) already exists, will use that one"
12998
13099 - name : upload to github release
131100 shell : bash
132101 env :
133102 GH_TOKEN : ${{ github.token }}
103+ version : ${{steps.meta.outputs.version}}
134104 run : |+
135- extra_args=""
136- if [ "$IMAGE_TAG" = "nightly" ]; then
137- extra_args="--clobber"
138- fi
139- gh release upload $IMAGE_TAG -R ${{github.repository}} $extra_args ${{github.workspace}}/upload/binaries/*
105+ gh release upload $version -R ${{github.repository}} bin/*
140106
141107 - name : mark release as latest
142108 if : startsWith(github.ref, 'refs/tags/')
143109 env :
144110 GH_TOKEN : ${{ github.token }}
111+ version : ${{steps.meta.outputs.version}}
145112 shell : bash
146113 run : |+
147- gh release edit $IMAGE_TAG -R ${{ github.repository }} --latest
114+ gh release edit $version -R ${{ github.repository }} --latest
115+
0 commit comments