This repository has been archived by the owner on Nov 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (89 loc) · 2.62 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Reusable publish workflow for open-source NPM packages
# - dual publication (to NPM, then GitHub)
# - single package per repo (no mono-repo support)
name: publish
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- run: npm ci
- name: Establish Version
run: |
release='${{ github.event.release.tag_name }}'
version=`echo $release | cut -b2-`
if ! echo $release | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$'; then
echo "Release name must be in the format of 'vX.Y.Z[-anything]', got '$release'"
exit 1
fi
jq --arg version $version '.version = $version' package.json > package.json.tmp && mv package.json.tmp package.json
- name: Build Distributables
run: npm run build
- uses: actions/upload-artifact@v3
with:
name: package.json
path: package.json
- uses: actions/upload-artifact@v3
with:
name: lib
path: lib
publish-github:
needs: build
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: https://npm.pkg.github.com/
- uses: actions/download-artifact@v3
with:
name: package.json
- uses: actions/download-artifact@v3
with:
name: lib
path: lib
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
publish-npmjs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- uses: actions/download-artifact@v3
with:
name: package.json
- uses: actions/download-artifact@v3
with:
name: lib
path: lib
- name: Establish NPM Scope
run: |
jq --arg name '@appfolio/react-gears-cypress' '.name = $name' package.json > package.json.tmp && mv package.json.tmp package.json
- name: Publish to NPM
run: |
touch $HOME/.npmrc
chmod 0600 $HOME/.npmrc
cat << EOF > ~/.npmrc
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
@appfolio:registry=https://registry.npmjs.org/
EOF
npm publish
env:
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"