| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- name: Release & Publish
- on:
- push:
- tags:
- - 'v*'
- workflow_dispatch:
- inputs:
- version:
- description: 'Version to release (e.g., 1.2.3)'
- required: true
- type: string
- permissions:
- contents: write
- packages: write
- jobs:
- release:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Use Node.js 20.x
- uses: actions/setup-node@v4
- with:
- node-version: '20.x'
- registry-url: 'https://registry.npmjs.org'
- cache: 'npm'
-
- - name: Install dependencies
- run: npm ci
-
- - name: Run tests
- run: npm test
-
- - name: Run linter
- run: npm run lint
-
- - name: Build
- run: npm run build
-
- - name: Set version from input
- if: github.event_name == 'workflow_dispatch'
- run: |
- npm version ${{ github.event.inputs.version }} --no-git-tag-version
- echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV
-
- - name: Set version from tag
- if: github.event_name == 'push'
- run: |
- echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- npm version ${GITHUB_REF#refs/tags/v} --no-git-tag-version
-
- - name: Create Release
- uses: softprops/action-gh-release@v2
- with:
- tag_name: ${{ env.VERSION }}
- name: Release ${{ env.VERSION }}
- body: |
- ## What's Changed
-
- **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...${{ env.VERSION }}
- draft: false
- prerelease: false
-
- - name: Publish to npm
- run: npm publish
- env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
-
- - name: Commit version bump
- if: github.event_name == 'workflow_dispatch'
- run: |
- git config --global user.name 'github-actions[bot]'
- git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- git add package.json package-lock.json
- git commit -m "chore: bump version to ${{ github.event.inputs.version }}"
- git push
|