Skip to content

Commit

Permalink
Github Actions for release + cli install script
Browse files Browse the repository at this point in the history
  • Loading branch information
mobycrypt committed Jan 6, 2025
1 parent 958c2ae commit 4087f26
Show file tree
Hide file tree
Showing 26 changed files with 758 additions and 148 deletions.
7 changes: 7 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[alias]
xtask = "run --quiet --package xtask --"

# On Windows MSVC, statically link the C runtime so that the resulting EXE does
# not depend on the vcruntime DLL.
[target.'cfg(windows)']
rustflags = ["-C", "target-feature=+crt-static"]
161 changes: 161 additions & 0 deletions .github/workflows/_build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Release Build

on:
workflow_call:
inputs:
# Must start with 'v'
noir-libs-tag:
required: true
type: string
ref:
required: false
type: string

jobs:
build:
name: build ${{ matrix.target }}
runs-on: ${{ matrix.os }}

env:
# Cross-compiled targets will override this to `cross`.
CARGO: cargo

strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
# Use cross to link oldest GLIBC possible.
cross: true

- target: x86_64-unknown-linux-musl
os: ubuntu-latest
cross: true

#- target: armv7-unknown-linux-gnueabihf
# os: ubuntu-latest
# cross: true

- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true

- target: aarch64-unknown-linux-musl
os: ubuntu-latest
cross: true

- target: x86_64-apple-darwin
os: macos-13

- target: aarch64-apple-darwin
os: macos-14

- target: x86_64-pc-windows-msvc
os: windows-latest

#- target: aarch64-pc-windows-msvc
# os: windows-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}

- name: Install cross
if: matrix.cross
uses: taiki-e/install-action@cross

- name: Enable cross-compilation
if: matrix.cross
shell: bash
run: echo "CARGO=cross" >> $GITHUB_ENV

- name: Build
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}

- name: Create archive
run: cargo xtask create-archive
env:
STAGING: noir-libs-${{ inputs.noir-libs-tag }}-${{ matrix.target }}
TARGET: ${{ matrix.target }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.target }}
path: noir-libs-${{ inputs.noir-libs-tag }}-${{ matrix.target }}.*

verify:
name: verify ${{ matrix.os }} ${{ matrix.target }}
runs-on: ${{ matrix.os }}
needs: build

strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-20.04

- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04

- target: aarch64-apple-darwin
os: macos-14

- target: x86_64-pc-windows-msvc
os: windows-2019

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- uses: dtolnay/rust-toolchain@stable

- name: Build xtasks
run: cargo build -p xtask

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.target }}
path: target/verify

# - name: Verify archive
# shell: bash
# run: |
# archive=$(find target/verify -name 'noir-libs-*.zip' -o -name 'noir-libs-*.tar.gz')
# cargo xtask verify-archive --archive "$archive"
# env:
# EXPECTED_VERSION: ${{ inputs.noir-libs-tag }}

checksums:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts-dl

- name: Unpack artifacts to staging directory
run: |
mkdir -p artifacts
mv artifacts-dl/build-*/noir-libs-* artifacts/
- name: Compute checksums
working-directory: artifacts
run: |
sha256sum -b noir-libs-* > checksums.sha256
cat checksums.sha256
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: checksums
path: artifacts/checksums.*
42 changes: 42 additions & 0 deletions .github/workflows/_check-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release Check

on:
workflow_dispatch:
inputs:
ref:
required: false
type: string
fail-fast:
required: false
type: boolean
default: true
workflow_call:
inputs:
ref:
required: false
type: string
fail-fast:
required: false
type: boolean
default: true

jobs:
test:
name: test ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: ${{ inputs.fail-fast }}
matrix:
include:
- name: linux x86-64
os: ubuntu-latest
- name: macos aarch64
os: macos-14
- name: windows x86-64
os: windows-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --no-fail-fast
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release

on:
push:
tags:
- v[0-9]+.*

permissions:
contents: write

jobs:
check:
uses: ./.github/workflows/_check-release.yml

release:
uses: ./.github/workflows/_build-release.yml
with:
noir-libs-tag: ${{ github.ref_name }}

draft:
name: draft release
runs-on: ubuntu-latest
needs: [ check, release ]
steps:
- uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts-dl

- name: Unpack artifacts to staging directory
run: |
mkdir -p artifacts
mv artifacts-dl/build-*/noir-libs-* artifacts/
mv artifacts-dl/checksums/* artifacts/
ls -lh artifacts/
- name: Draft GitHub release
run: |
gh release create \
'${{ github.ref_name }}' \
./artifacts/* \
--draft \
--title '${{ github.ref_name }}' \
--generate-notes \
--verify-tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 4087f26

Please sign in to comment.