-
Notifications
You must be signed in to change notification settings - Fork 3
88 lines (74 loc) · 2.54 KB
/
publish-npm.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
on:
workflow_run:
workflows: [Test JS bindings]
types: [completed]
branches: [master]
name: Build and publish to NPM
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
container: ghcr.io/kanaverse/emcmake-docker/builder:master
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 18
# We only run the remaining (remote-touching) steps if the version has actually changed.
- name: Extract package versions
shell: bash
run: |
current_version=$(npm pkg get version | sed 's/"//g')
echo "NEW_SCRANJS_VERSION=${current_version}" >> $GITHUB_ENV
old_version=$(npm view scran.js version)
update=0 && [[ $old_version != $current_version ]] && update=1
echo "UPDATE_SCRANJS=${update}" >> $GITHUB_ENV
echo "Current version is ${current_version} (published ${old_version})"
- name: Cache installed
if: env.UPDATE_SCRANJS == 1
uses: actions/cache@v4
with:
path: extern/installed
key: deps-${{ hashFiles('extern/**/build.sh') }}-${{ env.IMAGE_VERSION }}
- name: Cache Modules
if: env.UPDATE_SCRANJS == 1
uses: actions/cache@v4
with:
path: '**/node_modules'
key: npm-${{ hashFiles('package.json') }}
- name: Update NPM packages
if: env.UPDATE_SCRANJS == 1
run: npm i --include=dev
- name: Update node build
if: env.UPDATE_SCRANJS == 1
run: bash build.sh main
- name: Update browser build
if: env.UPDATE_SCRANJS == 1
run: bash build.sh browser
- name: Cache RDS files
if: env.UPDATE_SCRANJS == 1
uses: actions/cache@v4
with:
path: tests/rds/*.rds
key: rds-${{ hashFiles('tests/rds/generate.R') }}
- name: Double-checking tests
if: env.UPDATE_SCRANJS == 1
run: CHECK_RDS=1 npm run test
- name: Publish to NPM
if: env.UPDATE_SCRANJS == 1
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Tagging the release
if: env.UPDATE_SCRANJS == 1
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/' + process.env.NEW_SCRANJS_VERSION,
sha: context.sha
})