-
-
Notifications
You must be signed in to change notification settings - Fork 782
173 lines (153 loc) · 5.19 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
name: release
on:
push:
tags:
- "v*"
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
jobs:
build-release:
name: build-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
toolchain: [stable]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
binary: x86-64
use-cross: true
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
binary: aarch64
use-cross: true
# macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64
- os: macos-13
target: x86_64-apple-darwin
binary: x86_64
use-cross: false
- os: macos-latest
target: aarch64-apple-darwin
binary: arm64
use-cross: false
- os: windows-latest
target: x86_64-pc-windows-msvc
binary: x86-64
use-cross: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}
- name: Handle Rust dependencies caching
uses: Swatinem/rust-cache@v2
with:
key: v1-${{ matrix.target }}
- name: Build release binary
uses: clechasseur/rs-cargo@v2
with:
command: build
args: --release --target ${{ matrix.target }}
use-cross: ${{ matrix.use-cross }}
- name: Verify binary architecture
shell: bash
run: |
BINARY_PATH="target/${{ matrix.target }}/release/gleam"
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
BINARY_PATH="${BINARY_PATH}.exe"
fi
if ! file -b "$BINARY_PATH" | grep -q "${{ matrix.binary }}"; then
echo "error: Architecture mismatch"
echo "Expected architecture: '${{ matrix.binary }}'"
echo "Found binary type: '$(file -b "$BINARY_PATH")'"
exit 1
fi
echo "ok: Architecture match"
- name: Build archive
shell: bash
run: |
VERSION="${GITHUB_REF#refs/tags/}"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
ARCHIVE="gleam-$VERSION-${{ matrix.target }}.zip"
cp "target/${{ matrix.target }}/release/gleam.exe" "gleam.exe"
7z a "$ARCHIVE" "gleam.exe"
rm gleam.exe
else
ARCHIVE="gleam-$VERSION-${{ matrix.target }}.tar.gz"
cp "target/${{ matrix.target }}/release/gleam" "gleam"
tar -czvf "$ARCHIVE" "gleam"
rm gleam
fi
openssl dgst -r -sha256 -out "$ARCHIVE".sha256 "$ARCHIVE"
openssl dgst -r -sha512 -out "$ARCHIVE".sha512 "$ARCHIVE"
echo "ASSET=$ARCHIVE" >> $GITHUB_ENV
- name: Ensure binary successfully boots
shell: bash
run: |
case "${{ matrix.target }}" in
x86_64-pc-windows-msvc)
7z x "$ASSET"
./gleam.exe --version ;;
aarch64*)
echo "We cannot test an ARM binary on a AMD64 runner" ;;
*)
tar -xvzf "$ASSET"
./gleam --version ;;
esac
- name: Upload release archive
# https://github.com/softprops/action-gh-release/issues/445
# uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@0bd7e8b279c9b5b36661d552472fbbfe671fe26e
with:
draft: true
prerelease: false
fail_on_unmatched_files: true
files: |
${{ env.ASSET }}
${{ env.ASSET }}.sha256
${{ env.ASSET }}.sha512
build-release-wasm:
name: build-release-wasm
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
profile: minimal
override: true
- name: Install wasm-pack
run: curl -sSL https://rustwasm.github.io/wasm-pack/installer/init.sh | sh
- name: Build wasm
run: wasm-pack build --release --target web compiler-wasm
- name: Build wasm archive
run: |
VERSION="${GITHUB_REF#refs/tags/}"
ARCHIVE="gleam-$VERSION-browser.tar.gz"
tar -C compiler-wasm/pkg/ -czvf $ARCHIVE .
openssl dgst -r -sha256 -out "$ARCHIVE".sha256 "$ARCHIVE"
openssl dgst -r -sha512 -out "$ARCHIVE".sha512 "$ARCHIVE"
echo "ASSET=$ARCHIVE" >> $GITHUB_ENV
- name: Upload release archive
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: false
fail_on_unmatched_files: true
files: |
${{ env.ASSET }}
${{ env.ASSET }}.sha256
${{ env.ASSET }}.sha512