|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: 'Exact version to release (e.g. 1.2.3). Leave empty to auto-bump.' |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + preid: |
| 14 | + description: 'Pre-release identifier (e.g. beta, rc). Optional' |
| 15 | + required: false |
| 16 | + type: string |
| 17 | + npm_tag: |
| 18 | + description: 'npm dist-tag (e.g. latest, beta)' |
| 19 | + required: false |
| 20 | + default: 'latest' |
| 21 | + type: string |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: write |
| 25 | + id-token: write |
| 26 | + |
| 27 | +jobs: |
| 28 | + ci: |
| 29 | + name: CI |
| 30 | + uses: ./.github/workflows/ci.yml |
| 31 | + with: |
| 32 | + full: true |
| 33 | + |
| 34 | + release: |
| 35 | + name: Release & Publish |
| 36 | + runs-on: ubuntu-latest |
| 37 | + needs: ci |
| 38 | + steps: |
| 39 | + - name: Checkout repository |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + fetch-depth: 0 |
| 43 | + fetch-tags: true |
| 44 | + |
| 45 | + - name: Use Node.js |
| 46 | + uses: actions/setup-node@v4 |
| 47 | + with: |
| 48 | + node-version: 20 |
| 49 | + cache: 'npm' |
| 50 | + registry-url: 'https://registry.npmjs.org' |
| 51 | + always-auth: true |
| 52 | + |
| 53 | + - name: Install dependencies |
| 54 | + run: npm ci |
| 55 | + |
| 56 | + - name: Configure Git user |
| 57 | + run: | |
| 58 | + git config user.name "github-actions[bot]" |
| 59 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 60 | +
|
| 61 | + - name: Run release-it |
| 62 | + env: |
| 63 | + DEBUG: release-it:*,@release-it/* |
| 64 | + HUSKY: 0 |
| 65 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 67 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 68 | + run: | |
| 69 | + VERSION_ARG="" |
| 70 | + if [ -n "${{ inputs.version }}" ]; then |
| 71 | + VERSION_ARG="${{ inputs.version }}" |
| 72 | + fi |
| 73 | +
|
| 74 | + PREID_ARG="" |
| 75 | + if [ -n "${{ inputs.preid }}" ]; then |
| 76 | + PREID_ARG="--preRelease=${{ inputs.preid }}" |
| 77 | + fi |
| 78 | +
|
| 79 | + if [ -n "${{ inputs.npm_tag }}" ]; then |
| 80 | + NPM_TAG="${{ inputs.npm_tag }}" |
| 81 | + else |
| 82 | + NPM_TAG="latest" |
| 83 | + fi |
| 84 | + NPM_TAG_ARG="--npm.tag=${NPM_TAG}" |
| 85 | +
|
| 86 | + npm run release -- --ci $PREID_ARG $NPM_TAG_ARG $VERSION_ARG |
| 87 | +
|
| 88 | + - name: Sync main → develop |
| 89 | + uses: devmasx/merge-branch@v1.4.0 |
| 90 | + with: |
| 91 | + type: now |
| 92 | + from_branch: main |
| 93 | + target_branch: develop |
| 94 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + env: |
| 96 | + HUSKY: 0 |
| 97 | + |
0 commit comments