Implement simple inlining optimizer (#4167) #1532
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | |
| # Steps `verifyBranchVersion` and `verifyTagVersion` are mutually exclusive, only one of them will run | |
| versionIsValid: ${{ steps.verifyBranchVersion.outputs.versionIsValid }}${{ steps.verifyTagVersion.outputs.versionIsValid }} | |
| version: ${{ steps.verifyBranchVersion.outputs.version }}${{ steps.verifyTagVersion.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| 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@7ccaf8e700ce99eb3f0f6cef7f5930a0b3c827cd | |
| 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: draft | |
| - name: Verify branch version | |
| id: verifyBranchVersion | |
| if: github.ref_type == 'branch' | |
| 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" | |
| if gh release view "v$COMMIT_VERSION" >/dev/null 2>&1; then | |
| echo "Release v$COMMIT_VERSION already exists - aborting" | |
| echo "versionIsValid=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| IS_GREATER=$(node ./scripts/compareVersions.js $RELEASE_VERSION $COMMIT_VERSION) | |
| echo "versionIsValid=$IS_GREATER" >> "$GITHUB_OUTPUT" | |
| echo "version=$COMMIT_VERSION" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Verify tag version | |
| id: verifyTagVersion | |
| if: github.ref_type == 'tag' | |
| run: | | |
| TAG_NAME="$GITHUB_REF_NAME" | |
| TAG_VERSION="${TAG_NAME#v}" | |
| CARGO_VERSION="${{ steps.lookupVersion.outputs.result }}" | |
| echo "Tag version = $TAG_VERSION" | |
| echo "Project version from Cargo.toml = $CARGO_VERSION" | |
| if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then | |
| echo "Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)" | |
| exit 1 | |
| fi | |
| # Tag is usually created when publishing release from GitHub UI. | |
| # Then it triggers this workflow again and we want to exit without error. | |
| if gh release view "$TAG_NAME" >/dev/null 2>&1; then | |
| echo "Release $TAG_NAME already exists - aborting" | |
| echo "versionIsValid=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "versionIsValid=true" >> "$GITHUB_OUTPUT" | |
| echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-binaries: | |
| name: Build binaries | |
| needs: verify-version | |
| if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }} | |
| uses: ./.github/workflows/_build-binaries.yml | |
| 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" | |
| 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: | |
| prod_registry: false | |
| overridden_plugin_version: ${{ needs.verify-version.outputs.version }}-test.${{ github.run_id }} | |
| plugin_name: "snforge-scarb-plugin" | |
| dev-publish-std: | |
| needs: [verify-version, dev-publish-plugin] | |
| if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }} | |
| uses: ./.github/workflows/publish-std.yml | |
| secrets: inherit | |
| with: | |
| prod_registry: false | |
| 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] | |
| 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@v6 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v6 | |
| 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-to-registry: | |
| name: Publish packages to the registry | |
| needs: [ verify-version, publish-snforge-scarb-plugin ] | |
| uses: ./.github/workflows/publish-std.yml | |
| secrets: inherit | |
| with: | |
| plugin_dep_version: ${{ needs.verify-version.outputs.version }} | |
| prod_registry: true |