-
Notifications
You must be signed in to change notification settings - Fork 11
246 lines (234 loc) · 9.7 KB
/
release.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
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
name: Release
on:
push:
tags:
- v**
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: "aarch64-linux-gnu-gcc"
CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG: "true"
permissions:
contents: read
jobs:
check-install:
name: Check cargo install succeeds
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
with:
egress-policy: audit
- name: Checkout source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
- name: Remove config
run: rm -rf ./.cargo
- name: Install Rust toolchain (stable)
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203 # stable
with:
toolchain: stable
- name: Override toolchain
run: rustup override set stable
- name: Install
run: cargo install --bin rq --path ./crates/rsonpath
env:
RUSTFLAGS: "--deny warnings"
build:
name: Build matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
target_triple:
- aarch64-unknown-linux-gnu
- i686-pc-windows-gnu
- i686-pc-windows-msvc
- i686-unknown-linux-gnu
- x86_64-apple-darwin
- x86_64-pc-windows-gnu
- x86_64-pc-windows-msvc
- x86_64-unknown-linux-gnu
include:
- os: [self-hosted, linux, ARM64]
target_triple: aarch64-unknown-linux-gnu
rustflags: "-C link-arg=-fuse-ld=lld --deny warnings"
- os: ubuntu-latest
target_triple: i686-unknown-linux-gnu
# This target needs special setup.
prologue-script: sudo apt update && sudo apt install gcc-multilib
rustflags: "-C link-arg=-fuse-ld=lld --deny warnings"
- os: ubuntu-latest
target_triple: x86_64-unknown-linux-gnu
rustflags: "-C link-arg=-fuse-ld=lld --deny warnings"
- os: macos-latest
target_triple: x86_64-apple-darwin
rustflags: "--deny warnings"
- os: windows-latest
target_triple: i686-pc-windows-gnu
# This target needs special setup with MinGW.
needs-mingw: x86
rustflags: "-C link-arg=-fuse-ld=lld --deny warnings"
- os: windows-latest
target_triple: i686-pc-windows-msvc
rustflags: "-C link-arg=-fuse-ld=lld --deny warnings"
- os: windows-latest
target_triple: x86_64-pc-windows-gnu
rustflags: "-C link-arg=-fuse-ld=lld --deny warnings"
- os: windows-latest
target_triple: x86_64-pc-windows-msvc
rustflags: "-C link-arg=-fuse-ld=lld --deny warnings"
steps:
- name: Harden Runner
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
with:
egress-policy: audit
- name: Run prologue script
if: matrix.prologue-script != ''
run: ${{ matrix.prologue-script }}
- name: Cache restore (MinGW)
id: cache-restore-mingw
if: matrix.needs-mingw != ''
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
C:\ProgramData\chocolatey\lib\mingw
key: ${{ matrix.os }}-mingw-${{ matrix.needs-mingw }}-11-2
- name: Set up MinGW ${{ matrix.needs-mingw }}
if: matrix.needs-mingw != '' && steps.cache-restore-mingw.outputs.cache-hit != 'true'
uses: egor-tensin/setup-mingw@84c781b557efd538dec66bde06988d81cd3138cf # v2.2.0
with:
platform: ${{ matrix.needs-mingw }}
version: 12.2.0 # https://github.com/egor-tensin/setup-mingw/issues/14
- name: Add MinGW to PATH
if: matrix.needs-mingw != ''
run: echo "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw32\bin" >> $env:GITHUB_PATH
- name: Checkout source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
- name: Install lld (Unix)
if: matrix.os == 'ubuntu-latest'
run: sudo apt install lld
- name: Install Rust toolchain (stable)
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203 # stable
with:
toolchain: stable
target: ${{ matrix.target_triple }}
- name: Override toolchain
run: rustup override set stable
- name: Cache restore
id: cache-restore-cargo
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-${{ matrix.target_triple }}-cargo-${{ hashFiles('**/Cargo.toml') }}-release
- name: Build release (profile=distribution) for ${{ matrix.target-triple }}
run: cargo build --package rsonpath --profile=distribution --target ${{ matrix.target_triple }}
env:
RUSTFLAGS: ${{ matrix.rustflags }}
- name: Rename binary (Unix)
if: matrix.os != 'windows-latest'
run: rm -f target/distribution/rq-${{ matrix.target_triple }} && mv -f "target/${{ matrix.target_triple }}/distribution/rq" target/distribution/rq-${{ matrix.target_triple }}
- name: Rename binary (Windows)
if: matrix.os == 'windows-latest'
run: mv -Force "target/${{ matrix.target_triple }}/distribution/rq.exe" target/distribution/rq-${{ matrix.target_triple }}.exe
- name: Upload the binary as artifact
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: rq-${{ matrix.target_triple }}
# The * matches .exe if on windows and nothing otherwise.
path: target/distribution/rq-${{ matrix.target_triple }}*
if-no-files-found: error
github-release:
name: Release on GitHub
runs-on: ubuntu-latest
needs: [build, check-install]
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
permissions:
contents: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
with:
egress-policy: audit
- name: Download artifacts from build
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
path: release/
- name: Generate provenance subjects
id: hash
run: echo "hashes=$(sha256sum release/**/* | base64 -w0)" > $GITHUB_OUTPUT
- name: Generate provenance subjects sanity check
id: hash-sanity
run: echo "$(sha256sum release/**/* | base64 -w0)"
- name: Create GitHub Release
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
with:
name: ${{ github.ref_name }}
files: release/**/*
fail_on_unmatched_files: true
prerelease: ${{ endsWith(github.ref, 'rc') || endsWith(github.ref, 'alpha') || endsWith(github.ref, 'beta') }}
draft: true
provenance:
needs: [github-release]
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
permissions:
actions: read
id-token: write
contents: write
with:
base64-subjects: ${{ needs.github-release.outputs.hashes }}
upload-assets: true
upload-tag-name: ${{ github.ref_name }}
draft-release: true
crates-io-release:
name: Release on crates.io
needs: [check-install, github-release, provenance]
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
with:
egress-policy: audit
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust toolchain (stable)
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203 # stable
with:
toolchain: stable
- name: Publish rsonpath-syntax
run: |
old_ver=$(cargo info rsonpath-syntax --registry crates-io | sed -n 's/version: \([0-9]\.[0-9].[0-9]\)/\1/p')
new_ver=$(cargo pkgid rsonpath-syntax | sed 's/.*#//g')
if [ $old_ver != $new_ver ]; then
cargo publish --token ${{ secrets.CRATES_TOKEN }} -p rsonpath-syntax --no-verify
fi
- name: Publish rsonpath-syntax-proptest
run: |
old_ver=$(cargo info rsonpath-syntax-proptest --registry crates-io | sed -n 's/version: \([0-9]\.[0-9].[0-9]\)/\1/p')
new_ver=$(cargo pkgid rsonpath-syntax-proptest | sed 's/.*#//g')
if [ $old_ver != $new_ver ]; then
cargo publish --token ${{ secrets.CRATES_TOKEN }} -p rsonpath-syntax-proptest --no-verify
fi
- name: Publish rsonpath-lib
run: |
old_ver=$(cargo info rsonpath-lib --registry crates-io | sed -n 's/version: \([0-9]\.[0-9].[0-9]\)/\1/p')
new_ver=$(cargo pkgid rsonpath-lib | sed 's/.*#//g')
if [ $old_ver != $new_ver ]; then
cargo publish --token ${{ secrets.CRATES_TOKEN }} -p rsonpath-lib --no-verify
fi
- name: Publish rsonpath
run: |
old_ver=$(cargo info rsonpath --registry crates-io | sed -n 's/version: \([0-9]\.[0-9].[0-9]\)/\1/p')
new_ver=$(cargo pkgid rsonpath | sed 's/.*#//g')
if [ $old_ver != $new_ver ]; then
cargo publish --token ${{ secrets.CRATES_TOKEN }} -p rsonpath --no-verify
fi