Skip to content

Add gas report logic (#3841) #1370

Add gas report logic (#3841)

Add gas report logic (#3841) #1370

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@v5
- uses: actions/setup-node@v5
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@8bf425b4d1344db7cd469a8d10a390876e0c77fd
with:
cmd: yq -oy '.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 binaries
needs: verify-version
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
uses: ./.github/workflows/_build-binaries.yml
secrets: inherit
with:
version: ${{ needs.verify-version.outputs.version }}
build-plugin-binaries:
name: Build plugin binaries
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
needs: verify-version
uses: ./.github/workflows/_build-plugin-binaries.yml
with:
plugin_name: "snforge-scarb-plugin"
build-deprecated-plugin-binaries:
name: Build deprecated plugin binaries
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
needs: verify-version
uses: ./.github/workflows/_build-plugin-binaries.yml
with:
plugin_name: "snforge-scarb-plugin-deprecated"
dev-publish-plugin:
needs: [verify-version, build-plugin-binaries]
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
uses: ./.github/workflows/_publish-plugin.yml
secrets: inherit
with:
overridden_plugin_version: ${{ needs.verify-version.outputs.version }}-test.${{ github.run_id }}
plugin_name: "snforge-scarb-plugin"
dev-publish-deprecated-plugin:
needs: [ verify-version, build-deprecated-plugin-binaries ]
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
uses: ./.github/workflows/_publish-plugin.yml
secrets: inherit
with:
overridden_plugin_version: ${{ needs.verify-version.outputs.version }}-test.${{ github.run_id }}
plugin_name: "snforge-scarb-plugin-deprecated"
dev-publish-std:
needs: [verify-version, dev-publish-plugin, dev-publish-deprecated-plugin]
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
uses: ./.github/workflows/publish-std.yml
secrets: inherit
with:
plugin_dep_version: ${{ needs.verify-version.outputs.version }}-test.${{ github.run_id }}
override_std_version: ${{ needs.verify-version.outputs.version }}-test.${{ github.run_id }}
test-binary:
name: Test binary
needs: [build-binaries, verify-version, dev-publish-std, dev-publish-plugin, dev-publish-deprecated-plugin]
uses: ./.github/workflows/_test-binaries.yml
secrets: inherit
with:
bin_version: ${{ needs.verify-version.outputs.version }}
std_version: ${{ needs.verify-version.outputs.version }}-test.${{ github.run_id }}
create-release:
name: Create release
runs-on: ubuntu-latest
needs: [ test-binary, verify-version ]
steps:
- uses: actions/checkout@v5
- 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-*/starknet-foundry-* artifacts/
- name: Create GitHub release
id: create-release
uses: taiki-e/create-gh-release-action@26b80501670402f1999aff4b934e1574ef2d3705
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: true
changelog: CHANGELOG.md
allow-missing-changelog: false
title: $version
ref: refs/tags/v${{ 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 }}
publish-snforge-scarb-plugin:
name: Publish snforge_scarb_plugin
needs: [test-binary, create-release]
uses: ./.github/workflows/_publish-plugin.yml
secrets: inherit
with:
prod_registry: true
plugin_name: "snforge-scarb-plugin"
publish-snforge-scarb-plugin-deprecated:
name: Publish snforge_scarb_plugin_deprecated
needs: [ test-binary, create-release ]
uses: ./.github/workflows/_publish-plugin.yml
secrets: inherit
with:
prod_registry: true
plugin_name: "snforge-scarb-plugin-deprecated"
publish-to-registry:
name: Publish packages to the registry
needs: [ verify-version, publish-snforge-scarb-plugin, publish-snforge-scarb-plugin-deprecated ]
uses: ./.github/workflows/publish-std.yml
secrets: inherit
with:
plugin_dep_version: ${{ needs.verify-version.outputs.version }}
prod_registry: true