Repository navigation
213 lines (192 loc) · 7.17 KB
/
Copy pathrelease.yml
File metadata and controls
213 lines (192 loc) · 7.17 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: Existing version tag to package and release (vMAJOR.MINOR.PATCH)
required: true
type: string
env:
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
permissions:
contents: write
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
asset_name: malia-darwin-arm64
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
asset_name: malia-darwin-x64
# glibc targets build inside manylinux_2_28 (glibc 2.28), so the
# binaries run on RHEL/Alma 8+, Debian 10+, Ubuntu 20.04+; building on
# the runner itself would require its own (much newer) glibc.
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
asset_name: malia-linux-x64-gnu
build_packages: true
manylinux: quay.io/pypa/manylinux_2_28_x86_64
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
archive: tar.gz
asset_name: malia-linux-x64-musl
musl_docker: true
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
archive: tar.gz
asset_name: malia-linux-arm64-gnu
build_packages: true
pkg_arch: arm64
manylinux: quay.io/pypa/manylinux_2_28_aarch64
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
asset_name: malia-win32-x64
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_TAG }}
- name: Validate release tag
shell: bash
run: |
if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Expected an existing vMAJOR.MINOR.PATCH tag" >&2
exit 1
fi
git rev-parse --verify "refs/tags/$RELEASE_TAG"
# The tag, Cargo.toml and every npm package must agree.
python3 scripts/version.py check "$RELEASE_TAG"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.97.0
with:
targets: ${{ matrix.target }}
- name: Build release binaries
shell: bash
run: |
if [ -n "${{ matrix.manylinux }}" ]; then
docker run --rm -v "$PWD":/src -w /src "${{ matrix.manylinux }}" bash -c '
set -e
curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none
. "$HOME/.cargo/env"
cargo build --locked --release --target ${{ matrix.target }} --bins'
sudo chown -R "$(id -u):$(id -g)" target
elif [ "${{ matrix.musl_docker }}" = "true" ]; then
docker run --rm -v "$PWD":/src -w /src \
-e RUSTUP_HOME=/usr/local/rustup \
-e CARGO_HOME=/usr/local/cargo \
rust:1.97-bookworm bash -c '
set -e
apt-get update && apt-get install -y musl-tools
rustup target add ${{ matrix.target }}
cargo build --locked --release --target ${{ matrix.target }} --bins'
sudo chown -R "$(id -u):$(id -g)" target
else
cargo build --locked --release --target ${{ matrix.target }} --bins
fi
- name: Check glibc requirement (Linux glibc builds)
if: matrix.manylinux
shell: bash
run: |
need=$(objdump -T "target/${{ matrix.target }}/release/malia" | grep -oE 'GLIBC_2\.[0-9]+' | sort -V | uniq | tail -1)
echo "malia needs $need"
if [ "$(printf '%s\nGLIBC_2.28\n' "$need" | sort -V | tail -1)" != "GLIBC_2.28" ]; then
echo "binary requires $need; releases must run on glibc 2.28" >&2
exit 1
fi
- name: Package tarball (Unix)
if: matrix.archive == 'tar.gz'
shell: bash
run: |
BIN_DIR="target/${{ matrix.target }}/release"
strip "$BIN_DIR/malia" 2>/dev/null || true
mkdir -p "dist"
tar -czf "dist/${{ matrix.asset_name }}.tar.gz" -C "$BIN_DIR" malia
- name: Build .deb and .rpm packages
if: matrix.build_packages
shell: bash
run: |
# Install nfpm
NFPM_VERSION=2.47.0
NFPM_ARCH=$([ "$(uname -m)" = "aarch64" ] && echo arm64 || echo x86_64)
curl -fsSL "https://github.com/goreleaser/nfpm/releases/download/v${NFPM_VERSION}/nfpm_${NFPM_VERSION}_Linux_${NFPM_ARCH}.tar.gz" | tar xz -C /tmp nfpm
/tmp/nfpm --version
BIN_DIR="target/${{ matrix.target }}/release"
VERSION="${RELEASE_TAG#v}"
ARCH="${{ matrix.pkg_arch || 'amd64' }}"
# Copy binary to working dir for nfpm
cp "$BIN_DIR/malia" ./malia
# Build .deb
ARCH="$ARCH" VERSION="$VERSION" /tmp/nfpm package \
--config nfpm.yaml \
--packager deb \
--target "dist/malia_${VERSION}_${ARCH}.deb"
# Build .rpm
RPM_ARCH="$ARCH"
if [ "$RPM_ARCH" = "amd64" ]; then RPM_ARCH="x86_64"; fi
if [ "$RPM_ARCH" = "arm64" ]; then RPM_ARCH="aarch64"; fi
ARCH="$RPM_ARCH" VERSION="$VERSION" /tmp/nfpm package \
--config nfpm.yaml \
--packager rpm \
--target "dist/malia-${VERSION}-1.${RPM_ARCH}.rpm"
rm -f ./malia
ls -la dist/
- name: Package zip (Windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
$BinDir = "target/${{ matrix.target }}/release"
New-Item -ItemType Directory -Path "dist" -Force | Out-Null
Compress-Archive -Path "$BinDir\malia.exe" -DestinationPath "dist\${{ matrix.asset_name }}.zip" -Force
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: dist/*
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_TAG }}
- name: Validate release tag
shell: bash
run: |
if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Expected an existing vMAJOR.MINOR.PATCH tag" >&2
exit 1
fi
git rev-parse --verify "refs/tags/$RELEASE_TAG"
- name: Download all built artifacts
uses: actions/download-artifact@v4
with:
path: release-assets
merge-multiple: true
- name: Generate SHA256 checksums
run: |
cd release-assets
sha256sum * > SHA256SUMS
cat SHA256SUMS
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
files: release-assets/*
draft: false
prerelease: false
generate_release_notes: true