Skip to content

Commit

Permalink
ci: update release process with release-please
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbaliasnikov committed Jan 9, 2025
1 parent e85875e commit e26f093
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 30 deletions.
17 changes: 17 additions & 0 deletions .github/release-please/config.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
}
}
3 changes: 3 additions & 0 deletions .github/release-please/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.0.2"
}
41 changes: 41 additions & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 0 additions & 15 deletions .github/workflows/release-plz.yaml

This file was deleted.

53 changes: 39 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -20,29 +25,33 @@ 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
run: |
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
# This tag is used for this specific nightly version's release
# 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 }}
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}

Expand All @@ -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: |
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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"
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e26f093

Please sign in to comment.