From b06bec6e397c1c9ef9c1c7780d4e1bd9571191f3 Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Tue, 7 Jan 2025 15:07:54 +0000 Subject: [PATCH] ci: update release process with release-please --- .github/release-please/config.json | 17 +++++++++ .github/release-please/manifest.json | 3 ++ .github/workflows/release-please.yaml | 41 +++++++++++++++++++++ .github/workflows/release-plz.yaml | 15 -------- .github/workflows/release.yml | 53 ++++++++++++++++++++------- Cargo.toml | 2 +- 6 files changed, 101 insertions(+), 30 deletions(-) create mode 100644 .github/release-please/config.json create mode 100644 .github/release-please/manifest.json create mode 100644 .github/workflows/release-please.yaml delete mode 100644 .github/workflows/release-plz.yaml 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..3100d6b78 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] diff --git a/Cargo.toml b/Cargo.toml index 7893a22fe..8ef86267f 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"