-
Notifications
You must be signed in to change notification settings - Fork 171
267 lines (243 loc) · 10.8 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
name: Release
on:
workflow_dispatch:
inputs:
release_version:
description: "Release version"
required: true
default: ""
create_release:
description: "Create release"
required: true
default: "true"
upload_artifacts:
description: "Upload artifacts"
required: true
default: "true"
push:
tags:
- "v*"
branches:
- arqu/release_windows
concurrency:
group: release-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
RUST_BACKTRACE: 1
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
MSRV: "1.75"
SCCACHE_CACHE_SIZE: "50G"
BIN_NAMES: "iroh,iroh-relay,iroh-dns-server"
RELEASE_VERSION: "v0.14.1-test"
jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.release.outputs.upload_url }}
release_version: ${{ env.RELEASE_VERSION }}
steps:
- name: Get the release version from the tag or input
shell: bash
if: env.RELEASE_VERSION == ''
run: |
if "${{ github.event.inputs.release_version }}" != ""; then
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
echo "version is: ${{ env.RELEASE_VERSION }}"
else
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.RELEASE_VERSION }}"
fi
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Create GitHub release
id: release
if: github.event.inputs.create_release == 'true' || github.event_name == 'push'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: ${{ env.RELEASE_VERSION || github.event.inputs.release_version}}
release_name: ${{ env.RELEASE_VERSION || github.event.inputs.release_version }}
build_release:
timeout-minutes: 60
name: Build release binaries
needs: create-release
runs-on: ${{ matrix.runner }}
continue-on-error: false
strategy:
fail-fast: false
matrix:
name: [ubuntu-latest, ubuntu-arm-latest, macOS-latest, macOS-arm-latest, windows-latest]
rust: [stable]
experimental: [false]
include:
- name: ubuntu-arm-latest
os: ubuntu-latest
release-os: linux
release-arch: aarch64
cargo_targets: "aarch64-unknown-linux-musl"
runner: [self-hosted, linux, ARM64]
- name: ubuntu-latest
os: ubuntu-latest
release-os: linux
release-arch: amd64
cargo_targets: "x86_64-unknown-linux-musl"
runner: [self-hosted, linux, X64]
- name: macOS-latest
os: macOS-latest
release-os: darwin
release-arch: x86_64
cargo_targets: "x86_64-apple-darwin"
runner: [self-hosted, macOS, X64]
- name: macOS-arm-latest
os: macOS-latest
release-os: darwin
release-arch: aarch64
cargo_targets: "aarch64-apple-darwin"
runner: [self-hosted, macOS, ARM64]
- name: windows-latest
os: windows-latest
release-os: windows
release-arch: amd64
cargo_targets: "x86_64-pc-windows-msvc"
runner: [self-hosted, windows, X64]
env:
# Using self-hosted runners so use local cache for sccache and
# not SCCACHE_GHA_ENABLED.
# RUSTC_WRAPPER: "sccache"
RUST_BACKTRACE: full
RUSTV: ${{ matrix.rust }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set build arch
run: |
echo "RELEASE_ARCH=${{ matrix.release-arch }}" >> $GITHUB_ENV
echo "RELEASE_OS=${{ matrix.release-os }}" >> $GITHUB_ENV
- name: Ensure musl support
if: ${{ contains(matrix.cargo_targets, '-musl') }}
run: sudo apt-get install musl-tools -y
- name: Install Rust
if: matrix.os != 'windows-latest'
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.cargo_targets }}
- name: Install Rust
if: matrix.os == 'windows-latest'
run: |
rustup toolchain install stable
rustup target add ${{ matrix.cargo_targets }}
- name: build release
if: matrix.os != 'windows-latest'
shell: bash
run: |
if [ "${{ matrix.name }}" = "ubuntu-arm-latest" ]; then
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc
export CC=aarch64-linux-gnu-gcc
fi
cargo build --profile optimized-release --all-features --target ${{ matrix.cargo_targets }}
- name: build release
if: matrix.os == 'windows-latest'
run: cargo build --profile optimized-release --all-features --target ${{ matrix.cargo_targets }}
- name: attach artifacts
if: matrix.os != 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: iroh-${{env.RELEASE_OS }}-${{env.RELEASE_ARCH}}
path: target/${{ matrix.cargo_targets }}/optimized-release/iroh
compression-level: 0
- name: attach artifacts
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: iroh-windows-amd64.exe
path: target/${{ matrix.cargo_targets }}/optimized-release/iroh.exe
compression-level: 0
- name: Setup awscli on linux
if: matrix.name == 'ubuntu-latest'
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
- name: Setup awscli on linux
if: matrix.name == 'ubuntu-arm-latest'
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
- name: Setup awscli on mac
if: matrix.os == 'macos-latest'
run: |
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
- name: Set aws credentials
if: matrix.os != 'windows-latest'
run: |
echo "AWS_ACCESS_KEY_ID=${{secrets.S3_ACCESS_KEY_ID}}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{secrets.S3_ACCESS_KEY}}" >> $GITHUB_ENV
echo "AWS_DEFAULT_REGION=us-west-2" >> $GITHUB_ENV
- name: push release
if: matrix.os != 'windows-latest'
run: |
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh s3://vorc/iroh-${RELEASE_OS}-${RELEASE_ARCH}-${GITHUB_SHA::7} --no-progress
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-relay s3://vorc/iroh-relay-${RELEASE_OS}-${RELEASE_ARCH}-${GITHUB_SHA::7} --no-progress
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-dns-server s3://vorc/iroh-dns-server-${RELEASE_OS}-${RELEASE_ARCH}-${GITHUB_SHA::7} --no-progress
- name: push release latest
if: matrix.os != 'windows-latest'
run: |
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh s3://vorc/iroh-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-relay s3://vorc/iroh-relay-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-dns-server s3://vorc/iroh-dns-server-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress
- name: Build archives
if: matrix.os != 'windows-latest'
shell: bash
run: |
IFS=',' read -ra BIN_NAMES <<< "${{ env.BIN_NAMES }}"
ASSETS=""
for BIN_NAME in "${BIN_NAMES[@]}"; do
staging="$BIN_NAME-${{ needs.create-release.outputs.release_version }}-${{ matrix.cargo_targets }}"
mkdir -p "$staging"
cp "target/${{ matrix.cargo_targets }}/optimized-release/$BIN_NAME" "$staging/"
tar czf "$staging.tar.gz" -C "$staging" .
ASSETS+="$staging.tar.gz,"
done
echo "ASSET=$(echo $ASSETS | sed 's/,$//')" >> $GITHUB_ENV
- name: Build archives (windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$BIN_NAMES = "${{ env.BIN_NAMES }}".Split(',')
$ASSETS = @()
foreach ($BIN_NAME in $BIN_NAMES) {
$staging = "$BIN_NAME-${{ needs.create-release.outputs.release_version }}-${{ matrix.cargo_targets }}"
New-Item -ItemType Directory -Force -Path "$staging"
Copy-Item -Path "target/${{ matrix.cargo_targets }}/optimized-release/$BIN_NAME.exe" -Destination "$staging/"
Set-Location -Path "$staging"
Compress-Archive -Path * -DestinationPath "../$staging.zip"
$ASSETS += "$staging.zip"
Set-Location -Path ..
}
$ASSETS = $ASSETS -join ','
Add-Content -Path $env:GITHUB_ENV -Value "ASSET=$ASSETS"
- name: Install file
shell: bash
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: sudo apt update && sudo apt install -y file
- name: Upload release archives
if: (github.event.inputs.upload_artifacts == 'true' || github.event_name == 'push') && matrix.os != 'windows-latest'
shell: bash
run: .github/scripts/upload_gh_asset.sh "${{ secrets.GITHUB_TOKEN }}" "${{ needs.create-release.outputs.upload_url }}" "${{ env.ASSET }}"
- name: Upload release archives (windows)
if: (github.event.inputs.upload_artifacts == 'true' || github.event_name == 'push') && matrix.os == 'windows-latest'
# This exists purely because the GH runners don't properly escape the path to the bash script and the WSL fails to run it.
shell: pwsh
run: bash .github/scripts/upload_gh_asset.sh "${{ secrets.GITHUB_TOKEN }}" "${{ needs.create-release.outputs.upload_url }}" "${{ env.ASSET }}"