diff --git a/.github/release-please/config.json b/.github/release-please/config.json new file mode 100644 index 000000000..6a237d952 --- /dev/null +++ b/.github/release-please/config.json @@ -0,0 +1,17 @@ +{ + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": true, + "include-component-in-tag": true, + "release-type": "simple", + "packages": { + ".": { + "component": "foundry-zksync", + "extra-files": [ + { + "type": "generic", + "path": "Cargo.toml" + } + ] + } + } +} diff --git a/.github/release-please/manifest.json b/.github/release-please/manifest.json new file mode 100644 index 000000000..40ff6fe0d --- /dev/null +++ b/.github/release-please/manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.2" +} diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml new file mode 100644 index 000000000..4d740a84e --- /dev/null +++ b/.github/workflows/release-please.yaml @@ -0,0 +1,41 @@ +name: Release-please + +# Give permissions to the release-please bot to open and update PRs +# and commit to PRs the repository to update Cargo.lock +permissions: + contents: write + pull-requests: write + id-token: write + attestations: write + +# Run the workflow on push to the main branch and manually +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + + # Prepare the release PR with changelog updates and create github releases + # Do not publish to crates.io or upgrade dependencies + release-please: + uses: matter-labs/zksync-ci-common/.github/workflows/release-please.yaml@v1 + secrets: + slack_webhook: ${{ secrets.SLACK_WEBHOOK }} + gh_token: ${{ secrets.GITHUB_TOKEN }} + with: + config: '.github/release-please/config.json' # Specify the path to the configuration file + manifest: '.github/release-please/manifest.json' # Specify the path to the manifest file + update-cargo-lock: true # Update Cargo.lock file + publish-to-crates-io: false # Enable publishing to crates.io + upgrade-dependencies: false # Upgrade workspace dependencies + + # Trigger workflow to generate artifacts + release: + if: ${{ needs.release-please.outputs.releases_created == 'true' }} + needs: release-please + uses: ./.github/workflows/release.yml + with: + tag: ${{ needs.release-please.outputs.tag_name }} + secrets: inherit diff --git a/.github/workflows/release-plz.yaml b/.github/workflows/release-plz.yaml deleted file mode 100644 index 37be0f63e..000000000 --- a/.github/workflows/release-plz.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: Release-plz - -on: - push: - branches: - - main - -jobs: - - release: - uses: matter-labs/zksync-ci-common/.github/workflows/release-plz.yaml@v1 - secrets: - gh_token: ${{ secrets.RELEASE_TOKEN }} - cargo_registry_token: ${{ secrets.CRATES_IO_TOKEN }} - slack_webhook: ${{ secrets.SLACK_WEBHOOK_RELEASES }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61dd989fd..9d7d59f25 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,16 +1,21 @@ -name: release +name: Release on: - push: - tags: - - "*-zksync.*" schedule: - cron: "0 0 * * *" workflow_dispatch: + # Workflow call trigger for stable releases generation + workflow_call: + inputs: + tag: + description: "Tag to use for the release." + type: string + required: true + default: "" env: CARGO_TERM_COLOR: always - IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} + IS_NIGHTLY: ${{ github.event_name == 'schedule' || inputs.tag == '' }} jobs: prepare: @@ -20,11 +25,13 @@ jobs: outputs: tag_name: ${{ steps.release_info.outputs.tag_name }} release_name: ${{ steps.release_info.outputs.release_name }} - changelog: ${{ steps.build_changelog.outputs.changelog }} + prerelease: ${{ steps.release_info.outputs.prerelease }} + changelog: ${{ steps.build_changelog.outputs.changelog || '' }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ inputs.tag || '' }} - name: Compute release name and tag id: release_info @@ -32,9 +39,11 @@ jobs: if [[ $IS_NIGHTLY ]]; then echo "tag_name=nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT echo "release_name=foundry-zksync Nightly ($(date '+%Y-%m-%d'))" >> $GITHUB_OUTPUT + echo "prerelease=true" >> $GITHUB_OUTPUT else echo "tag_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT echo "release_name=foundry-zksync@${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT + echo "prerelease=false" >> $GITHUB_OUTPUT fi # Creates a `nightly-SHA` tag for this specific nightly @@ -42,7 +51,7 @@ jobs: # which allows users to roll back. It is also used to build # the changelog. - name: Create build-specific nightly tag - if: ${{ env.IS_NIGHTLY }} + if: ${{ env.IS_NIGHTLY == 'true' }} uses: actions/github-script@v7 env: TAG_NAME: ${{ steps.release_info.outputs.tag_name }} @@ -52,11 +61,12 @@ jobs: await createTag({ github, context }, process.env.TAG_NAME) - name: Build changelog + if: ${{ env.IS_NIGHTLY == 'true' }} id: build_changelog uses: mikepenz/release-changelog-builder-action@v4 with: configuration: "./.github/changelog.json" - fromTag: ${{ env.IS_NIGHTLY && 'nightly' || '' }} + fromTag: 'nightly' toTag: ${{ steps.release_info.outputs.tag_name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -102,9 +112,13 @@ jobs: arch: arm64 steps: - uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag || '' }} + - uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} + - name: Install required Rust targets run: rustup target add ${{ matrix.target }} @@ -120,6 +134,7 @@ jobs: echo "PATH=/usr/local/opt/make/libexec/gnubin:$PATH" >> $GITHUB_ENV echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV + - name: Apple Darwin if: matrix.target == 'x86_64-apple-darwin' run: | @@ -186,7 +201,7 @@ jobs: env: PLATFORM_NAME: ${{ matrix.platform }} TARGET: ${{ matrix.target }} - VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }} + VERSION_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }} shell: bash run: | sudo apt-get -y install help2man @@ -199,16 +214,26 @@ jobs: # Creates the release for this specific version - name: Create release - uses: softprops/action-gh-release@v1 + if: ${{ inputs.tag == '' }} + uses: softprops/action-gh-release@v2 with: name: ${{ needs.prepare.outputs.release_name }} tag_name: ${{ needs.prepare.outputs.tag_name }} - prerelease: true + prerelease: ${{ needs.prepare.outputs.prerelease }} body: ${{ needs.prepare.outputs.changelog }} files: | ${{ steps.artifacts.outputs.file_name }} ${{ steps.man.outputs.foundry_man }} + - name: Update release-please release artifacts + if: ${{ inputs.tag != '' }} + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ inputs.tag }} + files: | + ${{ steps.artifacts.outputs.file_name }} + ${{ steps.man.outputs.foundry_man }} + - name: Binaries attestation uses: actions/attest-build-provenance@v2 with: @@ -219,8 +244,8 @@ jobs: # If this is a nightly release, it also updates the release # tagged `nightly` for compatibility with `foundryup` - name: Update nightly release - if: ${{ env.IS_NIGHTLY }} - uses: softprops/action-gh-release@v1 + if: ${{ env.IS_NIGHTLY == 'true' }} + uses: softprops/action-gh-release@v2 with: name: "Nightly foundry-zksync" tag_name: "nightly" @@ -229,7 +254,7 @@ jobs: files: | ${{ steps.artifacts.outputs.file_name }} ${{ steps.man.outputs.foundry_man }} - + retry-on-failure: if: failure() && fromJSON(github.run_attempt) < 3 needs: [release] @@ -251,7 +276,7 @@ jobs: # Moves the `nightly` tag to `HEAD` - name: Move nightly tag - if: ${{ env.IS_NIGHTLY }} + if: ${{ env.IS_NIGHTLY == 'true' }} uses: actions/github-script@v7 with: script: | diff --git a/Cargo.toml b/Cargo.toml index 3dceea7bc..405f855af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.0.2" +version = "0.0.2" # x-release-please-version edition = "2021" # Remember to update clippy.toml as well rust-version = "1.83" diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 000000000..a3ad58998 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,39 @@ +# Release Process + +This document outlines the automated release process for `foundry-zksync` project. +The release process ensures that every change is systematically analyzed, documented, and packaged for distribution. + +## Release Process Overview + +1. **Triggering the Release Workflow** + - Every merge to the `main` branch activates a special workflow. + - This workflow uses the [`release-please` tool](https://github.com/googleapis/release-please) to analyze the commits. + +2. **Commit Analysis and Release Candidate Creation** + - The `release-please` tool scans for new conventional commits that meet the criteria for triggering a release. + - If qualifying commits are found, the tool automatically creates a **Release Pull Request (PR)**. This PR includes: + - An updated changelog detailing the new changes. + - Updated `Cargo.toml` and `Cargo.lock` files with the next release version. + +3. **Review and Approval** + - The Release PR must be reviewed and approved by the designated Release Manager. + - Once approved, the PR is merged when the release is planned. + +4. **Creating a New Release** + - Upon merging the Release PR: + - The workflow automatically creates a new GitHub tag and release corresponding to the new version. + - The Release PR is marked as "released" and linked to the newly created release. + - Merged PRs included in the release are also labeled with `released in version...`. + +5. **Generating and Publishing Artifacts** + - The `release-please` workflow also triggers the `release.yaml` workflow. + - This workflow generates binary artifacts for the release and attaches them to the GitHub release generated by `release-please`. + +6. **Release Completion** + - With the binary artifacts added, the release is complete and available for distribution. + +## Release Versioning + +The `foundry-zksync` project follows [Semantic Versioning](https://semver.org/). + +Tags are created in the format `foundry-zksync-vX.Y.Z`.