|
| 1 | +name: Manual Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_type: |
| 7 | + description: 'Release type' |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - patch |
| 12 | + - minor |
| 13 | + - major |
| 14 | + dry_run: |
| 15 | + description: 'Dry run (no actual release)' |
| 16 | + required: false |
| 17 | + type: boolean |
| 18 | + default: false |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: write |
| 22 | + issues: write |
| 23 | + pull-requests: write |
| 24 | + id-token: write |
| 25 | + |
| 26 | +jobs: |
| 27 | + manual-release: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout repository |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + fetch-depth: 0 |
| 35 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: Setup Node.js |
| 38 | + uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: 20 |
| 41 | + cache: 'npm' |
| 42 | + |
| 43 | + - name: Install dependencies |
| 44 | + run: npm ci |
| 45 | + |
| 46 | + - name: Run tests |
| 47 | + run: npm run test:coverage |
| 48 | + |
| 49 | + - name: Build package |
| 50 | + run: npm run build |
| 51 | + |
| 52 | + - name: Configure Git |
| 53 | + run: | |
| 54 | + git config user.name "github-actions[bot]" |
| 55 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 56 | +
|
| 57 | + - name: Bump version |
| 58 | + id: version |
| 59 | + run: | |
| 60 | + npm version ${{ inputs.release_type }} --no-git-tag-version |
| 61 | + NEW_VERSION=$(node -p "require('./package.json').version") |
| 62 | + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT |
| 63 | +
|
| 64 | + - name: Commit and push version bump |
| 65 | + if: ${{ !inputs.dry_run }} |
| 66 | + run: | |
| 67 | + git add package.json package-lock.json |
| 68 | + git commit -m "chore(release): v${{ steps.version.outputs.new_version }}" |
| 69 | + git tag "v${{ steps.version.outputs.new_version }}" |
| 70 | + git push origin master --tags |
| 71 | +
|
| 72 | + - name: Publish to NPM |
| 73 | + if: ${{ !inputs.dry_run }} |
| 74 | + run: npm publish --access public |
| 75 | + env: |
| 76 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 77 | + |
| 78 | + - name: Create GitHub Release |
| 79 | + if: ${{ !inputs.dry_run }} |
| 80 | + uses: softprops/action-gh-release@v2 |
| 81 | + with: |
| 82 | + tag_name: v${{ steps.version.outputs.new_version }} |
| 83 | + name: Release v${{ steps.version.outputs.new_version }} |
| 84 | + generate_release_notes: true |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + |
| 88 | + - name: Dry run summary |
| 89 | + if: ${{ inputs.dry_run }} |
| 90 | + run: | |
| 91 | + echo "🧪 Dry run completed!" |
| 92 | + echo "Would have released version: ${{ steps.version.outputs.new_version }}" |
0 commit comments