From 96dd4f860cd9b4c4b9239bb0d1e0e491023b91bb Mon Sep 17 00:00:00 2001 From: alvarof2 Date: Mon, 20 Jan 2025 23:37:22 +0100 Subject: [PATCH 1/6] Test Release GH Actions --- .github/release-drafter.yml | 9 +++ .github/workflows/docker-publish-release.yaml | 62 ++++++++++++++++ .github/workflows/first-release.yaml | 60 ++++++++++++++++ .github/workflows/release-drafter.yml | 71 +++++++++++++++++++ 4 files changed, 202 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..cfb93068d0 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,9 @@ +#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 \ No newline at end of file diff --git a/.github/workflows/docker-publish-release.yaml b/.github/workflows/docker-publish-release.yaml new file mode 100644 index 0000000000..e563ebac91 --- /dev/null +++ b/.github/workflows/docker-publish-release.yaml @@ -0,0 +1,62 @@ +name: "[cLabs] Publish Docker Image For Release" + +on: + release: + types: [published] # Trigger the workflow only when a release is published + +jobs: + get-release-commit: + runs-on: ubuntu-latest + + steps: + # Step 1: Check out the repository code + - name: Checkout Code + uses: actions/checkout@v3 + + # Step 2: Retrieve release commit information + - name: Get Release Commit + id: get-release-info + run: | + # Get the tag name of the published release + RELEASE_TAG=${{ github.event.release.tag_name }} + + # Fetch the commit associated with the tag + RELEASE_COMMIT=$(git rev-list -n 1 "$RELEASE_TAG") + + # Output the commit + echo "Release Tag: $RELEASE_TAG" + echo "Release Commit: $RELEASE_COMMIT" + + # Save outputs for later steps + echo "::set-output name=tag::$RELEASE_TAG" + echo "::set-output name=commit::$RELEASE_COMMIT" + + # Step 3: Use the release commit (optional) + - name: Use Release Commit + run: | + echo "The release is associated with tag: ${{ steps.get-release-info.outputs.tag }}" + echo "The release is associated with commit: ${{ steps.get-release-info.outputs.commit }}" + + # TO DO: Copy the docker image from us-west1-docker.pkg.dev/blockchaintestsglobaltestnet/dev-images/op-geth:${COMMIT_HASH} + # to https://us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:${TAG_NAME} + + # Step 3: Append Tag and Commit to Release Notes + - name: Update Release Notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Default token provided by GitHub Actions + run: | + # Get the current release notes + RELEASE_URL="${{ github.event.release.url }}" + TAG_NAME="${{ steps.get-release-info.outputs.tag }}" + COMMIT_HASH="${{ steps.get-release-info.outputs.commit }}" + CURRENT_BODY="${{ github.event.release.body }}" + + # Append tag and commit to the release notes + UPDATED_NOTES="${CURRENT_BODY}\n\n---\n**Docker Image:** https://us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:${TAG_NAME}\n**Release Tag:** ${TAG_NAME}\n**Commit Hash:** ${COMMIT_HASH}" + + # Update the release notes using GitHub API + curl -X PATCH \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"body\": \"$UPDATED_NOTES\"}" \ + $RELEASE_URL diff --git a/.github/workflows/first-release.yaml b/.github/workflows/first-release.yaml new file mode 100644 index 0000000000..318e3f34c3 --- /dev/null +++ b/.github/workflows/first-release.yaml @@ -0,0 +1,60 @@ +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 }}. + draft: true + prerelease: false diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000000..e3e0173304 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,71 @@ +name: "[cLabs] Release Drafter After First Release" + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - main + - 'celo\d+' + # 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: + - main + - 'celo\d+' + # 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: v$RESOLVED_VERSION + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From ab2468f318c21150abe0f4143db837eb3f7abb63 Mon Sep 17 00:00:00 2001 From: alvarof2 Date: Tue, 21 Jan 2025 00:02:01 +0100 Subject: [PATCH 2/6] Docker Image --- .github/release-drafter.yml | 5 ++++- .github/workflows/docker-publish-release.yaml | 20 ------------------- .github/workflows/first-release.yaml | 2 ++ 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index cfb93068d0..3a408adf35 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -6,4 +6,7 @@ version-resolver: template: | ## What’s Changed - $CHANGES \ No newline at end of file + $CHANGES + + --- + **Docker Image:** https://us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:$RESOLVED_VERSION. \ No newline at end of file diff --git a/.github/workflows/docker-publish-release.yaml b/.github/workflows/docker-publish-release.yaml index e563ebac91..4b415db8ea 100644 --- a/.github/workflows/docker-publish-release.yaml +++ b/.github/workflows/docker-publish-release.yaml @@ -40,23 +40,3 @@ jobs: # TO DO: Copy the docker image from us-west1-docker.pkg.dev/blockchaintestsglobaltestnet/dev-images/op-geth:${COMMIT_HASH} # to https://us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:${TAG_NAME} - # Step 3: Append Tag and Commit to Release Notes - - name: Update Release Notes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Default token provided by GitHub Actions - run: | - # Get the current release notes - RELEASE_URL="${{ github.event.release.url }}" - TAG_NAME="${{ steps.get-release-info.outputs.tag }}" - COMMIT_HASH="${{ steps.get-release-info.outputs.commit }}" - CURRENT_BODY="${{ github.event.release.body }}" - - # Append tag and commit to the release notes - UPDATED_NOTES="${CURRENT_BODY}\n\n---\n**Docker Image:** https://us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:${TAG_NAME}\n**Release Tag:** ${TAG_NAME}\n**Commit Hash:** ${COMMIT_HASH}" - - # Update the release notes using GitHub API - curl -X PATCH \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -H "Content-Type: application/json" \ - -d "{\"body\": \"$UPDATED_NOTES\"}" \ - $RELEASE_URL diff --git a/.github/workflows/first-release.yaml b/.github/workflows/first-release.yaml index 318e3f34c3..aa9e23689a 100644 --- a/.github/workflows/first-release.yaml +++ b/.github/workflows/first-release.yaml @@ -56,5 +56,7 @@ jobs: 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 From 9d6fbe107aa97a0a0377874d8230e822f8c458f6 Mon Sep 17 00:00:00 2001 From: alvarof2 Date: Tue, 21 Jan 2025 00:25:26 +0100 Subject: [PATCH 3/6] Crane Publish Docker Image For Release --- .github/workflows/docker-publish-release.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/docker-publish-release.yaml b/.github/workflows/docker-publish-release.yaml index 4b415db8ea..80fd14bc7c 100644 --- a/.github/workflows/docker-publish-release.yaml +++ b/.github/workflows/docker-publish-release.yaml @@ -1,6 +1,7 @@ name: "[cLabs] Publish Docker Image For Release" on: + workflow_dispatch: release: types: [published] # Trigger the workflow only when a release is published @@ -40,3 +41,20 @@ jobs: # TO DO: Copy the docker image from us-west1-docker.pkg.dev/blockchaintestsglobaltestnet/dev-images/op-geth:${COMMIT_HASH} # to https://us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:${TAG_NAME} + - name: Login at GCP Artifact Registry + uses: celo-org/reusable-workflows/.github/actions/auth-gcp-artifact-registry@v2.0.5 + with: + workload-id-provider: projects/1094498259535/locations/global/workloadIdentityPools/op-geth-release/providers/github-by-repos + service-account: op-geth-release@blockchaintestsglobaltestnet.iam.gserviceaccount.com + docker-gcp-registries: us-west1-docker.pkg.dev + + - name: Install Crane + run: | + curl -sSL https://github.com/google/go-containerregistry/releases/latest/download/go-containerregistry_Linux_x86_64.tar.gz | tar xz -C /usr/local/bin + + - name: Verify Crane Installation + run: crane version + + - name: Copy Container Image with Crane + run: crane copy us-west1-docker.pkg.dev/blockchaintestsglobaltestnet/dev-images/op-geth:${{ steps.get-release-info.outputs.commit }} us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:${{ steps.get-release-info.outputs.commit }} + \ No newline at end of file From 9d2db7e2a0cb025e3fbbed1850fec959823b1588 Mon Sep 17 00:00:00 2001 From: alvarof2 Date: Tue, 21 Jan 2025 09:43:16 +0100 Subject: [PATCH 4/6] Build-Container-Release --- .github/workflows/docker-publish-release.yaml | 68 ++++++------------- 1 file changed, 19 insertions(+), 49 deletions(-) diff --git a/.github/workflows/docker-publish-release.yaml b/.github/workflows/docker-publish-release.yaml index 80fd14bc7c..ad9a641a28 100644 --- a/.github/workflows/docker-publish-release.yaml +++ b/.github/workflows/docker-publish-release.yaml @@ -9,52 +9,22 @@ jobs: get-release-commit: runs-on: ubuntu-latest - steps: - # Step 1: Check out the repository code - - name: Checkout Code - uses: actions/checkout@v3 - - # Step 2: Retrieve release commit information - - name: Get Release Commit - id: get-release-info - run: | - # Get the tag name of the published release - RELEASE_TAG=${{ github.event.release.tag_name }} - - # Fetch the commit associated with the tag - RELEASE_COMMIT=$(git rev-list -n 1 "$RELEASE_TAG") - - # Output the commit - echo "Release Tag: $RELEASE_TAG" - echo "Release Commit: $RELEASE_COMMIT" - - # Save outputs for later steps - echo "::set-output name=tag::$RELEASE_TAG" - echo "::set-output name=commit::$RELEASE_COMMIT" - - # Step 3: Use the release commit (optional) - - name: Use Release Commit - run: | - echo "The release is associated with tag: ${{ steps.get-release-info.outputs.tag }}" - echo "The release is associated with commit: ${{ steps.get-release-info.outputs.commit }}" - - # TO DO: Copy the docker image from us-west1-docker.pkg.dev/blockchaintestsglobaltestnet/dev-images/op-geth:${COMMIT_HASH} - # to https://us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:${TAG_NAME} - - - name: Login at GCP Artifact Registry - uses: celo-org/reusable-workflows/.github/actions/auth-gcp-artifact-registry@v2.0.5 - with: - workload-id-provider: projects/1094498259535/locations/global/workloadIdentityPools/op-geth-release/providers/github-by-repos - service-account: op-geth-release@blockchaintestsglobaltestnet.iam.gserviceaccount.com - docker-gcp-registries: us-west1-docker.pkg.dev - - - name: Install Crane - run: | - curl -sSL https://github.com/google/go-containerregistry/releases/latest/download/go-containerregistry_Linux_x86_64.tar.gz | tar xz -C /usr/local/bin - - - name: Verify Crane Installation - run: crane version - - - name: Copy Container Image with Crane - run: crane copy us-west1-docker.pkg.dev/blockchaintestsglobaltestnet/dev-images/op-geth:${{ steps.get-release-info.outputs.commit }} us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:${{ steps.get-release-info.outputs.commit }} - \ No newline at end of file + 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 From ab731f8d343f61d4effe7c6cf08f022ee8d3bc3c Mon Sep 17 00:00:00 2001 From: alvarof2 Date: Tue, 21 Jan 2025 09:50:05 +0100 Subject: [PATCH 5/6] Blank --- .github/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 3a408adf35..8b837e0522 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -9,4 +9,4 @@ template: | $CHANGES --- - **Docker Image:** https://us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:$RESOLVED_VERSION. \ No newline at end of file + **Docker Image:** https://us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/op-geth:$RESOLVED_VERSION. From bd9153aabace5912c090d6057f1b5d2cd414a2c3 Mon Sep 17 00:00:00 2001 From: alvarof2 Date: Fri, 24 Jan 2025 23:11:31 +0100 Subject: [PATCH 6/6] Branches to trigger and tag --- .github/workflows/release-drafter.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index e3e0173304..e4a28123eb 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -4,15 +4,13 @@ on: push: # branches to consider in the event; optional, defaults to all branches: - - main - - 'celo\d+' + - '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: - - main - - 'celo\d+' + - '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] @@ -66,6 +64,6 @@ jobs: - uses: release-drafter/release-drafter@v6 # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml with: - tag: v$RESOLVED_VERSION + tag: celo-v$RESOLVED_VERSION env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}