Skip to content

Merge pull request #29 from ProvableHQ/bump/v0.2.2 #6

Merge pull request #29 from ProvableHQ/bump/v0.2.2

Merge pull request #29 from ProvableHQ/bump/v0.2.2 #6

Workflow file for this run

name: Release
on:
push:
tags: ['v[0-9]*']
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g. v0.2.0). Creates the git tag if it does not already exist."
required: true
env:
RUST_BACKTRACE: 0
jobs:
prepare:
name: Prepare Release
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ steps.resolve.outputs.tag }}
version: ${{ steps.resolve.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve Tag and Version
id: resolve
run: |
TAG="${{ github.event.inputs.tag || github.ref_name }}"
VERSION="${TAG#v}"
TOML_VERSION="$(grep '^version' Cargo.toml | head -1 | sed 's/.*= *"\(.*\)"/\1/')"
if [ "$VERSION" != "$TOML_VERSION" ]; then
echo "::error::Tag version ($VERSION) does not match Cargo.toml version ($TOML_VERSION)"
exit 1
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Ensure Tag Exists
run: |
TAG="${{ steps.resolve.outputs.tag }}"
if git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists"
else
git tag "$TAG"
git push origin "$TAG"
fi
build:
name: Build (${{ matrix.target }})
needs: prepare
strategy:
fail-fast: true
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
- target: x86_64-apple-darwin
os: macos-14-large
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.tag }}
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Add aarch64 target
if: matrix.target == 'aarch64-apple-darwin'
run: rustup target add aarch64-apple-darwin
- uses: Swatinem/rust-cache@v2
- name: Install libclang (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update -qq && sudo apt-get install -y libclang-dev
- name: Set LIBCLANG_PATH (macOS)
if: runner.os == 'macOS'
run: |
echo "LIBCLANG_PATH=/Library/Developer/CommandLineTools/usr/lib" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=/Library/Developer/CommandLineTools/usr/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Install LLVM (Windows)
if: runner.os == 'Windows'
uses: KyleMayes/install-llvm-action@v1
with:
version: "11"
directory: ${{ runner.temp }}/llvm
- name: Set LIBCLANG_PATH (Windows)
if: runner.os == 'Windows'
run: echo "LIBCLANG_PATH=${{ runner.temp }}/llvm/lib" >> $GITHUB_ENV
- name: Verify Cargo.lock exists
shell: bash
run: test -f Cargo.lock || (echo "::error::Cargo.lock is missing" && exit 1)
- name: Build
shell: bash
run: |
TARGET_FLAG=""
if [ "${{ matrix.target }}" = "aarch64-apple-darwin" ]; then
TARGET_FLAG="--target aarch64-apple-darwin"
fi
cargo build --release --locked $TARGET_FLAG
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
- name: Package (Unix)
if: runner.os != 'Windows'
run: |
TAG="${{ needs.prepare.outputs.tag }}"
if [ "${{ matrix.target }}" = "aarch64-apple-darwin" ]; then
BIN="target/aarch64-apple-darwin/release/aleo-devnode"
else
BIN="target/release/aleo-devnode"
fi
strip "$BIN"
ARCHIVE="aleo-devnode-${TAG}-${{ matrix.target }}.zip"
zip -j "$ARCHIVE" "$BIN"
echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV"
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$tag = "${{ needs.prepare.outputs.tag }}"
$archive = "aleo-devnode-${tag}-${{ matrix.target }}.zip"
Compress-Archive -Path target/release/aleo-devnode.exe -DestinationPath $archive
echo "ARCHIVE=$archive" >> $env:GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.target }}
path: ${{ env.ARCHIVE }}
release:
name: Publish Release
needs: [prepare, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: release-*
merge-multiple: true
- name: Generate Checksums
run: sha256sum *.zip > sha256sums.txt
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare.outputs.tag }}
name: "v${{ needs.prepare.outputs.version }}"
files: |
*.zip
sha256sums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm:
name: Publish to npm
needs: [prepare, release]
runs-on: ubuntu-latest
permissions:
actions: write
steps:
# All npm publishing lives in npm-publish.yml so npm's trusted publisher
# config can point at a single workflow file. It publishes from the
# release assets, so it must run after the GitHub release exists.
# `gh workflow run` is fire-and-forget and does not report the run it
# created, so this run's id is embedded in the dispatched run's name
# ("dispatch <id>") and polled for, then the run is watched to
# completion — a failed npm publish must fail this job (and the
# release run) too.
- name: Run npm publish workflow
run: |
# npm publishing is for stable releases only; npm-publish.yml
# rejects other tags, so don't dispatch it for them. Prerelease
# tags still get a GitHub release, just no npm packages.
if ! printf '%s' "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Tag '$TAG' is not a stable vX.Y.Z release tag; skipping npm publish."
exit 0
fi
# Backdated a minute so clock skew between this runner and GitHub's
# createdAt cannot hide the run from the --created filter below.
DISPATCHED_AT="$(date -u -d '1 minute ago' +%Y-%m-%dT%H:%M:%SZ)"
gh workflow run npm-publish.yml -f tag="$TAG" -f dispatch_id="$GITHUB_RUN_ID" -R "$REPO"
RUN_ID=""
for _ in $(seq 1 24); do
sleep 5
RUN_ID="$(gh run list -R "$REPO" --workflow=npm-publish.yml \
--event=workflow_dispatch --created ">=$DISPATCHED_AT" \
--json databaseId,displayTitle \
--jq "[.[] | select(.displayTitle | contains(\"dispatch ${GITHUB_RUN_ID})\"))][0].databaseId // empty")"
[ -n "$RUN_ID" ] && break
done
if [ -z "$RUN_ID" ]; then
echo "::error::Dispatched npm-publish.yml but could not find the run it created"
exit 1
fi
gh run watch "$RUN_ID" -R "$REPO" --exit-status
env:
GH_TOKEN: ${{ github.token }}
# Passed via env, not ${{ }} interpolation into the script: tag
# names may contain shell metacharacters.
TAG: ${{ needs.prepare.outputs.tag }}
REPO: ${{ github.repository }}