Skip to content

Commit 41d6ded

Browse files
authored
Merge pull request #143 from verhovsky/github-actions
Publish to npm through GitHub Actions
2 parents 3224eef + 811a705 commit 41d6ded

File tree

1 file changed

+29
-33
lines changed

1 file changed

+29
-33
lines changed

.github/workflows/build.yml

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ on:
77
pull_request:
88
branches:
99
- master
10+
release:
11+
types:
12+
- released
1013

1114
env:
12-
NODE_PREBUILD_CMD: npx prebuild -t 10.0.0 -t 12.0.0 -t 14.0.0 -t 16.0.0 -t 18.0.0 -t 20.0.0 --strip
13-
ELECTRON_PREBUILD_CMD: npx prebuild -r electron -t 3.0.0 -t 4.0.0 -t 5.0.0 -t 6.0.0 -t 7.0.0 -t 8.0.0 -t 9.0.0 -t 10.0.0 -t 11.0.0 -t 12.0.0 -t 13.0.0 -t 14.0.0 -t 15.0.0 -t 16.0.0 -t 17.0.0 -t 18.0.0 -t 19.0.0 -t 20.0.0 -t 21.0.0 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.0.0 --strip
15+
NODE_PREBUILD_CMD: npx prebuild -t 10.0.0 -t 12.0.0 -t 14.0.0 -t 16.0.0 -t 18.0.0 -t 20.0.0 --strip -u ${{ secrets.GH_TOKEN }}
16+
ELECTRON_PREBUILD_CMD: npx prebuild -r electron -t 3.0.0 -t 4.0.0 -t 5.0.0 -t 6.0.0 -t 7.0.0 -t 8.0.0 -t 9.0.0 -t 10.0.0 -t 11.0.0 -t 12.0.0 -t 13.0.0 -t 14.0.0 -t 15.0.0 -t 16.0.0 -t 17.0.0 -t 18.0.0 -t 19.0.0 -t 20.0.0 -t 21.0.0 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.0.0 --strip -u ${{ secrets.GH_TOKEN }}
1417

1518
jobs:
1619

@@ -43,55 +46,48 @@ jobs:
4346
- run: npm install
4447
- run: npm test
4548

49+
publish:
50+
if: ${{ github.event_name == 'release' }}
51+
name: Publish to npm
52+
runs-on: ubuntu-latest
53+
needs: test
54+
steps:
55+
- uses: actions/checkout@v3
56+
with:
57+
submodules: true
58+
fetch-depth: 0
59+
- uses: actions/setup-node@v3
60+
with:
61+
node-version: 20
62+
registry-url: https://registry.npmjs.org
63+
- run: npm install
64+
- run: npm publish --access public
65+
env:
66+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
67+
4668
prebuild:
4769
strategy:
4870
matrix:
4971
os:
5072
- windows-2019
5173
- macos-latest
5274
- ubuntu-latest
53-
node:
54-
# Node 10-14 fails to prebuild for Node 18+
55-
#
56-
# macos-latest's Python version is too new to work with the node-gyp
57-
# bundled by prebuild and the "overrides" in package.json for node-gyp
58-
# doesn't work before npm 8.3 (Node 16)
59-
#
60-
# ubuntu-latest has a similar issue but in this case the error is more direct:
61-
# #error "It looks like you are building this native module without
62-
# using the right config.gypi. This normally means that you need to
63-
# update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're
64-
# building modules directly."
65-
#
66-
# windows-2019 fails with
67-
# gyp: name 'llvm_version' is not defined while evaluating condition
68-
# 'llvm_version=="0.0"' in binding.gyp while trying to load binding.gyp
69-
# - 10
70-
# - 12
71-
# - 14
72-
- 16
73-
- 18
74-
- 20
7575
fail-fast: false
76-
name: Prebuild with Node ${{ matrix.node }} on ${{ matrix.os }}
76+
name: Prebuild for ${{ matrix.os }}
7777
runs-on: ${{ matrix.os }}
78-
# needs: test
78+
needs: publish
7979
steps:
8080
- uses: actions/checkout@v3
8181
with:
8282
submodules: true
8383
fetch-depth: 0
8484
- uses: actions/setup-node@v3
8585
with:
86-
node-version: ${{ matrix.node }}
86+
node-version: 20
8787
- run: npm install
88-
- if: matrix.os == 'windows-latest'
89-
run: ${{ env.NODE_PREBUILD_CMD }} --arch ia32
90-
- if: matrix.os == 'windows-latest'
91-
run: ${{ env.ELECTRON_PREBUILD_CMD }} --arch ia32
92-
- if: matrix.os == 'macos-latest'
88+
- if: runner.os == 'macOS'
9389
run: ${{ env.NODE_PREBUILD_CMD }} --arch arm64
94-
- if: matrix.os == 'macos-latest'
90+
- if: runner.os == 'macOS'
9591
run: ${{ env.ELECTRON_PREBUILD_CMD }} --arch arm64
9692
- run: ${{ env.NODE_PREBUILD_CMD }}
9793
- run: ${{ env.ELECTRON_PREBUILD_CMD }}

0 commit comments

Comments
 (0)