Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,29 @@ jobs:
echo "Current version: $CURRENT_VERSION"
echo "New version: $NEW_VERSION"

# Update package.json version field manually
yarn workspace @openzeppelin/compact-contracts version "$NEW_VERSION"
# Update package.json version field
node -e '
const fs = require("fs");
const path = "./contracts/package.json";
const pkg = JSON.parse(fs.readFileSync(path, "utf8"));
pkg.version = process.env.NEW_VERSION;
fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + "\n");
'

# Escape special characters for sed
ESCAPED_CURRENT=$(printf '%s' "$CURRENT_VERSION" | sed -e 's/[\/&]/\\&/g')
ESCAPED_NEW=$(printf '%s' "$NEW_VERSION" | sed -e 's/[\/&]/\\&/g')

# Pattern to match version + optional prerelease (-alpha.1) and build (+build) suffixes
VERSION_SUFFIX='(-[A-Za-z0-9.]+)?(\+[A-Za-z0-9.]+)?'

# Replace version in contracts/src/
find ./contracts/src/ -type d -name '.*' -prune -o \
-type f -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} +
-type f -exec sed -Ei "s#${ESCAPED_CURRENT}${VERSION_SUFFIX}#$ESCAPED_NEW#g" {} +

# Replace version in docs/, excluding package-lock.json
find ./docs/ -type d -name '.*' -prune -o \
-type f ! -name 'package-lock.json' -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} +
-type f ! -name 'package-lock.json' -exec sed -Ei "s#${ESCAPED_CURRENT}${VERSION_SUFFIX}#$ESCAPED_NEW#g" {} +

- name: Auto-commit changes
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 #v6.0.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Publish to npm
run: |
# Publish the tarball with appropriate tag
npm publish "${{ steps.pack.outputs.tarball }}" --tag "${{ steps.pack.outputs.tag }}" --access public --provenance
npm publish "${{ steps.pack.outputs.tarball }}" --tag "${{ steps.pack.outputs.tag }}" --access public
env:
NPM_CONFIG_PROVENANCE: true
Comment on lines 85 to 86
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
env:
NPM_CONFIG_PROVENANCE: true

I don't think this is required since npm automatically generates and publishes provenance attestations for packages that use trusted publishers eg GitHub Actions w/ GitHub-hosted runners. However, I can see how it improves code clarity by making it explicit. Up to you if we should keep it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean either the flag or env, right? Personally, I prefer the flag but no strong opinions. I'm good with it as-is so long as it works haha

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure neither are required if trusted publishing is configured in NPM, but I don't have access so I can't tell if it's been configured by IT or not sooooo if it works right now probably best to leave as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmmm yes, you are correct. Agreed, we can improve this in another PR


Expand Down
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openzeppelin/compact-contracts",
"version": "0.0.1",
"version": "0.0.1-alpha.0",
"description": "OpenZeppelin Compact contract library",
"keywords": [
"openzeppelin",
Expand Down
Loading