-
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
Open
james-toussaint
wants to merge
11
commits into
OpenZeppelin:master
Choose a base branch
from
james-toussaint:chore/release-upgradeable
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8b5132b
Add workflow to release upgradeable package
james-toussaint a252b22
Add quotes
james-toussaint 870e714
Fix notes spellcheck
james-toussaint 649a635
Fetch version from contracts package.json
james-toussaint 0c2dab8
Remote fetch-depth
james-toussaint 259c56e
Merge remote-tracking branch 'upstream/master' into chore/release-upg…
james-toussaint 40a76ef
Split scripts and use trusted publisher
james-toussaint aa1b25a
Check upgradeable separately
james-toussaint b096f3b
Use vanilla dir
james-toussaint e004cb0
Merge branch 'master' into chore/release-upgradeable
james-toussaint 9581bae
Handle prerelease/release label
james-toussaint File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | ||
| 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.UPGRADEABLE_REPO }} | ||
| submodules: true | ||
| token: ${{ secrets.GH_TOKEN_UPGRADEABLE }} | ||
| ref: ${{ github.ref }} | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| repository: ${{ env.VANILLA_REPO }} | ||
| ref: ${{ github.ref }} | ||
| path: vanilla | ||
| - id: vanilla | ||
| name: Get vanilla commit | ||
| run: cd vanilla && echo "commit=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" | ||
| - uses: actions/checkout@v5 # TODO: Remove this before merging (used to get scripts added in this PR) | ||
| with: | ||
| path: vanilla | ||
| - name: Set up environment | ||
| uses: ./vanilla/.github/actions/setup | ||
| - id: check-upgradeable | ||
| name: Check upgradeable | ||
| run: bash vanilla/scripts/release/workflow/check-upgradeable.sh | ||
| env: | ||
| VANILLA_COMMIT: ${{ steps.vanilla.outputs.commit }} | ||
| - id: publish | ||
| name: Publish | ||
| run: bash vanilla/scripts/release/workflow/publish-upgradeable.sh | ||
| env: | ||
| NPM_TAG: ${{ steps.check-upgradeable.outputs.npm_tag }} | ||
| - name: Create Github Release Note | ||
| run: bash vanilla/scripts/release/workflow/github-release-upgradeable.sh | ||
| 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 }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ${VANILLA_COMMIT}"; then | ||
| echo "Expected 'Transpile ${VANILLA_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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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="${VANILLA_REPO}" --json body -q .body)" `# TODO: Update tag before merging` \ | ||
| --prerelease="${PRERELEASE}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.