Skip to content

Commit fcd3d12

Browse files
committed
ci: release workflow
1 parent 403d3f5 commit fcd3d12

File tree

2 files changed

+166
-0
lines changed

2 files changed

+166
-0
lines changed

.github/workflows/config.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[build]
2+
target = ["riscv32im-succinct-zkvm-elf"]
3+
extended = true
4+
tools = ["cargo", "cargo-clippy", "clippy", "rustfmt"]
5+
configure-args = []
6+
cargo-native-static = true
7+
8+
[rust]
9+
lld = true
10+
llvm-tools = true
11+
12+
[llvm]
13+
download-ci-llvm = false

.github/workflows/release.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
on:
2+
push:
3+
tags:
4+
- "v*.*.*"
5+
6+
name: "Release"
7+
8+
jobs:
9+
version-info:
10+
name: "Extract version info"
11+
runs-on: "ubuntu-latest"
12+
outputs:
13+
version: ${{ steps.derive.outputs.version }}
14+
15+
steps:
16+
- id: "derive"
17+
name: "Derive version info from Git tag"
18+
run: |
19+
FULL_REF="${{ github.ref }}"
20+
REGEX="^refs\/tags\/v(.*)$"
21+
[[ $FULL_REF =~ $REGEX ]];
22+
23+
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
24+
25+
draft-release:
26+
name: "Create draft release"
27+
runs-on: "ubuntu-latest"
28+
needs:
29+
- "version-info"
30+
outputs:
31+
release-id: ${{ steps.create.outputs.id }}
32+
33+
steps:
34+
- id: "create"
35+
name: "Create draft release"
36+
run: |
37+
ID=$(curl -L --fail "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases" \
38+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
39+
-d '{"tag_name":"v${{ needs.version-info.outputs.version }}","name":"v${{ needs.version-info.outputs.version }}","draft":true,"generate_release_notes":true}' |
40+
jq ".id")
41+
echo "id=$ID" >> $GITHUB_OUTPUT
42+
43+
release-unix:
44+
name: "Build for ${{ matrix.triple }}"
45+
runs-on: "${{ matrix.runner }}"
46+
needs:
47+
- "version-info"
48+
- "draft-release"
49+
50+
strategy:
51+
matrix:
52+
include:
53+
# WARN: DO NOT upgrade Ubuntu runner to 22.04 or higher, as that would cause glibc 3.2+ to
54+
# be linked, and therefore errors when running on Ubuntu 20.04.
55+
- runner: "buildjet-32vcpu-ubuntu-2004"
56+
triple: "x86_64-unknown-linux-gnu"
57+
# Using Ubuntu 22 for now as none of these support Ubuntu 20 on ARM64:
58+
#
59+
# - GitHub Actions large runners
60+
# - BuildJet
61+
# - runs-on
62+
#
63+
# FIXME: use `ec2-github-runner` to build on Ubuntu 20.04 instead.
64+
- runner:
65+
[
66+
"runs-on",
67+
"runner=64cpu-linux-arm64",
68+
"image=ubuntu22-full-arm64",
69+
"run-id=${{ github.run_id }}",
70+
]
71+
triple: "aarch64-unknown-linux-gnu"
72+
- runner: "macos-13"
73+
triple: "x86_64-apple-darwin"
74+
- runner: "macos-14"
75+
triple: "aarch64-apple-darwin"
76+
77+
steps:
78+
- name: "Checkout source code"
79+
uses: "actions/checkout@v3"
80+
with:
81+
submodules: "recursive"
82+
fetch-depth: 0
83+
84+
- name: "Setup ninja-build"
85+
if: matrix.triple != 'aarch64-unknown-linux-gnu'
86+
uses: "seanmiddleditch/gha-setup-ninja@v5"
87+
88+
- name: "Setup ninja-build"
89+
if: matrix.triple == 'aarch64-unknown-linux-gnu'
90+
run: |
91+
sudo apt-get update
92+
sudo apt-get install -y ninja-build
93+
94+
- name: "Setup build config"
95+
run: |
96+
cp ./.github/workflows/config.toml ./config.toml
97+
98+
- name: "Setup build env vars"
99+
run: |
100+
echo "CARGO_TARGET_RISCV32IM_SUCCINCT_ZKVM_ELF_RUSTFLAGS=-Cpasses=loweratomic" >> $GITHUB_ENV
101+
102+
- name: "Work around missing target issue"
103+
run: |
104+
mkdir /tmp/rustc-targets
105+
touch /tmp/rustc-targets/riscv32im-succinct-zkvm-elf.json
106+
echo "RUST_TARGET_PATH=/tmp/rustc-targets" >> $GITHUB_ENV
107+
108+
- name: "Build Rust"
109+
run: |
110+
./x.py build --stage 2
111+
112+
- name: "Archive toolchain"
113+
run: |
114+
# Use `rsync` instead of `cp` due to hardlinks
115+
rsync --recursive ./build/${{ matrix.triple }}/stage2-tools-bin/ ./build/${{ matrix.triple }}/stage2/bin/
116+
117+
tar \
118+
--exclude lib/rustlib/src \
119+
--exclude lib/rustlib/rustc-src \
120+
-hczvf \
121+
./rust-toolchain-${{ matrix.triple }}.tar.gz \
122+
-C ./build/${{ matrix.triple }}/stage2/ \
123+
.
124+
125+
- name: "Upload workflow artifact"
126+
uses: "actions/upload-artifact@v3"
127+
with:
128+
name: "rust-toolchain-${{ matrix.triple }}.tar.gz"
129+
path: "./rust-toolchain-${{ matrix.triple }}.tar.gz"
130+
131+
- name: "Upload release artifact"
132+
run: |
133+
ARTIFACT_NAME="rust-toolchain-${{ matrix.triple }}.tar.gz"
134+
135+
curl -L --fail "https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${{ needs.draft-release.outputs.release-id }}/assets?name=${ARTIFACT_NAME}" \
136+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
137+
-H "Content-Type: application/octet-stream" \
138+
--data-binary "@${ARTIFACT_NAME}"
139+
140+
publish-release:
141+
name: "Publish release"
142+
runs-on: "ubuntu-latest"
143+
needs:
144+
- "draft-release"
145+
- "release-unix"
146+
147+
steps:
148+
- name: "Publish release"
149+
run: |
150+
curl -L --fail "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${{ needs.draft-release.outputs.release-id }}" \
151+
-X PATCH \
152+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
153+
-d '{"draft":false}'

0 commit comments

Comments
 (0)