@@ -23,34 +23,26 @@ permissions:
23
23
24
24
jobs :
25
25
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 }}
47
39
runs-on : ${{ matrix.os }}
48
40
steps :
49
41
- uses : actions/checkout@v4
50
42
51
43
- uses : nxtcoder17/actions/setup-cache-go@v1
52
44
with :
53
- cache_key : " run-${{ matrix.platform }}-${{ matrix.arch }}"
45
+ cache_key : " run-${{ matrix.os }}-${{ matrix.arch }}"
54
46
working_directory : .
55
47
56
48
- uses : nxtcoder17/actions/generate-image-tag@v1
@@ -62,86 +54,62 @@ jobs:
62
54
cachix_cache_name : ${{ secrets.CACHIX_CACHE_NAME }}
63
55
cachix_auth_token : ${{ secrets.CACHIX_AUTH_TOKEN }}
64
56
57
+ - uses : nxtcoder17/actions/metadata@main
58
+ id : meta
59
+
65
60
- name : Build Binary
66
61
shell : bash
67
62
env :
68
63
CGO_ENABLED : 0
64
+ GOOS : ${{matrix.os}}
65
+ GOARCH : ${{ matrix.arch }}
69
66
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")
76
69
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
82
75
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
103
80
104
81
- name : running for master branch
105
- if : startsWith(github.ref, 'refs/heads/master ')
82
+ if : startsWith(github.ref, 'refs/heads/')
106
83
env :
107
84
GH_TOKEN : ${{ github.token }}
85
+ version : ${{steps.meta.outputs.version}}
108
86
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"
117
89
118
90
- name : ensure github release exists
119
91
shell : bash
120
92
env :
121
93
GH_TOKEN : ${{ github.token }}
94
+ version : ${{steps.meta.outputs.version}}
122
95
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"
129
98
130
99
- name : upload to github release
131
100
shell : bash
132
101
env :
133
102
GH_TOKEN : ${{ github.token }}
103
+ version : ${{steps.meta.outputs.version}}
134
104
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/*
140
106
141
107
- name : mark release as latest
142
108
if : startsWith(github.ref, 'refs/tags/')
143
109
env :
144
110
GH_TOKEN : ${{ github.token }}
111
+ version : ${{steps.meta.outputs.version}}
145
112
shell : bash
146
113
run : |+
147
- gh release edit $IMAGE_TAG -R ${{ github.repository }} --latest
114
+ gh release edit $version -R ${{ github.repository }} --latest
115
+
0 commit comments