Skip to content

Commit 4a26882

Browse files
committed
fix windows runner
1 parent dd47ea9 commit 4a26882

4 files changed

Lines changed: 75 additions & 38 deletions

File tree

.github/goreleaser.linuxwin.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@ archives:
4848
- format: binary
4949
files:
5050
- none*
51-
- id: homebrew
52-
name_template: >-
53-
{{- .ProjectName }}_
54-
{{- title .Os }}_
55-
{{- if eq .Arch "amd64" }}x86_64
56-
{{- else if eq .Arch "386" }}i386
57-
{{- else }}{{ .Arch }}{{ end }}
58-
{{- if .Arm }}v{{ .Arm }}{{ end -}}
59-
format: zip
6051

6152
universal_binaries:
6253
- replace: true

.github/goreleaser.windows.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: 2
2+
3+
builds:
4+
- id: windows
5+
env:
6+
- CGO_ENABLED=1
7+
ldflags:
8+
- -s -w -X github.com/unblocked/chissl/share.BuildVersion={{.Version}}
9+
flags:
10+
- -trimpath
11+
goos:
12+
- windows
13+
goarch:
14+
- amd64
15+
16+
archives:
17+
- format: binary
18+
files:
19+
- none*
20+
21+
changelog:
22+
sort: asc
23+
filters:
24+
exclude:
25+
- "^docs:"
26+
- "^test:"
27+

.github/workflows/ci.yml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
if: startsWith(github.ref, 'refs/tags/v')
8686
strategy:
8787
matrix:
88-
os: [ubuntu-latest, macos-latest]
88+
os: [ubuntu-latest, macos-latest, windows-latest]
8989
runs-on: ${{ matrix.os }}
9090
steps:
9191
- name: Check out code
@@ -96,28 +96,26 @@ jobs:
9696
with:
9797
go-version: 1.21.x
9898

99+
- name: Set up MSYS2 (Windows)
100+
if: runner.os == 'Windows'
101+
uses: msys2/setup-msys2@v2
102+
with:
103+
update: true
104+
msystem: MINGW64
105+
install: >-
106+
mingw-w64-x86_64-gcc
107+
mingw-w64-x86_64-pkg-config
108+
99109
- name: Install cross toolchains and libc headers (Linux CGO)
100110
if: runner.os == 'Linux'
101111
run: |
102-
set -euo pipefail
103112
sudo apt-get update
104113
sudo apt-get install -y \
105114
gcc-arm-linux-gnueabihf gcc-arm-linux-gnueabi gcc-aarch64-linux-gnu \
106115
libc6-dev-armhf-cross libc6-dev-arm64-cross \
107-
linux-libc-dev-armhf-cross linux-libc-dev-arm64-cross \
108-
mingw-w64 gcc-mingw-w64 gcc-mingw-w64-x86-64
109-
# ensure mingw uses win32 threads model (so -mthreads is supported)
110-
if command -v update-alternatives >/dev/null 2>&1; then
111-
if [ -x /usr/bin/x86_64-w64-mingw32-gcc-win32 ]; then
112-
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-win32 || true
113-
fi
114-
if [ -x /usr/bin/x86_64-w64-mingw32-g++-win32 ]; then
115-
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-win32 || true
116-
fi
117-
fi \
118-
mingw-w64 gcc-mingw-w64 gcc-mingw-w64-x86-64
116+
linux-libc-dev-armhf-cross linux-libc-dev-arm64-cross
119117
120-
- name: Run GoReleaser [Linux+Windows]
118+
- name: Run GoReleaser [Linux]
121119
if: runner.os == 'Linux'
122120
uses: goreleaser/goreleaser-action@v5
123121
with:
@@ -129,6 +127,18 @@ jobs:
129127
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130128
CGO_ENABLED: 1
131129

130+
- name: Run GoReleaser [Windows]
131+
if: runner.os == 'Windows'
132+
uses: goreleaser/goreleaser-action@v5
133+
with:
134+
distribution: goreleaser
135+
version: v2.4.0
136+
args: release --verbose --config .github/goreleaser.windows.yml
137+
env:
138+
GORELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
CGO_ENABLED: 1
141+
132142
- name: Run GoReleaser [Darwin]
133143
if: runner.os == 'macOS'
134144
uses: goreleaser/goreleaser-action@v5

.github/workflows/release-dry-run.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
if: needs.check-permissions.outputs.allowed == 'true'
3939
strategy:
4040
matrix:
41-
os: [ubuntu-latest, macos-latest]
41+
os: [ubuntu-latest, macos-latest, windows-latest]
4242
runs-on: ${{ matrix.os }}
4343
permissions:
4444
contents: read
@@ -51,27 +51,26 @@ jobs:
5151
with:
5252
go-version: 1.21.x
5353

54+
- name: Set up MSYS2 (Windows)
55+
if: runner.os == 'Windows'
56+
uses: msys2/setup-msys2@v2
57+
with:
58+
update: true
59+
msystem: MINGW64
60+
install: >-
61+
mingw-w64-x86_64-gcc
62+
mingw-w64-x86_64-pkg-config
63+
5464
- name: Install cross toolchains and libc headers (Linux CGO)
5565
if: runner.os == 'Linux'
5666
run: |
57-
set -euo pipefail
5867
sudo apt-get update
5968
sudo apt-get install -y \
6069
gcc-arm-linux-gnueabihf gcc-arm-linux-gnueabi gcc-aarch64-linux-gnu \
6170
libc6-dev-armhf-cross libc6-dev-arm64-cross \
62-
linux-libc-dev-armhf-cross linux-libc-dev-arm64-cross \
63-
mingw-w64 gcc-mingw-w64 gcc-mingw-w64-x86-64
64-
# ensure mingw uses win32 threads model (so -mthreads is supported)
65-
if command -v update-alternatives >/dev/null 2>&1; then
66-
if [ -x /usr/bin/x86_64-w64-mingw32-gcc-win32 ]; then
67-
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-win32 || true
68-
fi
69-
if [ -x /usr/bin/x86_64-w64-mingw32-g++-win32 ]; then
70-
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-win32 || true
71-
fi
72-
fi
71+
linux-libc-dev-armhf-cross linux-libc-dev-arm64-cross
7372
74-
- name: Run GoReleaser build [Linux+Windows]
73+
- name: Run GoReleaser build [Linux]
7574
if: runner.os == 'Linux'
7675
uses: goreleaser/goreleaser-action@v5
7776
with:
@@ -81,6 +80,16 @@ jobs:
8180
env:
8281
CGO_ENABLED: 1
8382

83+
- name: Run GoReleaser build [Windows]
84+
if: runner.os == 'Windows'
85+
uses: goreleaser/goreleaser-action@v5
86+
with:
87+
distribution: goreleaser
88+
version: v2.4.0
89+
args: build --verbose --snapshot --clean --config .github/goreleaser.windows.yml
90+
env:
91+
CGO_ENABLED: 1
92+
8493
- name: Run GoReleaser build [Darwin]
8594
if: runner.os == 'macOS'
8695
uses: goreleaser/goreleaser-action@v5

0 commit comments

Comments
 (0)