-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Add workflow to release upgradeable package #6015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
8b5132b
a252b22
870e714
649a635
0c2dab8
259c56e
40a76ef
aa1b25a
b096f3b
e004cb0
9581bae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,72 @@ | ||||||||
| name: Release Upgradeable | ||||||||
|
|
||||||||
| on: | ||||||||
| workflow_dispatch: {} | ||||||||
|
|
||||||||
| jobs: | ||||||||
| release-upgradeable: | ||||||||
| environment: push-upgradeable | ||||||||
| runs-on: ubuntu-latest | ||||||||
| env: | ||||||||
| VANILLA_REPO: OpenZeppelin/openzeppelin-contracts | ||||||||
| UPGRADEABLE_REPO: james-toussaint/openzeppelin-contracts-upgradeable # TODO: Update repo before merging | ||||||||
| steps: | ||||||||
| - uses: actions/checkout@v5 | ||||||||
| with: | ||||||||
| repository: ${{ env.VANILLA_REPO }} | ||||||||
| fetch-depth: 0 | ||||||||
james-toussaint marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
| ref: ${{ github.ref }} | ||||||||
| - name: Get vanilla commit | ||||||||
| run: | | ||||||||
| echo "VANILLA_COMMIT=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV" | ||||||||
| - uses: actions/checkout@v5 | ||||||||
| with: | ||||||||
| repository: ${{ env.UPGRADEABLE_REPO }} | ||||||||
| fetch-depth: 0 | ||||||||
james-toussaint marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
| submodules: true | ||||||||
| token: ${{ secrets.GH_TOKEN_UPGRADEABLE }} | ||||||||
| ref: ${{ github.ref }} | ||||||||
| - name: Run | ||||||||
| run: | | ||||||||
| if ! git log -1 --pretty=%B | grep -q "Transpile ${VANILLA_COMMIT}"; then | ||||||||
| echo "Expected 'Transpile ${VANILLA_COMMIT}' but found '$(git log -1 --pretty=%B)'" | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
| VERSION="$(jq -r .version package.json)" | ||||||||
james-toussaint marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
| GIT_TAG="v${VERSION}" | ||||||||
| NPM_TAG="tmp" | ||||||||
| ADDITIONAL_OPTION_IF_PRERELEASE="--prerelease" | ||||||||
| if [[ "${GIT_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||||||||
| NPM_TAG="dev" | ||||||||
| ADDITIONAL_OPTION_IF_PRERELEASE="" | ||||||||
| elif [[ "${GIT_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rc.[0-9]+$ ]]; then | ||||||||
| NPM_TAG="next" | ||||||||
| fi | ||||||||
|
||||||||
| echo "ADDITIONAL_OPTION_IF_PRERELEASE=${ADDITIONAL_OPTION_IF_PRERELEASE}" >> "$GITHUB_ENV" | ||||||||
| ### [START BLOCK] TODO: Remove block before merging | ||||||||
| TIMESTAMPED_VERSION="${VERSION}-$(date +%s)" | ||||||||
| echo "OLD_GIT_TAG=${GIT_TAG}" >> "$GITHUB_ENV" | ||||||||
| GIT_TAG="${GIT_TAG}-$(date +%s)" # incremental git tag for testing | ||||||||
| sed -i'' -e 's/openzeppelin\/contracts-upgradeable/james-toussaint\/contracts-upgradeable/g' contracts/package.json # custom scope for testing | ||||||||
| sed -i'' -e "s/${VERSION}/${TIMESTAMPED_VERSION}/g" contracts/package.json && head contracts/package.json # incremental npm package version for testing | ||||||||
| ### [END BLOCK] | ||||||||
| npm ci | ||||||||
james-toussaint marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
| bash scripts/git-user-config.sh | ||||||||
james-toussaint marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
| git tag -m {,}"${GIT_TAG}" | ||||||||
| CI=true git push origin tag "${GIT_TAG}" | ||||||||
| cd "contracts/" | ||||||||
| # Intentionally escape $ to avoid interpolation and writing the token to disk | ||||||||
| echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc | ||||||||
| npm publish --tag "${NPM_TAG}" | ||||||||
| echo "GIT_TAG=${GIT_TAG}" >> "$GITHUB_ENV" | ||||||||
| env: | ||||||||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||||||||
|
||||||||
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
Also, I think this would fail because the NPM_TOKEN is only available in the npm environment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NPM_TOKEN has been removed.
Right now package.json url repository needs to be updated from upgradeable to vanilla to comply with provenance:
- https://www.npmjs.com/package/@james-toussaint/contracts-upgradeable/v/5.5.0-rc.1-1761847279#provenance
sed -i'' -e 's/OpenZeppelin\/openzeppelin-contracts-upgradeable/james-toussaint\/openzeppelin-contracts/g' contracts/package.json # repository.url for provenance (TODO: Update and try keep upgradeable url)
james-toussaint marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to document that the release will not include a customized readme and that we should copy paste the one from vanilla. Ideally, it would copy it directly from vanilla but that's too overkill imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Content is copied from vanilla release, see --notes.

Uh oh!
There was an error while loading. Please reload this page.