-
Notifications
You must be signed in to change notification settings - Fork 2
66 lines (54 loc) · 1.8 KB
/
publish-package.yaml
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
name: Create Tag and Publish Package
on:
pull_request:
branches:
- main
types:
- closed
permissions:
contents: write
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_VERSION: 20.13.1
jobs:
tag-and-publish-package:
name: Create Tag and Publish Package
runs-on: ubuntu-latest
# Only run this job if an actual publishing should be made
if: ${{ (github.event.pull_request.merged == true) &&
(startsWith(github.event.pull_request.head.ref, 'release/')) &&
(contains(github.event.pull_request.labels.*.name, 'release')) }}
steps:
- name: Extract package from head ref
id: extract_package
# yamllint disable-line rule:line-length
run: echo "package=$(echo ${{ github.event.pull_request.head.ref }} | grep -oP '(?<=release/)[^@]+(?=@)')" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
with:
filter: 'blob:none'
fetch-depth: 0
fetch-tags: true
- name: Configure git User
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
- name: Create tag
run: |
npx nx release version \
--projects=${{ steps.extract_package.outputs.package }} \
--git-commit=false \
--git-tag=true
- name: Publish package
run: |
npx nx release publish \
--projects=${{ steps.extract_package.outputs.package }}
- name: Push tags
run: git push origin --follow-tags