-
Notifications
You must be signed in to change notification settings - Fork 23
238 lines (214 loc) · 8.07 KB
/
Copy pathrelease.yaml
File metadata and controls
238 lines (214 loc) · 8.07 KB
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
name: Release
permissions:
contents: write
on:
push:
tags:
- v[0-9]+.*
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
with:
changelog: CHANGELOG.md
# (required) GitHub token for creating GitHub Releases.
token: ${{ secrets.GITHUB_TOKEN }}
upload-assets-mycelium:
needs: create-release
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: taiki-e/upload-rust-binary-action@v1
with:
# Name of the compiled binary, also name of the non-extension part of the produced file
bin: mycelium
# --target flag value, default is host
target: ${{ matrix.target }}
# Name of the archive when uploaded
archive: $bin-$target
# (required) GitHub token for uploading assets to GitHub Releases.
token: ${{ secrets.GITHUB_TOKEN }}
# Specify manifest since we are in a subdirectory
manifest-path: myceliumd/Cargo.toml
# TODO: Figure out the correct matrix setup to have this in a single action
upload-assets-myceliumd-private:
needs: create-release
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: taiki-e/upload-rust-binary-action@v1
with:
# Name of the compiled binary, also name of the non-extension part of the produced file
bin: mycelium-private
# Set the vendored-openssl flag for provided release builds
features: vendored-openssl
# --target flag value, default is host
target: ${{ matrix.target }}
# Name of the archive when uploaded
archive: $bin-$target
# (required) GitHub token for uploading assets to GitHub Releases.
token: ${{ secrets.GITHUB_TOKEN }}
# Specify manifest since we are in a subdirectory
manifest-path: myceliumd-private/Cargo.toml
upload-assets-libmycelium:
needs: create-release
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
dyn_lib: libmycelium.so
dyn_versioned: libmycelium.so.0
link_arg: -Wl,-soname,libmycelium.so.0
cross_apt: gcc-aarch64-linux-gnu
cross_linker_var: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER
cross_linker_val: aarch64-linux-gnu-gcc
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
dyn_lib: libmycelium.so
dyn_versioned: libmycelium.so.0
link_arg: -Wl,-soname,libmycelium.so.0
cross_apt: ""
cross_linker_var: ""
cross_linker_val: ""
- target: aarch64-apple-darwin
os: macos-latest
dyn_lib: libmycelium.dylib
dyn_versioned: libmycelium.0.dylib
link_arg: -Wl,-install_name,@rpath/libmycelium.0.dylib
cross_apt: ""
cross_linker_var: ""
cross_linker_val: ""
- target: x86_64-apple-darwin
os: macos-latest
dyn_lib: libmycelium.dylib
dyn_versioned: libmycelium.0.dylib
link_arg: -Wl,-install_name,@rpath/libmycelium.0.dylib
cross_apt: ""
cross_linker_var: ""
cross_linker_val: ""
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Linux cross toolchain
if: matrix.cross_apt != ''
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.cross_apt }}
- name: Build libmycelium
shell: bash
env:
RUSTFLAGS: -C link-arg=${{ matrix.link_arg }}
run: |
set -euo pipefail
if [ -n "${{ matrix.cross_linker_var }}" ]; then
export ${{ matrix.cross_linker_var }}=${{ matrix.cross_linker_val }}
fi
cargo build --release \
--manifest-path mycelium/Cargo.toml \
--target ${{ matrix.target }} \
--features ffi
- name: Stage artifacts
shell: bash
run: |
set -euo pipefail
TARGET_DIR="target/${{ matrix.target }}/release"
mkdir -p pkg/lib pkg/include
cp "$TARGET_DIR/${{ matrix.dyn_lib }}" "pkg/lib/${{ matrix.dyn_versioned }}"
ln -s "${{ matrix.dyn_versioned }}" "pkg/lib/${{ matrix.dyn_lib }}"
cp "$TARGET_DIR/libmycelium.a" pkg/lib/libmycelium.a
# cbindgen writes mycelium.h into the build-script OUT_DIR
# (target/<TARGET>/release/build/mycelium-<fingerprint>/out/).
# The dir name shares a prefix with sibling workspace crates
# (mycelium-tun, mycelium-api, ...) so glob on the file name —
# only mycelium/build.rs emits a header by that name.
headers=()
while IFS= read -r line; do
headers+=("$line")
done < <(find "$TARGET_DIR/build" -type f -name mycelium.h)
if [ ${#headers[@]} -ne 1 ]; then
echo "Expected exactly one mycelium.h, found ${#headers[@]}:" >&2
printf ' %s\n' "${headers[@]}" >&2
exit 1
fi
cp "${headers[0]}" pkg/include/mycelium.h
- name: Verify SONAME / install_name
shell: bash
run: |
set -euo pipefail
if [ "${{ runner.os }}" = "Linux" ]; then
readelf -d "pkg/lib/${{ matrix.dyn_versioned }}" \
| grep -q 'SONAME.*libmycelium\.so\.0'
else
otool -D "pkg/lib/${{ matrix.dyn_versioned }}" \
| grep -q '@rpath/libmycelium\.0\.dylib'
fi
- name: Create tarball
shell: bash
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
tar -czf "libmycelium-${VERSION}-${{ matrix.target }}.tar.gz" -C pkg .
- name: Upload tarball to release
uses: alexellis/upload-assets@0.4.0
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["libmycelium-*.tar.gz"]'
build-msi:
needs: create-release
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Create .exe file
shell: bash
run: cd myceliumd && RUSTFLAGS="-C target-feature=+crt-static" cargo build --release && cd ..
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4.0.0
- name: Install WiX Toolset
run: dotnet tool install --global wix --version 6.0.2
- name: Add WixToolset.UI.wixext extension
run: wix extension add WixToolset.UI.wixext/6.0.2
- name: Download Wintun zip file
run: curl -o wintun.zip https://www.wintun.net/builds/wintun-0.14.1.zip
- name: Unzip Wintun
run: unzip wintun.zip
- name: Move .dll file to myceliumd directory
run: move wintun\bin\amd64\wintun.dll myceliumd
- name: Build MSI package
run: wix build -loc installers\windows\wix\mycelium.en-us.wxl installers\windows\wix\mycelium.wxs -ext WixToolset.UI.wixext -arch x64 -dcl high -out mycelium_installer.msi
- name: Upload MSI artifact
uses: alexellis/upload-assets@0.4.0
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["mycelium_installer.msi"]'