-
Notifications
You must be signed in to change notification settings - Fork 124
144 lines (113 loc) · 3.54 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Publish
on:
workflow_dispatch:
push:
branches: [main, publish]
pull_request:
env:
DEBUG: "napi:*"
MACOSX_DEPLOYMENT_TARGET: "10.13"
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: tiktoken-node
strategy:
matrix:
target:
- x86_64-pc-windows-msvc
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.6.1
- uses: anysphere/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd
name: Install pnpm
id: pnpm-install
with:
version: "=8.6.0"
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Run init.sh
working-directory: .
run: ./init.sh
- uses: Swatinem/rust-cache@v2
- name: Install ziglang
uses: goto-bus-stop/setup-zig@v1
with:
version: 0.10.0
- run: cargo install cargo-xwin
if: matrix.target == 'x86_64-pc-windows-msvc'
- name: Check formatting
run: cargo fmt --all --check
- name: Node install
run: pnpm i
- name: Build Mac and Linux
if: matrix.target != 'x86_64-pc-windows-msvc' && matrix.target != 'x86_64-unknown-linux-gnu'
run: pnpm run build -- --zig --target ${{ matrix.target }}
- name: Build Windows
if: matrix.target == 'x86_64-pc-windows-msvc' || matrix.target == 'x86_64-unknown-linux-gnu'
run: pnpm run build -- --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: bindings-${{ matrix.target }}
path: tiktoken-node/tiktoken-node.*.node
if-no-files-found: error
publish:
if: ${{ github.repository == 'anysphere/priompt' && github.event_name == 'push' && github.ref == 'refs/heads/publish' }}
runs-on: ubuntu-20.04
needs: build
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.6.1
- uses: anysphere/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd
name: Install pnpm
id: pnpm-install
with:
version: "=8.6.0"
- name: Run init.sh
working-directory: .
run: ./init.sh
- name: Download build
uses: actions/download-artifact@v3
with:
path: tiktoken-node/artifacts
- name: LS artifacts
run: ls -R tiktoken-node/artifacts
shell: bash
- name: Move artifacts
working-directory: tiktoken-node
run: pnpm artifacts
- name: LS post-move
run: ls -R tiktoken-node/npm
shell: bash
- name: npm version
run: npm --version
shell: bash
- name: Build priompt
working-directory: priompt
run: pnpm build
- name: Build priompt-preview
working-directory: priompt-preview
run: pnpm build
- name: globally install napi-rs
run: npm install -g @napi-rs/cli
- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish to npm
run: pnpm publish --recursive --access=public --no-git-checks