Skip to content

Commit 65917f0

Browse files
committed
Automate input of rename go module workflow
1 parent 0fff08c commit 65917f0

File tree

3 files changed

+33
-25
lines changed

3 files changed

+33
-25
lines changed

.github/workflows/rename-module.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ name: Rename Go module
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
source_commit:
7-
description: "Upstream commit on which to base module renaming"
8-
required: true
9-
type: string
10-
default: "2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1"
115

126
jobs:
137
rename-module:
@@ -17,6 +11,10 @@ jobs:
1711
with:
1812
fetch-depth: 0 # everything
1913

14+
- name: Find base geth commit hash
15+
id: geth-commit
16+
run: echo "hash=$(.github/workflows/scripts/geth-commit.sh)" >> "$GITHUB_OUTPUT"
17+
2018
- name: Set variables
2119
id: vars
2220
# Including hashes of both the source commit and the workflow file makes
@@ -25,11 +23,11 @@ jobs:
2523
WORKFLOW_HASH: ${{ hashFiles('.github/workflows/rename-module.yml') }}
2624
run: |
2725
echo "WORKFLOW_HASH=${WORKFLOW_HASH}" >> "$GITHUB_OUTPUT";
28-
echo "DEST_BRANCH=auto-rename-module_source-${{ inputs.source_commit }}_workflow-${WORKFLOW_HASH}-${{ github.ref_name }}" \
26+
echo "DEST_BRANCH=auto-rename-module_source-${{ steps.geth-commit.outputs.hash }}_workflow-${WORKFLOW_HASH}-${{ github.ref_name }}" \
2927
>> "$GITHUB_OUTPUT";
3028
3129
- name: Check out source commit
32-
run: git checkout ${{ inputs.source_commit }}
30+
run: git checkout ${{ steps.geth-commit.outputs.hash }}
3331

3432
- name: Globally update module name
3533
run: |

.github/workflows/scripts/base-commit.sh

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,8 @@
77
# go-ethereum (aka geth) tag present in the main branch of libevm.
88
# If an error occurs, this one is echo-ed and the script exits with code 1.
99

10-
git remote add geth https://github.com/ethereum/go-ethereum.git
11-
git fetch geth 'refs/tags/*:refs/tags/*'
1210

13-
geth_tags=$(git ls-remote --tags --sort=-version:refname geth "v[1-9]*" | awk '{print $2}' | sed 's/refs\/tags\///')
14-
15-
base_geth_tag_hash=
16-
for geth_tag in $geth_tags; do
17-
geth_tag_hash="$(git rev-parse $geth_tag)"
18-
if git merge-base --is-ancestor $geth_tag_hash "origin/main"; then
19-
base_geth_tag_hash="$geth_tag_hash"
20-
break
21-
fi
22-
done
23-
24-
if [ -z "$base_geth_tag_hash" ]; then
25-
echo "No geth tag found in libevm main branch."
26-
exit 1
27-
fi
11+
base_geth_tag_hash="$($(dirname "$0")/geth-commit.sh)"
2812

2913
base_commit_hash="$(git log --oneline --grep="rename Go module + update internal import paths" --after "$base_geth_tag_hash" -n 1 origin/main | head -n 1 | awk '{print $1}')"
3014
if [ -z "$base_commit_hash" ]; then
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# This script finds the base commit corresponding to a geth tag
4+
# from which libevm was last based on, and returns it to the caller.
5+
# If an error occurs, this one is echo-ed and the script exits with code 1.
6+
7+
git remote add geth https://github.com/ethereum/go-ethereum.git
8+
git fetch geth 'refs/tags/*:refs/tags/*'
9+
10+
geth_tags=$(git ls-remote --tags --sort=-version:refname geth "v[1-9]*" | awk '{print $2}' | sed 's/refs\/tags\///')
11+
12+
base_geth_tag_hash=
13+
for geth_tag in $geth_tags; do
14+
geth_tag_hash="$(git rev-parse --short $geth_tag)"
15+
if git merge-base --is-ancestor $geth_tag_hash "origin/main"; then
16+
base_geth_tag_hash="$geth_tag_hash"
17+
break
18+
fi
19+
done
20+
21+
if [ -z "$base_geth_tag_hash" ]; then
22+
echo "No geth tag found in libevm main branch."
23+
exit 1
24+
fi
25+
26+
echo $base_geth_tag_hash | tr -d '\n'

0 commit comments

Comments
 (0)