Skip to content

Commit eb5f694

Browse files
committed
enforce correct GOOS/GOARCH build and arch-specific binary names
1 parent 566d457 commit eb5f694

1 file changed

Lines changed: 72 additions & 25 deletions

File tree

.github/workflows/release-build.yml

Lines changed: 72 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
uses: actions/setup-go@v5
5555
with:
5656
go-version: "stable"
57+
cache: true
5758

5859
- name: Setup tools
5960
run: |
@@ -77,35 +78,81 @@ jobs:
7778
run: |
7879
bash scripts/fetch_usque.sh "${{ matrix.os }}" "${{ matrix.arch }}"
7980
80-
- name: Build project
81+
- name: Build project (skip for android)
8182
if: ${{ matrix.os != 'android' }}
82-
env:
83-
CGO_ENABLED: 0
8483
run: |
8584
mkdir -p build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}
8685
87-
set_go_envs() {
88-
case "${{ matrix.arch }}" in
89-
amd64) echo "GOOS=${{ matrix.os }} GOARCH=amd64" ;;
90-
arm64) echo "GOOS=${{ matrix.os }} GOARCH=arm64" ;;
91-
armv5) echo "GOOS=${{ matrix.os }} GOARCH=arm GOARM=5" ;;
92-
armv6) echo "GOOS=${{ matrix.os }} GOARCH=arm GOARM=6" ;;
93-
armv7) echo "GOOS=${{ matrix.os }} GOARCH=arm GOARM=7" ;;
94-
mips) echo "GOOS=${{ matrix.os }} GOARCH=mips" ;;
95-
mipsle) echo "GOOS=${{ matrix.os }} GOARCH=mipsle" ;;
96-
mips64) echo "GOOS=${{ matrix.os }} GOARCH=mips64" ;;
97-
mips64le) echo "GOOS=${{ matrix.os }} GOARCH=mips64le" ;;
98-
*) echo "unsupported arch: ${{ matrix.arch }}"; exit 1 ;;
99-
esac
100-
}
101-
102-
eval "$(set_go_envs)"
103-
104-
if [ "${{ matrix.os }}" = "windows" ]; then
105-
go build -o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus.exe .
106-
else
107-
go build -o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus .
108-
fi
86+
case "${{ matrix.os }}_${{ matrix.arch }}" in
87+
windows_amd64)
88+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 \
89+
go build -trimpath -ldflags="-s -w" \
90+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }}.exe .
91+
;;
92+
windows_arm64)
93+
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 \
94+
go build -trimpath -ldflags="-s -w" \
95+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }}.exe .
96+
;;
97+
darwin_amd64)
98+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 \
99+
go build -trimpath -ldflags="-s -w" \
100+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }} .
101+
;;
102+
darwin_arm64)
103+
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 \
104+
go build -trimpath -ldflags="-s -w" \
105+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }} .
106+
;;
107+
linux_amd64)
108+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
109+
go build -trimpath -ldflags="-s -w" \
110+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }} .
111+
;;
112+
linux_arm64)
113+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 \
114+
go build -trimpath -ldflags="-s -w" \
115+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }} .
116+
;;
117+
linux_armv5)
118+
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 \
119+
go build -trimpath -ldflags="-s -w" \
120+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }} .
121+
;;
122+
linux_armv6)
123+
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 \
124+
go build -trimpath -ldflags="-s -w" \
125+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }} .
126+
;;
127+
linux_armv7)
128+
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 \
129+
go build -trimpath -ldflags="-s -w" \
130+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }} .
131+
;;
132+
linux_mips)
133+
CGO_ENABLED=0 GOOS=linux GOARCH=mips \
134+
go build -trimpath -ldflags="-s -w" \
135+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }} .
136+
;;
137+
linux_mipsle)
138+
CGO_ENABLED=0 GOOS=linux GOARCH=mipsle \
139+
go build -trimpath -ldflags="-s -w" \
140+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }} .
141+
;;
142+
linux_mips64)
143+
CGO_ENABLED=0 GOOS=linux GOARCH=mips64 \
144+
go build -trimpath -ldflags="-s -w" \
145+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }} .
146+
;;
147+
linux_mips64le)
148+
CGO_ENABLED=0 GOOS=linux GOARCH=mips64le \
149+
go build -trimpath -ldflags="-s -w" \
150+
-o build/masque-plus/${{ matrix.os }}_${{ matrix.arch }}/masque-plus_${{ matrix.os }}_${{ matrix.arch }} .
151+
;;
152+
*)
153+
echo "unsupported target: ${{ matrix.os }}_${{ matrix.arch }}"; exit 1
154+
;;
155+
esac
109156
110157
- name: Prepare package directory (android)
111158
if: ${{ matrix.os == 'android' }}

0 commit comments

Comments
 (0)