Skip to content
72 changes: 72 additions & 0 deletions .github/workflows/release-upgradeable.yml
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
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
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)"
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the vanilla release cycle workflow we pack first and then we publish. This allows to gather environmental values as output from the job (see the pack script). I would suggest doing the same here so that we can isolate the npm publish command and also run an integrity check

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steps have been scoped, lmk.

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
bash scripts/git-user-config.sh
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 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wouldn't need the NPM_TOKEN if we're using trusted publishers. See #6009

I just added the trusted publisher for the upgradeable package:
Captura de pantalla 2025-10-29 a la(s) 4 02 37 p m

Suggested change
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Also, I think this would fail because the NPM_TOKEN is only available in the npm environment

Copy link
Collaborator Author

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:

- name: Create Github Release Note
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_UPGRADEABLE }}
run: |
gh release create "${GIT_TAG}" \
--repo="${UPGRADEABLE_REPO}" \
--title="${GIT_TAG}" \
--notes="$(gh release view "${OLD_GIT_TAG}" --repo="${VANILLA_REPO}" --json body -q .body)" `# TODO: Update tag before merging` \
"${ADDITIONAL_OPTION_IF_PRERELEASE}"
Copy link
Member

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

Copy link
Collaborator Author

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.