-
Notifications
You must be signed in to change notification settings - Fork 4
62 lines (53 loc) · 2.03 KB
/
publish.yml
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
name: Publish package
on:
push:
tags: ["v*"]
jobs:
publish-npm:
name: Publish to npm
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
registry-url: "https://registry.npmjs.org"
- name: Get semver from tag
run: |
RELEASE_VERSION=${GITHUB_REF#refs/*/}
NPM_TAG=$(echo ${RELEASE_VERSION} | grep -oP '^v\d+\.\d+\.\d+-?\K(\w+)?')
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
echo "NPM_TAG=${NPM_TAG:-latest}" >> $GITHUB_ENV
- name: Publish
# pnpm checks whether you are on the main branch when running publish,
# but github will checkout the tag, so we need to disable the check
run: |
pnpm --recursive npm-version --no-git-tag-version ${{ env.RELEASE_VERSION }}
pnpm --recursive publish --no-git-checks --access public --tag ${{ env.NPM_TAG }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-github:
name: Publish to GitHub
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
registry-url: "https://npm.pkg.github.com"
- name: Get semver from tag
run: |
RELEASE_VERSION=${GITHUB_REF#refs/*/}
NPM_TAG=$(echo ${RELEASE_VERSION} | grep -oP '^v\d+\.\d+\.\d+-?\K(\w+)?')
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
echo "NPM_TAG=${NPM_TAG:-latest}" >> $GITHUB_ENV
- name: Publish
# pnpm checks whether you are on the main branch when running publish,
# but github will checkout the tag, so we need to disable the check
run: |
pnpm --recursive npm-version --no-git-tag-version ${{ env.RELEASE_VERSION }}
pnpm --recursive publish --no-git-checks --access public --tag ${{ env.NPM_TAG }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}