Skip to content

Commit 13c23df

Browse files
committed
ci: update publish-for-forge.sh
1 parent 9ffc7e4 commit 13c23df

File tree

2 files changed

+17
-28
lines changed

2 files changed

+17
-28
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ jobs:
5151
steps:
5252
- uses: actions/checkout@v4
5353
- uses: fregante/setup-git-user@v2.0.1
54-
- name: Push contracts to dedicated branches
54+
- name: Push contracts to forge branch
5555
run: scripts/publish-for-forge.sh

scripts/publish-for-forge.sh

+16-27
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,36 @@
33
set -eu
44

55
clean() {
6-
pkg="$1"
76
# TODO: use regex instead
8-
find . -maxdepth 2 \
7+
find . -maxdepth 1 \
98
! -path . \
109
! -path ./.git \
1110
! -path "./.git/*" \
12-
! -path ./.gitignore \
1311
! -path ./packages \
1412
! -path ./LICENSE \
15-
! -path "./packages/$pkg" \
1613
-exec rm -rf {} +
1714
}
1815

19-
maybe_publish_forge_pkg() {
20-
pkg="$1"
21-
version=$(jq -r '.version' "packages/$pkg/package.json")
22-
latest_commit_msg=$(git log -1 --pretty=%B)
23-
24-
git checkout -b "$pkg"
25-
# return early if latest already published
26-
[ "$latest_commit_msg" = "$version" ] && return
27-
git pull --rebase origin "$pkg" 2>/dev/null || true
28-
clean "$pkg"
29-
mkdir "$pkg"
30-
mv "packages/$pkg"/src "$pkg"
31-
mv "packages/$pkg"/README.md "$pkg"
32-
mv LICENSE "$pkg"
33-
rm -fr "packages"
34-
git add "$pkg"
35-
git commit -am "$version"
36-
git push origin "$pkg"
37-
git checkout origin/"$GITHUB_HEAD_REF"
38-
}
39-
4016
main() {
41-
git fetch origin "$GITHUB_HEAD_REF"
17+
git fetch origin main
18+
latest_main_commit_msg=$(git log origin/main -1 --pretty=%B)
19+
20+
git checkout -b forge
21+
clean
22+
4223
# http://mywiki.wooledge.org/BashFAQ/001
4324
# https://github.com/koalaman/shellcheck/wiki/SC2012
4425
find packages -maxdepth 1 -mindepth 1 -printf '%P\n' | while read -r pkg; do
45-
maybe_publish_forge_pkg "$pkg"
26+
mkdir "$pkg"
27+
mv "packages/$pkg/src" "$pkg"
28+
mv "packages/$pkg/README.md" "$pkg"
29+
git add "$pkg"
4630
done
31+
32+
rm -fr "packages"
33+
34+
git commit -am "$latest_main_commit_msg"
35+
git push origin forge
4736
}
4837

4938
main

0 commit comments

Comments
 (0)