[1.0.4] - 2026-01-30 #5
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: Publish to npm and create GitHub Release | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| jobs: | |
| release: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| actions: write | |
| id-token: write | |
| packages: write | |
| pull-requests: write | |
| steps: | |
| - name: Generate token from GitHub App | |
| id: generate_token | |
| uses: actions/create-github-app-token@v1 | |
| with: | |
| app-id: ${{ secrets.APP_ID }} | |
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ steps.generate_token.outputs.token }} | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org/ | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Determine version bump | |
| id: version_type | |
| run: | | |
| if [[ "${{ github.event.pull_request.title }}" == *"major"* ]]; then | |
| echo "BUMP_TYPE=major" >> $GITHUB_ENV | |
| elif [[ "${{ github.event.pull_request.title }}" == *"minor"* ]]; then | |
| echo "BUMP_TYPE=minor" >> $GITHUB_ENV | |
| else | |
| echo "BUMP_TYPE=patch" >> $GITHUB_ENV | |
| fi | |
| - name: Configure Git | |
| run: | | |
| git config user.name "TODOvue-release[bot]" | |
| git config user.email "TODOvue-release[bot]@users.noreply.github.com" | |
| git config url."https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/".insteadOf "https://github.com/" | |
| - name: Bump version and push | |
| id: bump | |
| run: | | |
| npm version $BUMP_TYPE -m "chore(release): 🔥 v%s [skip ci]" | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| git push origin main --follow-tags | |
| env: | |
| GIT_AUTHOR_NAME: "TODOvue-release[bot]" | |
| GIT_AUTHOR_EMAIL: "TODOvue-release[bot]@users.noreply.github.com" | |
| GIT_COMMITTER_NAME: "TODOvue-release[bot]" | |
| GIT_COMMITTER_EMAIL: "TODOvue-release[bot]@users.noreply.github.com" | |
| - name: Build package | |
| run: npm run build | |
| - name: Publish to npm | |
| run: npm publish --access public --provenance | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ steps.generate_token.outputs.token }} | |
| script: | | |
| await github.rest.repos.createRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: `v${{ steps.bump.outputs.NEW_VERSION }}`, | |
| name: `v${{ steps.bump.outputs.NEW_VERSION }}`, | |
| body: 'For stable releases, please refer to [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details.', | |
| draft: false, | |
| prerelease: false | |
| }); |