-
Notifications
You must be signed in to change notification settings - Fork 1
Add release workflow #19
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
Changes from 18 commits
e454b34
5bd566e
cac2427
e7e47fe
34983fe
769a860
0ef2ab4
4322f13
565d772
3e93b14
0cb64f7
1d6d87c
15907a1
4a9eca6
1f0c57a
02451e7
714f4b9
225f9d0
0f40e4a
bbfa51c
8f956fa
461e235
fcfcdb7
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,94 @@ | ||
| name: Release Package | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| package: | ||
| description: "Which package to release" | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - compact-tools-cli | ||
| - compact-tools-simulator | ||
| version_bump: | ||
| description: "Version bump type" | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - patch | ||
| - minor | ||
| - major | ||
|
|
||
| permissions: | ||
| contents: write # Required to push commits and tags | ||
|
|
||
| env: | ||
| TURBO_TELEMETRY_DISABLED: 1 | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Release ${{ inputs.package }} | ||
| runs-on: ubuntu-24.04 | ||
| environment: compact-npm-prod # Requires approval | ||
|
|
||
| env: | ||
| COMPACT_INSTALLER_URL: ${{ vars.COMPACT_INSTALLER_URL }} | ||
|
|
||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set package directory | ||
| id: pkg | ||
| run: | | ||
| case "${{ inputs.package }}" in | ||
| "compact-tools-cli") | ||
| echo "dir=cli" >> $GITHUB_OUTPUT | ||
| ;; | ||
| "compact-tools-simulator") | ||
| echo "dir=simulator" >> $GITHUB_OUTPUT | ||
| ;; | ||
| esac | ||
|
|
||
| - name: Setup Environment | ||
| uses: ./.github/actions/setup | ||
|
|
||
| - name: Run tests for package | ||
| run: yarn test --filter=@openzeppelin/${{ inputs.package }} | ||
|
|
||
| - name: Build package | ||
| run: yarn build --filter=@openzeppelin/${{ inputs.package }} | ||
|
|
||
| - name: Bump version | ||
| id: version | ||
| run: | | ||
| cd packages/${{ steps.pkg.outputs.dir }} | ||
| yarn version ${{ inputs.version_bump }} | ||
| NEW_VERSION=$(node -p "require('./package.json').version") | ||
| echo "new=$NEW_VERSION" >> $GITHUB_OUTPUT | ||
| echo "### Release Summary" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Package: ${{ inputs.package }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- New version: $NEW_VERSION" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Bump type: ${{ inputs.version_bump }}" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| - name: Verify package contents | ||
| run: | | ||
| cd packages/${{ steps.pkg.outputs.dir }} | ||
| yarn pack --dry-run | ||
|
|
||
| - name: Commit and tag version bump | ||
| uses: stefanzweifel/git-auto-commit-action@28e16e81777b558cc906c8750092100bbb34c5e3 # v7.0.0 | ||
| with: | ||
| commit_message: "chore: release ${{ inputs.package }} v${{ steps.version.outputs.new }}" | ||
| file_pattern: "packages/${{ steps.pkg.outputs.dir }}/package.json" | ||
| tagging_message: "${{ inputs.package }}/v${{ steps.version.outputs.new }}" | ||
|
|
||
| - name: Publish to npm | ||
| run: | | ||
| yarn config set npmAuthToken "$NPM_TOKEN" | ||
| cd packages/${{ steps.pkg.outputs.dir }} | ||
| yarn npm publish --access public | ||
|
||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
Contributor
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. I hope we can switch this off and use Trusted Publishing with OIDC auth later. Yarn should support it (yarnpkg/berry#6898, yarnpkg/berry#6911) 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. Just to be clear, You need to first publish the package and then enable OIDC for the subsequent versions. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Releasing | ||
|
|
||
| 1. Go to "Release Package" in Actions. | ||
| 2. Click on the "Run workflow" dropdown menu. | ||
| 3. Choose the package to release and the version bump type. | ||
|
Contributor
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. it looks like this will run on |
||
|
|
||
| Following [SemVer](https://semver.org/): | ||
| - **Patch** - Backward compatible bug fixes. | ||
| - **Minor** - New functionality in a backward compatible way. | ||
| - **Major** - Breaking API changes. | ||
|
|
||
| 4. A maintainer must approve the release before it proceeds. | ||
|
|
||
| 5. Once approved, the CI will automatically: | ||
| - Run tests. | ||
| - Bump the version. | ||
| - Create a git tag. | ||
| - Publish the package to npm. | ||
|
|
||
| 6. Once published, go to "Releases" and create a GitHub release using the generated tag. | ||
|
Contributor
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 could automate this too, perhaps a future improvement?
Contributor
Author
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. Tracking here #30 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. Just FYI, If you guys haven't seen it, you can check how we are managing this using changesets here https://github.com/OpenZeppelin/relayer-plugin-channels/tree/main/.github/workflows. We pretty much standardized using changesets across all ts/js repos publishing to npm. Something to improve. |
||
Uh oh!
There was an error while loading. Please reload this page.