From 659a5ac5ccbeb17ab242473d2162676c4be83d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez?= <35505302+alvarof2@users.noreply.github.com> Date: Thu, 30 Jan 2025 16:16:14 +0100 Subject: [PATCH] Tentative op-geth Release workflows for CELO (#314) * Test Release GH Actions * Docker Image * Crane Publish Docker Image For Release * Build-Container-Release * Blank * Branches to trigger and tag --- .github/release-drafter.yml | 12 ++++ .github/workflows/docker-publish-release.yaml | 30 ++++++++ .github/workflows/first-release.yaml | 62 +++++++++++++++++ .github/workflows/release-drafter.yml | 69 +++++++++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/docker-publish-release.yaml create mode 100644 .github/workflows/first-release.yaml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000000..8b837e0522 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,12 @@ +#tag-template: '${{ env.BRANCH_NAME }}-v$RESOLVED_VERSION' +name-template: 'Celo op-geth v$RESOLVED_VERSION' +filter-by-commitish: true +version-resolver: + default: patch +template: | + ## What’s Changed + + $CHANGES + + --- + **Docker Image:** https://us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:$RESOLVED_VERSION. diff --git a/.github/workflows/docker-publish-release.yaml b/.github/workflows/docker-publish-release.yaml new file mode 100644 index 0000000000..ad9a641a28 --- /dev/null +++ b/.github/workflows/docker-publish-release.yaml @@ -0,0 +1,30 @@ +name: "[cLabs] Publish Docker Image For Release" + +on: + workflow_dispatch: + release: + types: [published] # Trigger the workflow only when a release is published + +jobs: + get-release-commit: + runs-on: ubuntu-latest + + Build-Container-Release: + permissions: + contents: write + actions: read + pull-requests: write + security-events: write + attestations: write + id-token: write + concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + uses: celo-org/reusable-workflows/.github/workflows/docker-build.yaml@v3.0.0-alpha + with: + workload-id-provider: projects/1094498259535/locations/global/workloadIdentityPools/gh-op-geth-release/providers/github-by-repos + service-account: op-geth-release@blockchaintestsglobaltestnet.iam.gserviceaccount.com + artifact-registry: us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth + tags: ${{ github.event.release.tag_name }} + context: . + debug_enabled: false diff --git a/.github/workflows/first-release.yaml b/.github/workflows/first-release.yaml new file mode 100644 index 0000000000..aa9e23689a --- /dev/null +++ b/.github/workflows/first-release.yaml @@ -0,0 +1,62 @@ +name: "[cLabs] Create First Draft Release For A Branch" + +on: + workflow_dispatch: + inputs: + release_tag: + description: 'The tag for the release (e.g., v1.0.0)' + required: true + forked_from: + description: 'The op-geth version this release is forked from (e.g., v1.0.0)' + required: true + +jobs: + + check-release: + runs-on: ubuntu-latest + outputs: + release_exists: ${{ steps.check_release.outputs.release_exists }} + steps: + # Query the GitHub API to check for a release + - name: Check if release exists + id: check_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + RELEASES=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/${{ github.repository }}/releases") + + BRANCH="${{ github.ref }}" # Current branch + if echo "$RELEASES" | jq -e ".[] | select(.target_commitish == \"$BRANCH\")" > /dev/null; then + echo "Release exists for branch $BRANCH." + echo "release_exists=true" >> $GITHUB_OUTPUT + else + echo "No release found for branch $BRANCH." + echo "release_exists=false" >> $GITHUB_OUTPUT + fi + + create-release: + runs-on: ubuntu-latest + needs: check-release + if: needs.check-release.outputs.release_exists == 'false' + steps: + # Checkout the repository + - name: Checkout code + uses: actions/checkout@v3 + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.event.inputs.release_tag }} + release_name: Celo op-geth ${{ github.event.inputs.release_tag }} + commitish: ${{ github.ref }} + body: | + Celo op-geth ${{ github.event.inputs.release_tag }} is forked from [ethereum-optimism/op-geth](https://github.com/ethereum-optimism/op-geth) ${{ github.event.inputs.forked_from }}. + + **Docker Image:** https://us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:${{ github.event.inputs.release_tag }}. + draft: true + prerelease: false diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000000..e4a28123eb --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,69 @@ +name: "[cLabs] Release Drafter After First Release" + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - 'celo-release-v[0-9]+\.[0-9]+' + # pull_request event is required only for autolabeler + pull_request: + # Only following types are handled by the action, but one can default to all as well + types: [opened, reopened, synchronize] + branches: + - 'celo-release-v[0-9]+\.[0-9]+' + # pull_request_target event is required for autolabeler to support PRs from forks + # pull_request_target: + # types: [opened, reopened, synchronize] + workflow_dispatch: + +permissions: + contents: read + +jobs: + check-release: + runs-on: ubuntu-latest + outputs: + release_exists: ${{ steps.check_release.outputs.release_exists }} + steps: + # Query the GitHub API to check for a release + - name: Check if release exists + id: check_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + RELEASES=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/${{ github.repository }}/releases") + + BRANCH="${{ github.ref }}" # Current branch + if echo "$RELEASES" | jq -e ".[] | select(.target_commitish == \"$BRANCH\")" > /dev/null; then + echo "Release exists for branch $BRANCH." + echo "release_exists=true" >> $GITHUB_OUTPUT + else + echo "No release found for branch $BRANCH." + echo "release_exists=false" >> $GITHUB_OUTPUT + fi + + update-release-draft: + permissions: + # write permission is required to create a github release + contents: write + # write permission is required for autolabeler + # otherwise, read permission is required at least + pull-requests: write + runs-on: ubuntu-latest + needs: check-release + if: needs.check-release.outputs.release_exists == 'true' + steps: + # (Optional) GitHub Enterprise requires GHE_HOST variable set + #- name: Set GHE_HOST + # run: | + # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV + + # Drafts your next Release notes as Pull Requests are merged + - uses: release-drafter/release-drafter@v6 + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml + with: + tag: celo-v$RESOLVED_VERSION + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}