-
Notifications
You must be signed in to change notification settings - Fork 10
111 lines (98 loc) · 3.18 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Publish
on:
workflow_dispatch:
push:
tags:
- "v*"
jobs:
build_and_upload_artifacts:
name: Publish Using github
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: ["18.13"]
target: [x86_64-unknown-linux-gnu]
include:
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
steps:
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates.toml
~/.cargo/.crates2.json
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/checkout@v4
- name: Install Stable Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- run: rustup target add ${{matrix.target}}
- uses: actions-rs/[email protected]
with:
crate: nj-cli
version: latest
use-tool-cache: true
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
registry-url: "https://registry.npmjs.org"
- name: Build package
run: |
nj-cli build -o ./dist/${{matrix.target}} --release --target ${{matrix.target}}
- name: "Upload Artifact - ${{matrix.os}} for ${{matrix.target}}"
uses: actions/upload-artifact@v4
with:
name: ${{matrix.target}}
path: ./dist/${{matrix.target}}
retention-days: 5
publish-to-npm-with-artifacts:
runs-on: [macos-latest] # macos needed for lipo command
needs: [build_and_upload_artifacts]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: ./dist/
- name: size of darwin file
run: |
du -hs dist/*
ls -R ./dist
mkdir -p ./dist/{linux,darwin}
- name: Build universal dylib for macos
run: |
ls -R
lipo ./dist/x86_64-apple-darwin/index.node ./dist/aarch64-apple-darwin/index.node -create -output ./dist/darwin/index.node
rm -r ./dist/x86_64-apple-darwin/ ./dist/aarch64-apple-darwin/
- name: Build universal dylib for linux
run: |
du -hs dist/*
mv ./dist/x86_64-unknown-linux-gnu/index.node ./dist/linux/index.node
rm -r ./dist/x86_64-unknown-linux-gnu
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
registry-url: "https://registry.npmjs.org"
- name: Publish
# if: github.event_name == 'workflow_dispatch'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH }}
run: npm publish --access public
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
if: github.event_name == 'workflow_dispatch'
with:
files: ./dist/*