Skip to content

Commit 8b5132b

Browse files
Add workflow to release upgradeable package
1 parent 1cf1377 commit 8b5132b

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Release Upgradeable
2+
3+
on:
4+
workflow_dispatch: {}
5+
6+
jobs:
7+
release-upgradeable:
8+
environment: push-upgradeable
9+
runs-on: ubuntu-latest
10+
env:
11+
VANILLA_REPO: OpenZeppelin/openzeppelin-contracts
12+
UPGRADEABLE_REPO: james-toussaint/openzeppelin-contracts-upgradeable # TODO: Update repo before merging
13+
steps:
14+
- uses: actions/checkout@v5
15+
with:
16+
repository: ${{ env.VANILLA_REPO }}
17+
fetch-depth: 0
18+
ref: ${{ github.ref }}
19+
- name: Get vanilla commit
20+
run: |
21+
echo "VANILLA_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
22+
- uses: actions/checkout@v5
23+
with:
24+
repository: ${{ env.UPGRADEABLE_REPO }}
25+
fetch-depth: 0
26+
submodules: true
27+
token: ${{ secrets.GH_TOKEN_UPGRADEABLE }}
28+
ref: ${{ github.ref }}
29+
- name: Run
30+
run: |
31+
if ! $(git log -1 --pretty=%B | grep -q "Transpile ${VANILLA_COMMIT}"); then
32+
echo "Expected 'Transpile ${VANILLA_COMMIT}' but found '$(git log -1 --pretty=%B)'"
33+
fi
34+
VERSION="$(jq -r .version package.json)"
35+
GIT_TAG="v${VERSION}"
36+
NPM_TAG="tmp"
37+
ADDITIONAL_OPTION_IF_PRERELEASE="--prerelease"
38+
if [[ "${GIT_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
39+
NPM_TAG="dev"
40+
ADDITIONAL_OPTION_IF_PRERELEASE=""
41+
elif [[ "${GIT_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rc.[0-9]+$ ]]; then
42+
NPM_TAG="next"
43+
fi
44+
echo "ADDITIONAL_OPTION_IF_PRERELEASE=${ADDITIONAL_OPTION_IF_PRERELEASE}" >> $GITHUB_ENV
45+
### [START BLOCK] TODO: Remove block before merging
46+
TIMESTAMPED_VERSION="${VERSION}-$(date +%s)"
47+
OLD_GIT_TAG="${GIT_TAG}"
48+
GIT_TAG="${GIT_TAG}-$(date +%s)" # incremental git tag for testing
49+
sed -i'' -e 's/openzeppelin\/contracts-upgradeable/james-toussaint\/contracts-upgradeable/g' contracts/package.json # custom scope for testing
50+
sed -i'' -e "s/${VERSION}/${TIMESTAMPED_VERSION}/g" contracts/package.json && head contracts/package.json # incremental npm package version for testing
51+
### [END BLOCK]
52+
npm ci
53+
bash scripts/git-user-config.sh
54+
git tag -m {,}${GIT_TAG}
55+
CI=true git push origin tag ${GIT_TAG}
56+
cd contracts
57+
# Intentionally escape $ to avoid interpolation and writing the token to disk
58+
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
59+
npm publish --tag ${NPM_TAG}
60+
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_ENV
61+
env:
62+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
63+
- name: Create Github Release Note
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_UPGRADEABLE }}
66+
run: |
67+
gh release create "${GIT_TAG}" \
68+
--repo="${UPGRADEABLE_REPO}" \
69+
--title="${GIT_TAG}" \
70+
--notes="$(gh release view ${OLD_GIT_TAG} --repo="${VANILLA_REPO}" --json body -q .body)" `#TODO: Update tag before merging` \
71+
${ADDITIONAL_OPTION_IF_PRERELEASE}

0 commit comments

Comments
 (0)