From 3d2d27304469cdfbd497e3847f1686ce7956204e Mon Sep 17 00:00:00 2001 From: tchataigner Date: Mon, 29 Jul 2024 19:48:31 +0200 Subject: [PATCH] ci: refactor release flow (#127) * ci: refactor release flow * refactor: apply suggestions Co-authored-by: Samuel Burnham <45365069+samuelburnham@users.noreply.github.com> * refactor: integrate review --------- Co-authored-by: Samuel Burnham <45365069+samuelburnham@users.noreply.github.com> --- .github/workflows/bump-version-PR.yml | 39 ++++++++++++++++++--------- .github/workflows/tag-release.yml | 2 +- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/.github/workflows/bump-version-PR.yml b/.github/workflows/bump-version-PR.yml index 0ab5b840..af90ae4b 100644 --- a/.github/workflows/bump-version-PR.yml +++ b/.github/workflows/bump-version-PR.yml @@ -2,6 +2,14 @@ name: Bump Version on: workflow_dispatch: inputs: + light-client: + description: 'aptos or ethereum' + type: choice + options: + - aptos + - ethereum + required: true + default: 'aptos' type: description: 'release or hotfix' type: choice @@ -39,8 +47,8 @@ jobs: - name: Install `tq-rs` run: cargo install tq-rs - # The `release/1.0` branch is always truncated, so that patch version merges still are valid Semver - # However, when we make the initial `release/1.0` version bump, we include the full `1.0.0` in `Cargo.toml` + # The `release/-v1.0` branch is always truncated, so that patch version merges still are valid Semver + # However, when we make the initial `release/-v1.0` version bump, we include the full `1.0.0` in `Cargo.toml` # and the release for clarity - name: Set branches run: | @@ -48,19 +56,19 @@ jobs: BASE_VERSION="${BASE_VERSION_SHORT}.0" if [[ "${{ inputs.type }}" == "hotfix" ]]; then VERSION=${{ inputs.version }} - BASE_BRANCH="release/v$BASE_VERSION_SHORT" - PR_BRANCH="${{ inputs.type }}/v${{ inputs.version }}" - git checkout $PR_BRANCH + BASE_BRANCH="release/${{ inputs.light-client }}-v$BASE_VERSION_SHORT" + PR_BRANCH="${{ inputs.type }}/${{ inputs.light-client }}-v${{ inputs.version }}" + git checkout -b $PR_BRANCH else VERSION=$BASE_VERSION BASE_BRANCH="dev" - PR_BRANCH="release/v$BASE_VERSION_SHORT" + PR_BRANCH="release/${{ inputs.light-client }}-v$BASE_VERSION_SHORT" git checkout -b $PR_BRANCH fi echo "BASE_BRANCH=$BASE_BRANCH" | tee -a $GITHUB_ENV echo "PR_BRANCH=$PR_BRANCH" | tee -a $GITHUB_ENV - echo "PR_DESCRIPTION=chore: Release $VERSION" | tee -a $GITHUB_ENV + echo "PR_DESCRIPTION=chore(${{ inputs.light-client }}): Release $VERSION" | tee -a $GITHUB_ENV echo "VERSION=$VERSION" | tee -a $GITHUB_ENV # Regex from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string @@ -81,7 +89,14 @@ jobs: run: | echo "Updating version in Cargo.toml..." - members=$(tq workspace.members -f Cargo.toml | jq -r '. += ["programs/inclusion", "programs/epoch-change"] | .[]') + if [[ "${{ inputs.light-client }}" == "ethereum" ]]; then + members=$(tq workspace.members -f Cargo.toml | jq -r '. += ["programs/inclusion", "programs/committee-change"] | .[]') + elif [[ "${{ inputs.light-client }}" == "aptos" ]]; then + members=$(tq workspace.members -f Cargo.toml | jq -r '. += ["programs/inclusion", "programs/epoch-change"] | .[]') + else + echo "Unknown light-client: ${{ inputs.light-client }}. Aborting..." + exit 1 + fi bump_version() { cd "$1" @@ -106,7 +121,7 @@ jobs: bump_version "$path" fi done <<< "$members" - working-directory: ${{ github.workspace }}/aptos + working-directory: ${{ github.workspace }}/${{ inputs.light-client }} - name: Commit changes run: | @@ -119,13 +134,13 @@ jobs: - name: Create PR run: | cat << 'EOF' > body.md - This is an automated release PR for version `${ env.VERSION }}`. + This is an automated release PR for version `${{ env.VERSION }}` of the ${{ inputs.light-client }} light client. - On merge, this will trigger the [release publish workflow](${{ github.server_url }}/${{ github.repository }}/actions/workflows/tag-release.yml), which will upload a new GitHub release with tag `v${{ env.VERSION }}`. + On merge, this will trigger the [release publish workflow](${{ github.server_url }}/${{ github.repository }}/actions/workflows/tag-release.yml), which will upload a new GitHub release with tag `${{ inputs.light-client }}-v${{ env.VERSION }}`. [Workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) EOF gh pr create --title "${{ env.PR_DESCRIPTION }}" --body-file ./body.md --head ${{ env.PR_BRANCH }} --base ${{ env.BASE_BRANCH }} env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ github.token }} \ No newline at end of file diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 36c310bc..f87949c0 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -58,4 +58,4 @@ jobs: body: ${{ steps.github_release.outputs.changelog }} tag: ${{ steps.get-version.outputs.version }} commit: ${{ env.RELEASE_BRANCH }} - allowUpdates: true + allowUpdates: true \ No newline at end of file