Skip to content

Commit

Permalink
Tentative op-geth Release workflows for CELO (#314)
Browse files Browse the repository at this point in the history
* Test Release GH Actions

* Docker Image

* Crane Publish Docker Image For Release

* Build-Container-Release

* Blank

* Branches to trigger and tag
  • Loading branch information
alvarof2 authored Jan 30, 2025
1 parent 2a740e5 commit 659a5ac
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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.
30 changes: 30 additions & 0 deletions .github/workflows/docker-publish-release.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
62 changes: 62 additions & 0 deletions .github/workflows/first-release.yaml
Original file line number Diff line number Diff line change
@@ -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
69 changes: 69 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit 659a5ac

Please sign in to comment.