Skip to content

Added to changelog file #1

Added to changelog file

Added to changelog file #1

Workflow file for this run

name: Release
on:
push:
branches:
- 'master'
tags:
- v[0-9]+.*
permissions:
contents: write
jobs:
verify-version:
name: Verify that version that triggered this workflow is greater than most recent release
runs-on: ubuntu-latest
outputs:
versionIsValid: ${{ steps.validVersion.outputs.versionIsValid }}
version: ${{ steps.validVersion.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
cache: 'npm'
cache-dependency-path: scripts/package-lock.json
- run: npm ci
working-directory: scripts
- name: Get version from Cargo.toml
id: lookupVersion
uses: mikefarah/yq@a198f72367ce9da70b564a2cc25399de8e27bf37
with:
cmd: yq -oy '"v" + .workspace.package.version' 'Cargo.toml'
- name: Get version from the latest releases
id: lookupVersionRelease
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: foundry-rs
repo: starknet-foundry
excludes: prerelease, draft
- name: Compare versions
id: validVersion
run: |
RELEASE_VERSION=${{ steps.lookupVersionRelease.outputs.release }}
COMMIT_VERSION=${{ steps.lookupVersion.outputs.result }}
echo "Project version from newest release = $RELEASE_VERSION"
echo "Project version from this commit = $COMMIT_VERSION"
IS_VALID=$(node ./scripts/compareVersions.js $RELEASE_VERSION $COMMIT_VERSION)
echo "versionIsValid=$IS_VALID" >> "$GITHUB_OUTPUT"
echo "version=$COMMIT_VERSION" >> "$GITHUB_OUTPUT"
- name: Output job skipped
if: ${{ steps.validVersion.outputs.versionIsValid == 'false' }}
run: echo "Version from commit is not greater from newest release, skipping build"
build-binaries:
name: Build ${{ matrix.target }}
needs: verify-version
runs-on: ${{ matrix.os }}
continue-on-error: true
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: 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-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@439cf607258077187679211f12aa6f19af4a0af7
with:
toolchain: stable
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@dd05243424bd5c0e585e4b55eb2d7615cdd32f1f
with:
workspaces: starknet-foundry
- 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: Package
shell: bash
run: |
set -euxo pipefail
PKG_FULL_NAME="starknet-foundry-${{ needs.verify-version.outputs.version }}-${{ matrix.target }}"
echo "PKG_FULL_NAME=$PKG_FULL_NAME" >> $GITHUB_ENV
chmod +x ./scripts/package.sh
./scripts/package.sh "${{ matrix.target }}" "$PKG_FULL_NAME"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.target }}
path: ${{ env.PKG_FULL_NAME }}.*
create-release:
name: Create release
runs-on: ubuntu-latest
needs: [ build-binaries, verify-version ]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts-dl
- name: Unpack artifacts to staging directory
run: |
mkdir -p artifacts
mv artifacts-dl/build-*/starknet-foundry-* artifacts/
- name: Create GitHub release
id: create-release
uses: taiki-e/create-gh-release-action@9762dfdfe60a96b3fef6c4a0aaafd9840f1195b7
with:
token: ${{ secrets.GITHUB_TOKEN }}
changelog: CHANGELOG.md
allow-missing-changelog: false
title: $version
ref: refs/tags/${{ needs.verify-version.outputs.version }}
- name: Upload artifacts to the release
working-directory: artifacts
run: gh release upload "$TAG" *
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.create-release.outputs.computed-prefix }}${{ steps.create-release.outputs.version }}