-
Notifications
You must be signed in to change notification settings - Fork 15
170 lines (153 loc) · 4.98 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Publish
on:
push:
tags:
- 'v*.*.*'
pull_request:
branches: [master, release/*]
jobs:
build:
name: Build for ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
env:
CARGO: cargo
strategy:
matrix:
name:
- linux-x86-gnu
- linux-x86-musl
- linux-arm-gnu
- linux-arm-musl
- macos-x86
- macos-arm
- macos-universal
- windows-x86
include:
- name: linux-x86-gnu
runner: ubuntu-latest
family: linux
arch: x86_64
target: x86_64-unknown-linux-gnu
archiver: tar.gz
asset: hl-linux-x86_64-gnu.tar.gz
skip: true
- name: linux-x86-musl
runner: ubuntu-latest
family: linux
arch: x86_64
target: x86_64-unknown-linux-musl
archiver: tar.gz
asset: hl-linux-x86_64-musl.tar.gz
cross: true
- name: linux-arm-gnu
runner: ubuntu-latest
family: linux
arch: aarch64
target: aarch64-unknown-linux-gnu
archiver: tar.gz
asset: hl-linux-arm64-gnu.tar.gz
cross: true
skip: true
- name: linux-arm-musl
runner: ubuntu-latest
family: linux
arch: aarch64
target: aarch64-unknown-linux-musl
archiver: tar.gz
asset: hl-linux-arm64-musl.tar.gz
cross: true
- name: macos-x86
runner: macos-latest
family: macos
arch: x86_64
target: x86_64-apple-darwin
archiver: tar.gz
asset: hl-macos-x86_64.tar.gz
- name: macos-arm
runner: macos-latest
family: macos
arch: aarch64
target: aarch64-apple-darwin
archiver: tar.gz
asset: hl-macos-arm64.tar.gz
- name: macos-universal
runner: macos-latest
family: macos
arch: '{aarch64,x86_64}'
target: '{aarch64,x86_64}-apple-darwin'
archiver: tar.gz
asset: hl-macos.tar.gz
universal: true
- name: windows-x86
runner: windows-latest
family: windows
arch: x86_64
target: x86_64-pc-windows-msvc
archiver: 7z
asset: hl-windows.zip
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
rustflags: ''
- name: Install Cross
if: matrix.cross
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
- name: Add Target
if: matrix.cross == false && matrix.target != ''
run: |
rustup target add ${{ matrix.target }}
- name: Build
run: echo ${{ matrix.target }} | xargs -n 1 ${{ env.CARGO }} build --release --locked --verbose --target
- name: Sign
if: matrix.family == 'macos'
run: codesign --force --deep --sign - ./target/${{ matrix.target }}/release/hl
- name: Package using `tar`
if: matrix.archiver == 'tar.gz' && matrix.universal == false
run: tar -C ./target/${{ matrix.target }}/release -cz -f ${{ matrix.asset }} hl
- name: Package using `7z`
if: matrix.archiver == '7z' && matrix.universal == false
run: 7z a ${{ matrix.asset }} .\target\${{ matrix.target }}\release\hl.exe
- name: Make universal binary
if: matrix.family == 'macos' && matrix.universal == true
run: lipo ./target/${{ matrix.target }}/release/hl -create -output ./target/hl
- name: Package universal binary using `tar`
if: matrix.archiver == 'tar.gz' && matrix.universal == true
run: tar -C ./target -cz -f ${{ matrix.asset }} hl
- name: Store artifact
if: matrix.skip != true
uses: actions/upload-artifact@v4
with:
name: hl-${{ matrix.arch }}-${{ matrix.family }}
path: target/${{ matrix.target }}/release/hl${{ matrix.family == 'windows' && '.exe' || '' }}
retention-days: 1
- name: Upload binaries to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.asset }}
tag: ${{ github.ref }}
publish:
name: Publish
needs: [build]
runs-on: ubuntu-22.04
steps:
- name: Checkout Git repo
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Set up Go
uses: actions/setup-go@v5
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean --skip=validate --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}