-
Notifications
You must be signed in to change notification settings - Fork 19
52 lines (45 loc) · 1.48 KB
/
publish.yml
File metadata and controls
52 lines (45 loc) · 1.48 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
name: Publish package on NPM
permissions:
contents: write
on:
release:
types:
- prereleased
- released
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Releasing tag ${{ github.event.release.tag_name }}
run: |
corepack enable; yarn
# Get tag name from event
tag_name="${{ github.event.release.tag_name }}"
if [[ ! "$tag_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
cd $(echo $tag_name | rev | cut -d'/' -f2- | rev)
fi
yarn_major_version=$(yarn --version | cut -d'.' -f1)
if [ "$yarn_major_version" -ge 2 ] && [ "$yarn_major_version" -le 4 ]; then
cmd="yarn npm publish --access public"
elif [ "$yarn_major_version" -eq 1 ]; then
cmd="yarn publish --access public"
else
echo "Unsupported Yarn version: $yarn_major_version"
exit 1
fi
if [ "${{ github.event.release.prerelease }}" == "true" ]; then
cmd+=" --tag=beta"
else
cmd+=" --tag=latest"
fi
eval $cmd
env:
NPM_AUTH_TOKEN: ${{ secrets.YARN_NPM_AUTH_TOKEN }}
YARN_NPM_AUTH_TOKEN: ${{ secrets.YARN_NPM_AUTH_TOKEN }}
COREPACK_ENABLE_DOWNLOAD_PROMPT: 0