-
Notifications
You must be signed in to change notification settings - Fork 50
84 lines (72 loc) · 2.62 KB
/
release.yml
File metadata and controls
84 lines (72 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Specify the version'
required: false
type: string
dryRun:
description: 'Start the release with dryRun parameter'
required: true
type: boolean
default: true
jobs:
release:
strategy:
matrix:
node-version: [20]
if: (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/release') || (github.event_name == 'workflow_dispatch' && github.event.inputs.dryRun == 'true')
name: Release new version 🛠
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
issues: write
pull-requests: write
id-token: write
steps:
- name: Check out the code 🗄
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile --prefer-offline
- name: Create new version 🛠
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
pnpm exec nx release ${{ github.event.inputs.version || '' }} --skip-publish --verbose --dryRun=${{ github.event.inputs.dryRun }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sync main with release 📤
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin
git switch main
git pull origin main
git merge origin/release --ff-only -m "chore: merge release into main" --no-verify
git push origin main
- name: Build code 🛠
run: pnpm lib:build
- name: Publish new version 🛠
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
pnpm exec nx release publish --verbose --dryRun=${{ github.event.inputs.dryRun }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true