-
Notifications
You must be signed in to change notification settings - Fork 259
272 lines (235 loc) · 8.46 KB
/
release.yaml
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: Release
on:
push:
tags:
- "v*"
jobs:
init:
runs-on: ubuntu-22.04
outputs:
version: ${{steps.version.outputs.version}}
prerelease: ${{steps.state.outputs.prerelease}}
steps:
- name: Evaluate state
id: state
env:
HEAD_REF: ${{github.head_ref}}
run: |
test -z "${HEAD_REF}" && (echo 'do-publish=true' >> $GITHUB_OUTPUT)
if [[ "${{ github.event.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo release=true >> $GITHUB_OUTPUT
elif [[ "${{ github.event.ref }}" =~ ^refs/tags/v.*$ ]]; then
echo prerelease=true >> $GITHUB_OUTPUT
fi
- name: Set version
id: version
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo "Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
build:
strategy:
fail-fast: false
matrix:
rust:
- stable
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- aarch64-apple-darwin
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
name: trunk-x86_64-unknown-linux-gnu.tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04
name: trunk-aarch64-unknown-linux-gnu.tar.gz
cross: "true"
# cross's container image is too old for us
args: --features vendored
- target: x86_64-unknown-linux-musl
os: ubuntu-22.04
name: trunk-x86_64-unknown-linux-musl.tar.gz
install: |
sudo apt install -y musl-tools
args: --features vendored
- target: aarch64-unknown-linux-musl
os: ubuntu-22.04
name: trunk-aarch64-unknown-linux-musl.tar.gz
cross: "true"
args: --features vendored
- target: x86_64-apple-darwin
os: macos-13
name: trunk-x86_64-apple-darwin.tar.gz
- target: aarch64-apple-darwin
os: macos-14
name: trunk-aarch64-apple-darwin.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-2022
name: trunk-x86_64-pc-windows-msvc.zip
ext: ".exe"
install: |
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
vcpkg install openssl:x64-windows-static-md
runs-on: ${{ matrix.os }}
steps:
- name: Setup | Checkout
uses: actions/checkout@v4
- name: Setup | Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Setup | Export GitHub Actions cache environment variables
uses: actions/github-script@v7
if: runner.os == 'Windows'
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite');
- name: Setup | Install dependencies
if: matrix.install != ''
run: ${{ matrix.install }}
- name: Setup | Disable rustup self-update
# workaround for: https://github.com/rust-lang/rustup/issues/3709
run: |
rustup set auto-self-update disable
- name: Setup | Rust
run: |
rustup toolchain install ${{ matrix.rust }} --target ${{ matrix.target }} --profile minimal
rustup default ${{ matrix.rust }}
- name: Setup | Cross
if: matrix.cross == 'true'
run: |
curl -sSL https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz -o binstall.tar.gz
tar xzf binstall.tar.gz
mv cargo-binstall $HOME/.cargo/bin/
cargo binstall cross -y
- name: Build | Build
shell: bash
run: |
if [[ "${{ matrix.xcode }}" == "true" ]]; then
export SDKROOT=$(xcrun -sdk macosx --show-sdk-path)
export MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)
fi
CMD="cargo"
if [[ -n "${{ matrix.cross }}" ]]; then
CMD="cross"
fi
OPTS="--release"
OPTS="$OPTS ${{ matrix.args }}"
if [[ -n "${{ matrix.target }}" ]]; then
OPTS="$OPTS --target=${{ matrix.target }}"
fi
${CMD} build ${OPTS}
- name: Post Build | List output
shell: bash
run: |
ls -l target/
- name: Post Build | Move binary
shell: bash
run: |
mkdir -p upload
# if we have an alternate target, there is a sub-directory
if [[ -f "target/release/trunk${{ matrix.ext }}" ]]; then
SRC="target/release/trunk${{ matrix.ext }}"
elif [[ -f "target/${{ matrix.target }}/release/trunk${{ matrix.ext }}" ]]; then
SRC="target/${{ matrix.target }}/release/trunk${{ matrix.ext }}"
else
echo "Unable to find output"
find target
false # stop build
fi
# for upload
cp -pv "${SRC}" upload/trunk${{ matrix.ext }}
- name: Post Build | Strip binary
if: matrix.cross != 'true'
working-directory: upload
run: |
ls -l trunk${{matrix.ext}}
strip trunk${{matrix.ext}}
ls -l trunk${{matrix.ext}}
- name: Post Build | Prepare artifacts [zip]
if: endsWith(matrix.name, '.zip')
working-directory: upload
run: |
7z a ${{ matrix.name }} trunk${{matrix.ext}}
- name: Post Build | Prepare artifacts [tar.gz]
if: endsWith(matrix.name, '.tar.gz')
working-directory: upload
run: |
tar czvf ${{ matrix.name }} trunk${{matrix.ext}}
- name: Post Build | Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: upload/${{ matrix.name }}
if-no-files-found: error
release:
needs:
- init
- build
runs-on: ubuntu-22.04
steps:
- name: Setup | Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup | Artifacts
uses: actions/download-artifact@v4
- name: Setup | Checksums
run: for file in trunk-*/trunk-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done
- name: Setup | Install convco
run: |
curl -sLO https://github.com/convco/convco/releases/download/v0.4.2/convco-ubuntu.zip
unzip convco-ubuntu.zip
chmod a+x convco
sudo mv convco /usr/local/bin
- name: Setup | Generate changelog
run: |
convco changelog -s --max-majors=1 --max-minors=1 --max-patches=1 > RELEASE_LOG.md
- name: Build | Publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: v${{ needs.init.outputs.version }}
run: |
OPTS=""
if [[ "${{ needs.init.outputs.prerelease }}" == "true" ]]; then
OPTS="${OPTS} -p"
fi
gh release create ${OPTS} --title "${{ needs.init.outputs.version }}" -F RELEASE_LOG.md ${TAG} \
trunk-*/trunk-*
publish:
needs: release
runs-on: ubuntu-22.04
steps:
- name: Setup | Checkout
uses: actions/checkout@v4
- name: Build | Publish
run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }}
pages:
needs:
- init
- publish
if: needs.init.outputs.prerelease != 'true'
uses: ./.github/workflows/pages.yaml
brew:
needs:
- init
- publish
if: needs.init.outputs.prerelease != 'true'
uses: ./.github/workflows/brew.yaml
with:
tag-name: v${{ needs.init.outputs.version }}
secrets: inherit