Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: update release process with release-please #549

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/release-please/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"release-type": "simple",
"include-component-in-tag": false,
"group-pull-request-title-pattern": "chore: release ${component} ${version}",
"packages": {
".": {
"component": "anvil-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.2.5"
}
86 changes: 41 additions & 45 deletions .github/workflows/build-push-docker.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,43 @@
name: Build and push Docker image

on:
push:
branches:
- main
tags:
- "*"
antonbaliasnikov marked this conversation as resolved.
Show resolved Hide resolved
workflow_dispatch:
inputs:
ref:
description: 'The zksync-anvil version to generate docker image from. If empty, branch that triggered the workflow is used.'
required: false
default: ''
tag:
description: 'The tag to use for the Docker image. Leave empty to skip pushing the image.'
required: false
default: ''
workflow_call:
inputs:
tag:
type: string
description: 'The tag to use for the Docker image.'
required: true

env:
PLATFORMS: 'linux/amd64,linux/arm64'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
cancel-in-progress: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: do we even need concurrency groups anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess it can be removed in this case.


jobs:
set-tags:
name: Set Docker Tags
runs-on: ubuntu-latest
outputs:
base_tag: ${{ steps.set_tag.outputs.base_tag }}
steps:
- uses: actions/checkout@v4

- name: Set Git SHA
id: git_sha
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Determine Base Tag
id: set_tag
run: |
ts=$(date +%s%N | cut -b1-13)
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "base_tag=${{ steps.git_sha.outputs.sha_short }}-${ts}" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "base_tag=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "base_tag=none" >> $GITHUB_OUTPUT
else
echo "Unsupported event ${GITHUB_EVENT_NAME} or ref ${GITHUB_REF}. Only refs/heads/main, refs/tags/*, and pull_request are supported."
exit 1
fi

build-push-image:
name: Build and Push Docker Image
runs-on: matterlabs-ci-runner-high-performance
needs: set-tags
env:
DOCKERHUB_IMAGE: us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || '' }}

- name: Login to GAR
run: |
gcloud auth configure-docker us-docker.pkg.dev -q
run: gcloud auth configure-docker us-docker.pkg.dev -q

- name: Login to GHCR
uses: docker/login-action@v3
Expand All @@ -63,19 +50,28 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@v6
id: push
with:
context: .
push: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }}
platforms: ${{ env.PLATFORMS }}
push: ${{ inputs.tag != '' }}
platforms: 'linux/amd64,linux/arm64'
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/${{ github.repository_owner }}/anvil-zksync:${{ needs.set-tags.outputs.base_tag }}
us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${{ needs.set-tags.outputs.base_tag }}
ghcr.io/${{ github.repository }}:${{ inputs.tag }}
${{ env.DOCKERHUB_IMAGE }}:${{ inputs.tag }}

- name: Generate docker image attestation
if: ${{ inputs.tag != '' }}
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
antonbaliasnikov marked this conversation as resolved.
Show resolved Hide resolved

- name: Print image digest to summary
if: ${{ inputs.tag != '' }}
run: |
echo "Image tags: ghcr.io/${{ github.repository_owner }}/anvil-zksync:${{ needs.set-tags.outputs.base_tag }}" >> $GITHUB_STEP_SUMMARY
echo "Image tags: us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${{ needs.set-tags.outputs.base_tag }}" >> $GITHUB_STEP_SUMMARY
echo "Image tags: ghcr.io/${{ github.repository }}:${{ inputs.tag }}" >> "${GITHUB_STEP_SUMMARY}"
echo "Image tags: ${{ env.DOCKERHUB_IMAGE }}:${{ inputs.tag }}" >> "${GITHUB_STEP_SUMMARY}"
51 changes: 51 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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 # Disable publishing to crates.io
upgrade-dependencies: false # Do not upgrade workspace dependencies
antonbaliasnikov marked this conversation as resolved.
Show resolved Hide resolved
workspace-dirs: 'e2e-tests-rust' # Additionally update Cargo.lock in e2e-tests-rust workspace

# Trigger workflow to publish binaries
release-binaries:
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

# Trigger workflow to publish docker images
release-docker:
if: ${{ needs.release-please.outputs.releases_created == 'true' }}
needs: release-please
uses: ./.github/workflows/build-push-docker.yml
with:
tag: ${{ needs.release-please.outputs.tag_name }}
secrets: inherit
Loading
Loading