Skip to content

release

release #350

Workflow file for this run

# Reference: https://github.com/foundry-rs/foundry/blob/master/.github/workflows/release.yml
name: release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
prerelease:
description: 'Mark as pre-release'
type: boolean
default: false
target_branch:
description: 'Target branch (leave empty for current branch)'
type: string
default: ''
dry_run:
description: 'Dry run - creates a draft release, tests everything, then deletes it'
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
jobs:
prepare:
name: Prepare release
runs-on: [runs-on, runner=8cpu-linux-x64, "run-id=${{ github.run_id }}"]
timeout-minutes: 30
outputs:
tag_name: ${{ steps.release_info.outputs.tag_name }}
release_name: ${{ steps.release_info.outputs.release_name }}
changelog: ${{ steps.build_changelog.outputs.changelog }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup CI
uses: ./.github/actions/setup
with:
pull_token: ${{ secrets.PULL_TOKEN }}
- name: Compute release name and tag
id: release_info
run: |
# Parse the version from the `Cargo.toml` file.
VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "sp1-primitives") | .version')
TAG_NAME="v${VERSION}"
# Append suffix for dry runs to avoid tag collisions with existing releases
if [ "${{ inputs.dry_run }}" == "true" ]; then
TAG_NAME="${TAG_NAME}-dry-run-${{ github.run_id }}"
fi
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
echo "release_name=${TAG_NAME}" >> $GITHUB_OUTPUT
# - name: Build changelog
# uses: mikepenz/release-changelog-builder-action@v4
# id: build_changelog
# with:
# outputFile: ${{ steps.release_info.outputs.tag_name }}-changelog.md
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
id: create_release
env:
GH_TOKEN: ${{ secrets.SP1_RELEASE_TOKEN }}
run: |
TARGET_BRANCH="${{ inputs.target_branch || github.ref_name }}"
PRERELEASE_FLAG=${{ inputs.prerelease && '"--prerelease"' || '""' }}
DRAFT_FLAG=${{ inputs.dry_run && '"--draft"' || '""' }}
GH_DEBUG=api gh release create ${{ steps.release_info.outputs.tag_name }} --target "$TARGET_BRANCH" --generate-notes --latest=false $PRERELEASE_FLAG $DRAFT_FLAG
- name: Print GH version
run: |
gh version
cargo-prove-release:
name: ${{ matrix.target }} (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 240
needs: prepare
strategy:
fail-fast: false
matrix:
include:
# `runner`: GHA runner label
# `target`: Rust build target triple
# `platform` and `arch`: Used in tarball names
# `svm`: target platform to use for the Solc binary: https://github.com/roynalnaruto/svm-rs/blob/84cbe0ac705becabdc13168bae28a45ad2299749/svm-builds/build.rs#L4-L24
- runner: ubuntu-latest
target: x86_64-unknown-linux-musl
svm_target_platform: linux-amd64
platform: linux
arch: amd64
# - runner: ubuntu-24.04-arm todo fix
# target: aarch64-unknown-linux-musl
# svm_target_platform: linux-aarch64
# platform: linux
# arch: arm64
- runner: macos-latest-large
target: x86_64-apple-darwin
svm_target_platform: macosx-amd64
platform: darwin
arch: amd64
- runner: macos-latest-xlarge
target: aarch64-apple-darwin
svm_target_platform: macosx-aarch64
platform: darwin
arch: arm64
# - runner: windows-latest
# target: x86_64-pc-windows-msvc
# svm_target_platform: windows-amd64
# platform: win32
# arch: amd64
steps:
- uses: actions/checkout@v6
# Install rust and go
- name: Install rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
rustup install stable
- name: Install go
uses: actions/setup-go@v5
with:
go-version: "^1.22.1"
- name: Check go installation
run: |
go version
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "29.4"
- name: Set up git private repo access
run: |
git config --global url."https://${{ secrets.PRIVATE_PULL_TOKEN }}@github.com/".insteadOf ssh://[email protected]
git config --global url."https://${{ secrets.PRIVATE_PULL_TOKEN }}@github.com".insteadOf https://github.com
- name: Apple M1 setup
if: matrix.target == 'aarch64-apple-darwin'
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Musl setup (x86_64)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update -y
sudo apt-get install -y clang musl-tools musl-dev libssl-dev
# g++ supports musl
sudo ln -s /usr/bin/g++ /usr/bin/musl-g++
rustup target add ${{ matrix.target }}
- name: Musl setup (aarch64)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
sudo apt-get update -y
sudo apt-get install -y clang musl-tools musl-dev gcc-aarch64-linux-gnu
# g++ supports musl
sudo ln -s /usr/bin/g++ /usr/bin/musl-g++
# cc-rs uses the wrong defaults for this target so we override them.
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
rustup target add ${{ matrix.target }}
- name: Build binaries
env:
SVM_TARGET_PLATFORM: ${{ matrix.svm_target_platform }}
shell: bash
run: |
set -eo pipefail
target="${{ matrix.target }}"
flags=()
[[ "$target" == *windows* ]] && exe=".exe"
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release -p sp1-cli --target "$target" "${flags[@]}"
bins=(cargo-prove)
for name in "${bins[@]}"; do
bin=./target/$target/release/$name$exe
file "$bin" || true
ldd "$bin" || true
$bin --version || true
done
- name: Archive binaries
id: artifacts
env:
PLATFORM_NAME: ${{ matrix.platform }}
TARGET: ${{ matrix.target }}
ARCH: ${{ matrix.arch }}
# NOTE: SP1UP Relies on the version name being the tag name,
# DO NOT CHANGE THIS WITHOUT UPDATING SP1UP TOO.
VERSION_NAME: ${{ needs.prepare.outputs.tag_name }}
shell: bash
run: |
if [ "$PLATFORM_NAME" == "linux" ]; then
tar -czvf "cargo_prove_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release cargo-prove
echo "file_name=cargo_prove_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT
elif [ "$PLATFORM_NAME" == "darwin" ]; then
# We need to use gtar here otherwise the archive is corrupt.
# See: https://github.com/actions/virtual-environments/issues/2619
gtar -czvf "cargo_prove_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release cargo-prove
echo "file_name=cargo_prove_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT
else
cd ./target/${TARGET}/release
7z a -tzip "cargo_prove_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" cargo-prove.exe
mv "cargo_prove_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" ../../../
echo "file_name=cargo_prove_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" >> $GITHUB_OUTPUT
fi
# Upload the artifacts to the release.
- name: Upload Release artifact
id: upload_release_artifact
env:
GH_TOKEN: ${{ secrets.SP1_RELEASE_TOKEN }}
run: |
gh release upload ${{ needs.prepare.outputs.tag_name }} ${{ steps.artifacts.outputs.file_name }}
sp1-gpu-server-release:
name: (${{ matrix.platform }}-${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 240
needs: prepare
strategy:
fail-fast: false
matrix:
include:
- runner: [runs-on, runner=64cpu-linux-x64, disk=large]
platform: linux
arch: x86_64
steps:
# Note: We need to checkout the repo in order to upload artifacts to the release.
- uses: actions/checkout@v6
with:
ref: ${{ github.ref }}
- name: Print ref
run: |
echo "ref: ${{ github.ref }}"
# Install rust and go
- name: Install rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
rustup install stable
- name: Install CUDA
uses: Jimver/[email protected]
id: cuda-toolkit
with:
cuda: '12.8.1'
use-github-cache: false
use-local-cache: false
sub-packages: '["nvcc", "nvtx", "cudart"]'
method: 'network'
log-file-suffix: "${{ matrix.platform }}-${{ matrix.arch }}.txt"
- name: Install go
uses: actions/setup-go@v5
with:
go-version: "^1.22.1"
- name: Check go installation
run: |
go version
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "29.4"
- name: print nvcc version
run: |
nvcc --version
- name: Build binaries
shell: bash
run: |
set -eo pipefail
cargo build --release --bin sp1-gpu-server
- name: Prepare artifacts
id: artifacts
env:
PLATFORM_NAME: ${{ matrix.platform }}
ARCH: ${{ matrix.arch }}
# NOTE: SP1UP Relies on the version name being the tag name,
# DO NOT CHANGE THIS WITHOUT UPDATING SP1UP TOO.
VERSION_NAME: ${{ needs.prepare.outputs.tag_name }}
shell: bash
run: |
tar -czvf "sp1_gpu_server_${VERSION_NAME}_${ARCH}.tar.gz" -C ./target/release sp1-gpu-server
echo "file_name=sp1_gpu_server_${VERSION_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT
# Upload the artifacts to the release.
- name: Upload Release artifact
id: upload_release_artifact
env:
GH_TOKEN: ${{ secrets.SP1_RELEASE_TOKEN }}
run: |
gh release upload ${{ needs.prepare.outputs.tag_name }} ${{ steps.artifacts.outputs.file_name }}
set-latest-release:
name: Set latest release
runs-on: ubuntu-latest
needs: [sp1-gpu-server-release, cargo-prove-release, prepare]
if: ${{ success() && inputs.prerelease != true && inputs.dry_run != true }}
steps:
- uses: actions/checkout@v6
- name: Set latest release
env:
GH_TOKEN: ${{ secrets.SP1_RELEASE_TOKEN }}
run: |
# Wait until all the binaries have been built to set the latest release.
gh release edit ${{ needs.prepare.outputs.tag_name }} --latest
toolchain-test:
name: "Test toolchain installation (${{ matrix.name }})"
needs: [sp1-gpu-server-release, cargo-prove-release, prepare]
strategy:
fail-fast: false
matrix:
include:
- name: "Ubuntu 24.04 (x86_64)"
runner: "ubuntu-24.04"
- name: "Ubuntu 24.04 (ARM64)"
runner: "ubuntu-24.04-arm"
- name: "macOS Sequoia (x86_64)"
runner: "macos-15-intel"
- name: "macOS Sonoma (ARM64)"
runner: "macos-14"
runs-on: "${{ matrix.runner }}"
steps:
- name: "Checkout source code"
uses: "actions/checkout@v6"
- name: "Install SP1"
run: |
cd sp1up
chmod +x sp1up
bash -x sp1up --token ${{ secrets.GITHUB_TOKEN }}
- name: "Create SP1 project from template"
run: |
$HOME/.sp1/bin/cargo-prove prove new --bare hello
- name: "Build SP1 project"
run: |
cd ./hello/program
$HOME/.sp1/bin/cargo-prove prove build
# If any of the jobs fail, this will create a high-priority issue to signal so.
issue:
name: Open an issue
runs-on: ubuntu-latest
needs: [sp1-gpu-server-release, cargo-prove-release, prepare]
if: ${{ failure() && inputs.dry_run != true }}
steps:
- uses: actions/checkout@v6
# todo remove this and use GH cli to create the issue
- uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_URL: |
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
update_existing: true
filename: .github/RELEASE_FAILURE_ISSUE_TEMPLATE.md
# If any of the jobs fail, this will create a high-priority issue to signal so.
delete-failed-release:
name: Delete failed release
runs-on: ubuntu-latest
needs: [sp1-gpu-server-release, cargo-prove-release, prepare]
if: failure()
steps:
- uses: actions/checkout@v6
- name: Delete failed release
env:
GH_TOKEN: ${{ secrets.SP1_RELEASE_TOKEN }}
run: |
gh release delete ${{ needs.prepare.outputs.tag_name }} --cleanup-tag
# Clean up the draft release at the end of a dry run
dry-run-cleanup:
name: Delete dry run release
runs-on: ubuntu-latest
needs: [toolchain-test, prepare]
if: ${{ always() && inputs.dry_run == true }}
steps:
- uses: actions/checkout@v6
- name: Delete draft release
env:
GH_TOKEN: ${{ secrets.SP1_RELEASE_TOKEN }}
run: |
gh release delete ${{ needs.prepare.outputs.tag_name }} --cleanup-tag --yes || true