-
Notifications
You must be signed in to change notification settings - Fork 3
ci: migrate releases to semantic-release #59
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: next
Are you sure you want to change the base?
Changes from all commits
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,23 @@ | ||
| name: Semantic Pull Request | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: | ||
| - edited | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| validate-title: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Validate pull request title | ||
| uses: amannn/action-semantic-pull-request@01d5fd8a8ebb9aafe902c40c53f0f4744f7381eb | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,50 @@ | ||
| name: Release @doist/react-interpolate package | ||
|
|
||
| on: | ||
| release: | ||
| types: [created] | ||
| workflow_dispatch: | ||
| push: | ||
|
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] Switching this workflow to every push on |
||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| # Enable the use of OIDC for trusted publishing and npm provenance | ||
| contents: write | ||
| issues: write | ||
| pull-requests: write | ||
| id-token: write | ||
| # Enable the use of GitHub Packages registry | ||
| packages: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - name: Generate release bot token | ||
| id: release-bot | ||
| if: ${{ secrets.DOIST_RELEASE_BOT_ID != '' && secrets.DOIST_RELEASE_BOT_PRIVATE_KEY != '' }} | ||
| 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 | ||
|
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. [P1] GitHub App permissions use an underscore ( |
||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ steps.release-bot.outputs.token || github.token }} | ||
|
|
||
| - name: Setup Node.js from .node-version | ||
| uses: actions/setup-node@v3 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| cache: npm | ||
| node-version-file: .node-version | ||
| registry-url: https://registry.npmjs.org/ | ||
| scope: "@doist" | ||
|
|
||
| - name: Ensure npm 11.5.1 or later is installed | ||
| run: npm install -g npm@latest | ||
|
|
@@ -35,26 +57,39 @@ jobs: | |
| env: | ||
| CI: true | ||
|
|
||
| - name: Test the codebase | ||
|
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] This extends the same checkout/setup/install/check/test/build sequence that's already defined in |
||
| run: npm run test | ||
| env: | ||
| CI: true | ||
|
|
||
| - name: Build the codebase | ||
| run: npm run build | ||
|
|
||
| - name: Publish to GitHub Package Registry | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version-file: .node-version | ||
| registry-url: https://npm.pkg.github.com/ | ||
| scope: "@doist" | ||
| - run: npm publish | ||
| - name: Publish package to npm registry | ||
| id: semantic-release | ||
| run: npx semantic-release | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GITHUB_TOKEN: ${{ steps.release-bot.outputs.token || github.token }} | ||
|
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. [P0] |
||
| GIT_AUTHOR_EMAIL: doistbot@users.noreply.github.com | ||
| GIT_AUTHOR_NAME: Doist Bot | ||
| GIT_COMMITTER_EMAIL: doistbot@users.noreply.github.com | ||
| GIT_COMMITTER_NAME: Doist Bot | ||
|
|
||
| - name: Clear npm config between GitHub/npm registries | ||
| run: rm -f $NPM_CONFIG_USERCONFIG | ||
| - name: Clear npm config between registries | ||
| if: ${{ steps.semantic-release.outputs.package-published == 'true' }} | ||
|
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. [P1] This gate makes the GitHub Packages publish non-retryable. If |
||
| run: rm -f "$NPM_CONFIG_USERCONFIG" | ||
|
|
||
| - name: Publish to npm registry | ||
| uses: actions/setup-node@v3 | ||
| - name: Setup GitHub Packages registry | ||
| if: ${{ steps.semantic-release.outputs.package-published == 'true' }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| cache: npm | ||
|
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. [P3] Dependencies are already cached and installed by the first |
||
| node-version-file: .node-version | ||
| registry-url: https://registry.npmjs.org/ | ||
| registry-url: https://npm.pkg.github.com/ | ||
| scope: "@doist" | ||
| - run: npm publish --provenance --access public | ||
|
|
||
| - name: Publish package to GitHub Packages | ||
| if: ${{ steps.semantic-release.outputs.package-published == 'true' }} | ||
| run: npm publish | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ github.token }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Per the Secrets Management standard, workflows triggered by pull requests from forks should not have access to secrets to prevent potential exfiltration. While this workflow currently doesn't check out fork code, using
pull_request_targetexposes repository secrets to the run context and creates a security risk if the workflow is later modified. Change this topull_request, which safely runs with a read-only token and is fully sufficient for validating PR titles.