-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (68 loc) · 2.23 KB
/
npm-publish-beta.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
name: NPM Publish@beta
on:
push:
branches:
- main
jobs:
check_pkg_version:
runs-on: ubuntu-latest
outputs:
publishBeta: ${{ steps.compare.outputs.publishBinary }}
steps:
- name: "checkout"
uses: actions/checkout@v3
- name: "setup node"
uses: actions/setup-node@v3
with:
node-version: '14'
registry-url: 'https://registry.npmjs.org'
- run: npm i semver-compare-cli
- id: "compare"
name: "compare local/live package versions"
run: |
echo '::echo::on'
SHOULD_PUBLISH=0
PKG_VERSION_LOCAL=`cat package.json | jq -r '.version'`
echo 'local pkg: '$PKG_VERSION_LOCAL
PKG_VERSION_PUBLISHED=`npm view @thencc/algonautjs@beta version`
echo 'beta pkg: '$PKG_VERSION_PUBLISHED
npx semver-compare $PKG_VERSION_LOCAL gt $PKG_VERSION_PUBLISHED && SHOULD_PUBLISH=1
echo 'publish beta?: '$SHOULD_PUBLISH
if [[ $SHOULD_PUBLISH ]] ; then echo "WILL npm publish beta"; else echo "NO npm publish needed" ; fi
echo "::set-output name=publishBinary::$SHOULD_PUBLISH"
# check_job_output:
# needs: [ check_pkg_version ]
# runs-on: ubuntu-latest
# steps:
# - run: |
# echo '::echo::on'
# echo "hello world"
# echo ${{ needs.check_pkg_version.outputs.publishBeta }}
publish:
needs: [ check_pkg_version ]
if: needs.check_pkg_version.outputs.publishBeta == 1
runs-on: ubuntu-latest
steps:
- name: "checkout"
uses: actions/checkout@v3
- name: "setup node"
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
# creates an .npmrc
- name: "setup pnpm"
uses: pnpm/[email protected]
with:
version: 8.5.0
# auto install on use
run_install: |
args: [--no-frozen-lockfile, --strict-peer-dependencies]
- name: "build"
run: pnpm run build
- name: "publish"
run: |
npm config set registry https://registry.npmjs.org/
npm publish --access public --tag beta --greater-version-only
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}