-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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 all commits
8b5132b
a252b22
870e714
649a635
0c2dab8
259c56e
40a76ef
aa1b25a
b096f3b
e004cb0
9581bae
bed91d7
d96e92a
2bcbcea
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,52 @@ | ||||||||||||||
| name: Release Upgradeable | ||||||||||||||
|
|
||||||||||||||
| on: | ||||||||||||||
| workflow_dispatch: {} | ||||||||||||||
|
|
||||||||||||||
| jobs: | ||||||||||||||
| release-upgradeable: | ||||||||||||||
| environment: push-upgradeable | ||||||||||||||
| permissions: | ||||||||||||||
| id-token: write # Required for OIDC | ||||||||||||||
| contents: read | ||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||
| env: | ||||||||||||||
| REFERENCE_REPO: OpenZeppelin/openzeppelin-contracts | ||||||||||||||
| UPGRADEABLE_REPO: james-toussaint/openzeppelin-contracts-upgradeable # TODO: Update repo before merging | ||||||||||||||
| steps: | ||||||||||||||
| - uses: actions/checkout@v5 | ||||||||||||||
| with: | ||||||||||||||
| repository: ${{ env.UPGRADEABLE_REPO }} | ||||||||||||||
| submodules: true | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| token: ${{ secrets.GH_TOKEN_UPGRADEABLE }} | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we shouldn't need that for checkout
Suggested change
|
||||||||||||||
| ref: ${{ github.ref }} | ||||||||||||||
| - uses: actions/checkout@v5 | ||||||||||||||
| with: | ||||||||||||||
| repository: ${{ env.REFERENCE_REPO }} | ||||||||||||||
| ref: ${{ github.ref }} | ||||||||||||||
| path: reference | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| - name: Get reference commit | ||||||||||||||
| id: get-reference-commit | ||||||||||||||
| run: cd reference && echo "commit=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| - uses: actions/checkout@v5 # TODO: Remove this before merging (used to get scripts added in this PR) | ||||||||||||||
| with: | ||||||||||||||
| path: reference | ||||||||||||||
|
Comment on lines
+31
to
+33
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| - name: Set up environment | ||||||||||||||
| uses: ./reference/.github/actions/setup | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| - name: Check upgradeable | ||||||||||||||
| id: check-upgradeable | ||||||||||||||
| run: bash reference/scripts/release/workflow/check-upgradeable.sh | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| env: | ||||||||||||||
| REFERENCE_COMMIT: ${{ steps.get-reference-commit.outputs.commit }} | ||||||||||||||
| - name: Publish upgradeable contracts | ||||||||||||||
| id: publish | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is that id needed ?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| run: bash reference/scripts/release/workflow/publish-upgradeable.sh | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| env: | ||||||||||||||
| NPM_TAG: ${{ steps.check-upgradeable.outputs.npm_tag }} | ||||||||||||||
Amxx marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+43
to
+45
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| - name: Create Github Release Note | ||||||||||||||
| run: bash reference/scripts/release/workflow/github-release-upgradeable.sh | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| env: | ||||||||||||||
| GITHUB_TOKEN: ${{ secrets.GH_TOKEN_UPGRADEABLE }} | ||||||||||||||
| GIT_TAG: ${{ steps.check-upgradeable.outputs.git_tag }} | ||||||||||||||
| RELEASE_COMMIT: ${{ steps.check-upgradeable.outputs.release_commit }} | ||||||||||||||
| PRERELEASE: ${{ steps.check-upgradeable.outputs.prerelease }} | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| echo "release_commit=$(git log -1 --pretty=%H)" >> "$GITHUB_OUTPUT" | ||
| if ! git log -1 --pretty=%B | grep -q "Transpile ${REFERENCE_COMMIT}"; then | ||
| echo "Expected 'Transpile ${REFERENCE_COMMIT}' but found '$(git log -1 --pretty=%B)'" | ||
| exit 1 | ||
| fi | ||
| VERSION="$(jq -r .version contracts/package.json)" | ||
| GIT_TAG="v${VERSION}" | ||
| NPM_TAG="tmp" | ||
| PRERELEASE="true" | ||
| if [[ "${GIT_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| NPM_TAG="dev" | ||
| PRERELEASE="false" | ||
| elif [[ "${GIT_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rc.[0-9]+$ ]]; then | ||
| NPM_TAG="next" | ||
| fi | ||
| echo "prerelease=${PRERELEASE}" >> "$GITHUB_OUTPUT" | ||
| echo "npm_tag=${NPM_TAG}" >> "$GITHUB_OUTPUT" | ||
| ### [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] | ||
| echo "git_tag=${GIT_TAG}" >> "$GITHUB_OUTPUT" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
james-toussaint marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| set -euo pipefail | ||
|
|
||
| gh release create "${GIT_TAG}" \ | ||
| --repo="${UPGRADEABLE_REPO}" \ | ||
| --title="${GIT_TAG}" \ | ||
| --target="${RELEASE_COMMIT}" \ | ||
| --notes="$(gh release view "${OLD_GIT_TAG}" --repo="${REFERENCE_REPO}" --json body -q .body)" `# TODO: Update tag before merging` \ | ||
| --prerelease="${PRERELEASE}" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
james-toussaint marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| set -euo pipefail | ||
|
|
||
| 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) | ||
| cd "contracts/" | ||
| npm publish --tag "${NPM_TAG}" | ||
Uh oh!
There was an error while loading. Please reload this page.