mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 09:50:45 +00:00
feat: signed commit when renaming upstream module (#61)
## Why this should be merged
Signs commits for auto-renaming the Go module, originally introduced in
#51 with unsigned commits that can't be merged to `main`.
## How this works
Changes the commit action to use
[`ghcommit`](https://github.com/planetscale/ghcommit), which was made
specifically to allow for keyless signing (GitHub signs the commit). The
workflow no longer opens a PR to the `renamed-go-module` branch as it's
redundant and the generated branch can be used directly.
The commit message includes the `workflow_dispatch` trigger branch as
well as a hash of the workflow file for a complete audit trail.
I removed the commented-out PR trigger as it's unnecessary. In
development we can now just trigger the workflow on the dev branch.
## How this was tested
Inspecting [the
commit](572b8ab74e)
generated by a [workflow
run](https://github.com/ava-labs/libevm/actions/runs/11357025696/job/31589219847).
It is identical in modifications to the one reviewed in #59.
This commit is contained in:
parent
21122c043a
commit
c6c85589af
1 changed files with 25 additions and 30 deletions
55
.github/workflows/rename-module.yml
vendored
55
.github/workflows/rename-module.yml
vendored
|
|
@ -1,13 +1,6 @@
|
||||||
name: Rename Go module
|
name: Rename Go module
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# During development, the next two lines MAY be enabled to have the PR
|
|
||||||
# automatically run this workflow for inspection of the resulting branch.
|
|
||||||
# However, they MUST be disabled again before merging otherwise *all* PRs will
|
|
||||||
# run this.
|
|
||||||
#
|
|
||||||
# pull_request:
|
|
||||||
# branches: [ main ]
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
source_commit:
|
source_commit:
|
||||||
|
|
@ -19,18 +12,24 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
rename-module:
|
rename-module:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
source_commit: "${{ inputs.source_commit || '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' }}"
|
|
||||||
# env variables cannot reference others so we have to duplicate the ||
|
|
||||||
output_branch: "${{ github.ref_name }}_auto-rename-module-${{ inputs.source_commit || '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' }}"
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # everything
|
fetch-depth: 0 # everything
|
||||||
fetch-tags: true
|
|
||||||
|
- name: Set variables
|
||||||
|
id: vars
|
||||||
|
# Including hashes of both the source commit and the workflow file makes
|
||||||
|
# this idempotent.
|
||||||
|
env:
|
||||||
|
WORKFLOW_HASH: ${{ hashFiles('.github/workflows/rename-module.yml') }}
|
||||||
|
run: |
|
||||||
|
echo "WORKFLOW_HASH=${WORKFLOW_HASH}" >> "$GITHUB_OUTPUT";
|
||||||
|
echo "DEST_BRANCH=auto-rename-module_source-${{ inputs.source_commit }}_workflow-${WORKFLOW_HASH}-${{ github.ref_name }}" \
|
||||||
|
>> "$GITHUB_OUTPUT";
|
||||||
|
|
||||||
- name: Check out source commit
|
- name: Check out source commit
|
||||||
run: git checkout ${{ env.source_commit }}
|
run: git checkout ${{ inputs.source_commit }}
|
||||||
|
|
||||||
- name: Globally update module name
|
- name: Globally update module name
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -60,22 +59,18 @@ jobs:
|
||||||
go build ./...;
|
go build ./...;
|
||||||
go test ./accounts/abi/bind ./rlp/rlpgen
|
go test ./accounts/abi/bind ./rlp/rlpgen
|
||||||
|
|
||||||
- name: Commit to new branch
|
- name: Create new branch
|
||||||
uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7
|
env:
|
||||||
with:
|
BRANCH: ${{ steps.vars.outputs.DEST_BRANCH }}
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
run: |
|
||||||
target_branch: ${{ env.output_branch }}
|
git checkout -b "${BRANCH}";
|
||||||
force: true
|
git push origin "${BRANCH}";
|
||||||
commit_prefix: "[AUTO] rename Go module + update internal import paths"
|
|
||||||
|
|
||||||
- name: Open PR to "renamed-go-module" iff workflow dispatched on "main"
|
- name: Commit to new branch
|
||||||
# If we are changing the way in which we manage module renaming then it
|
uses: planetscale/ghcommit-action@d4176bfacef926cc2db351eab20398dfc2f593b5 # v0.2.0
|
||||||
# MUST go through PR review to main; only then can it open PRs.
|
env:
|
||||||
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
uses: devops-infra/action-pull-request@v0.5.5
|
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
commit_message: "[AUTO] rename Go module + update internal import paths\n\nWorkflow: ${{ steps.vars.outputs.WORKFLOW_HASH }} on branch ${{ github.ref_name }}"
|
||||||
source_branch: ${{ env.output_branch }}
|
repo: ${{ github.repository }}
|
||||||
target_branch: renamed-go-module
|
branch: ${{ steps.vars.outputs.DEST_BRANCH }}
|
||||||
title: "[AUTO] Rename upstream Go module at `${{ env.source_commit }}`"
|
|
||||||
body: "_PR generated by GitHub Action_"
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue