Release Package #3
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
| name: Release Package | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| package: | |
| description: "Which package to release" | |
| required: true | |
| type: choice | |
| options: | |
| - compact-builder | |
| - compact-cli | |
| - compact-simulator | |
| version_bump: | |
| description: "Version bump type" | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| release: | |
| name: Release ${{ inputs.package }} | |
| runs-on: ubuntu-24.04 | |
| environment: compact-npm-prod # Includes npm token and requires approval | |
| permissions: | |
| contents: write # Required to push commits and tags | |
| steps: | |
| - name: Get github app token | |
| uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0 | |
| id: gh-app-token | |
| with: | |
| app-id: ${{ vars.GH_APP_ID }} | |
| private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | |
| - name: Check out code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ steps.gh-app-token.outputs.token }} | |
| - name: Set package directory | |
| id: pkg | |
| run: | | |
| case "${{ inputs.package }}" in | |
| "compact-builder") | |
| echo "dir=builder" >> $GITHUB_OUTPUT | |
| ;; | |
| "compact-cli") | |
| echo "dir=cli" >> $GITHUB_OUTPUT | |
| ;; | |
| "compact-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 | |
| # Uses GitHub API to create signed commits for verification on protected branches | |
| - name: Commit version bump | |
| uses: iarekylew00t/verified-bot-commit@934fa64df2191ab067d0c0d73f422239b6933392 # v2.2.1 | |
| with: | |
| message: "Release ${{ inputs.package }} v${{ steps.version.outputs.new }}" | |
| token: ${{ steps.gh-app-token.outputs.token }} | |
| ref: ${{ github.ref_name }} | |
| files: | | |
| packages/${{ steps.pkg.outputs.dir }}/package.json | |
| - name: Create and push tag | |
| run: | | |
| git tag "${{ inputs.package }}/v${{ steps.version.outputs.new }}" | |
| git push origin "${{ 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 --provenance | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |