-
Notifications
You must be signed in to change notification settings - Fork 0
chore: migrate from release-please to semantic-release #78
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
base: main
Are you sure you want to change the base?
Changes from all commits
5e4692b
817cb21
3f0dcbe
828d43e
89611ef
0de6d18
2331597
34dbfef
7605f5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| name: Package Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| # Enable the use of OIDC for trusted publishing and npm provenance | ||
| id-token: write | ||
| # Enable the use of GitHub Packages registry | ||
| packages: write | ||
| # Enable semantic-release to publish a GitHub release and push commits | ||
| contents: write | ||
|
Member
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. [P2] Overly broad workflow permissions (Least Privilege) The workflow-level Granting these write permissions to the built-in token violates the principle of least privilege. The workflow token only needs contents: read
Member
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. This follows the pattern set out by other repos (Typist, etc.), but we can bring this up in the thread. |
||
| # Enable semantic-release to post comments on issues | ||
| issues: write | ||
| # Enable semantic-release to post comments on pull requests | ||
| pull-requests: write | ||
|
|
||
| # Release workflow steps must complete fully to avoid inconsistent state (e.g., published to | ||
| # npm but not GitHub Packages), so new workflow runs are queued until the previous one finishes. | ||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| ci-validation: | ||
| name: CI Validation | ||
| uses: ./.github/workflows/check-pull-request-health.yml | ||
|
|
||
| release-and-publish: | ||
| name: Release & Publish | ||
| needs: ci-validation | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
|
|
||
| steps: | ||
| - name: Generate bot token | ||
| id: generate_token | ||
| uses: actions/create-github-app-token@v3 | ||
| with: | ||
| app-id: ${{ secrets.DOIST_RELEASE_BOT_ID }} | ||
| private-key: ${{ secrets.DOIST_RELEASE_BOT_PRIVATE_KEY }} | ||
| permission-contents: write | ||
| permission-issues: write | ||
| permission-pull-requests: write | ||
|
|
||
| - name: Get bot user ID | ||
| id: bot_user | ||
| run: | | ||
| user_id=$(gh api "/users/${{ steps.generate_token.outputs.app-slug }}[bot]" --jq .id) | ||
| if [ -z "$user_id" ]; then | ||
| echo "Failed to get bot user ID" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "id=$user_id" >> "$GITHUB_OUTPUT" | ||
| env: | ||
| GH_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| token: ${{ steps.generate_token.outputs.token }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Prepare Node.js environment | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| cache: npm | ||
| node-version-file: .node-version | ||
| scope: '@doist' | ||
| registry-url: 'https://registry.npmjs.org/' | ||
|
|
||
| - name: Install project npm dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build package | ||
| run: npm run build | ||
|
|
||
| # The Node.js environment is prepared with the public npm registry and OIDC | ||
| # authentication for the initial semantic-release publish, after which we remove | ||
| # the Doist registry configuration and prepare the Node.js environment for the | ||
| # GitHub Packages registry, providing a predictable release workflow for both. | ||
| - name: Release and publish to public npm registry | ||
frankieyan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| id: semantic-release | ||
| run: npx semantic-release | ||
| env: | ||
| GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
| GIT_AUTHOR_NAME: ${{ steps.generate_token.outputs.app-slug }}[bot] | ||
| GIT_AUTHOR_EMAIL: ${{ steps.bot_user.outputs.id }}+${{ steps.generate_token.outputs.app-slug }}[bot]@users.noreply.github.com | ||
| GIT_COMMITTER_NAME: ${{ steps.generate_token.outputs.app-slug }}[bot] | ||
| GIT_COMMITTER_EMAIL: ${{ steps.bot_user.outputs.id }}+${{ steps.generate_token.outputs.app-slug }}[bot]@users.noreply.github.com | ||
|
|
||
| - name: Remove Doist registry configuration from .npmrc | ||
| if: ${{ steps.semantic-release.outputs.package-published == 'true' }} | ||
| run: npm config delete @doist:registry --location=project | ||
|
|
||
| - name: Prepare Node.js environment for GitHub Packages registry | ||
| if: ${{ steps.semantic-release.outputs.package-published == 'true' }} | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| cache: npm | ||
| node-version-file: .node-version | ||
| registry-url: https://npm.pkg.github.com/ | ||
| scope: '@doist' | ||
|
|
||
| - name: Publish package to GitHub Packages registry | ||
| if: ${{ steps.semantic-release.outputs.package-published == 'true' }} | ||
| run: npm publish | ||
frankieyan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.