Skip to content

Commit bd2fe8c

Browse files
committed
chore: Add NPM packages and workflow
1 parent c4b89e1 commit bd2fe8c

File tree

12 files changed

+3882
-15
lines changed

12 files changed

+3882
-15
lines changed

.github/workflows/cd.yml

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,73 @@ jobs:
3030
strategy:
3131
matrix:
3232
include:
33-
- target: aarch64-apple-darwin
33+
- name: darwin-arm64
34+
target: aarch64-apple-darwin
3435
os: macos-13
35-
- target: x86_64-unknown-linux-gnu
36+
- name: linux-x64-glibc
37+
target: x86_64-unknown-linux-gnu
3638
os: ubuntu-22.04
37-
- target: x86_64-apple-darwin
39+
- name: darwin-x64
40+
target: x86_64-apple-darwin
3841
os: macos-13
39-
- target: x86_64-pc-windows-msvc
42+
- name: win32-x64-msvc
43+
target: x86_64-pc-windows-msvc
4044
os: windows-2022
4145
timeout-minutes: 60
4246
steps:
4347
- name: Checkout repository
4448
uses: actions/checkout@v4
4549
with:
4650
fetch-depth: 0
47-
51+
- name: Set the release version
52+
shell: bash
53+
# Extract the version number from the "refs/tags/huly-coder-vx.x.x"
54+
run: echo "RELEASE_VERSION=${GITHUB_REF:22}" >> $GITHUB_ENV
4855
- name: Install Rust toolchain
4956
uses: actions-rust-lang/setup-rust-toolchain@v1
5057

51-
- run: echo "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >> "${GITHUB_ENV}"
52-
if: endsWith(matrix.target, 'windows-msvc')
53-
54-
- uses: taiki-e/upload-rust-binary-action@v1
58+
- name: Upload binaries to release
59+
uses: taiki-e/upload-rust-binary-action@v1
5560
with:
5661
bin: huly-coder
5762
target: ${{ matrix.target }}
5863
include: LICENSE,README.md,huly-coder.yaml
5964
tar: all
6065
zip: windows
6166
token: ${{ secrets.GITHUB_TOKEN }}
67+
- name: Install node
68+
uses: actions/setup-node@v4
69+
with:
70+
node-version: 18
71+
registry-url: "https://registry.npmjs.org"
72+
73+
- name: Publish to NPM
74+
shell: bash
75+
run: |
76+
cd npm
77+
bin="huly-coder"
78+
node_os=$(echo "${{ matrix.name }}" | cut -d '-' -f1)
79+
export node_os
80+
node_arch=$(echo "${{ matrix.name }}" | cut -d '-' -f2)
81+
export node_arch
82+
export version="${{ env.RELEASE_VERSION }}"
83+
if [ "${{ matrix.os }}" = "windows-2022" ]; then
84+
export node_pkg="${bin}-windows-${node_arch}"
85+
else
86+
export node_pkg="${bin}-${node_os}-${node_arch}"
87+
fi
88+
mkdir -p "${node_pkg}/bin"
89+
envsubst < package.json.tmpl > "${node_pkg}/package.json"
90+
if [ "${{ matrix.os }}" = "windows-2022" ]; then
91+
bin="${bin}.exe"
92+
fi
93+
cp "../target/${{ matrix.target }}/release/${bin}" "${node_pkg}/bin"
94+
cp ../README.md "${node_pkg}"
95+
cp ../huly-coder.yaml "${node_pkg}"
96+
cd "${node_pkg}"
97+
npm publish
98+
env:
99+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
62100
upload-docker:
63101
name: Build & Push Docker Image
64102
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,8 @@ on:
66
- main
77

88
jobs:
9-
run-ci:
10-
uses: ./.github/workflows/ci.yml
11-
secrets: inherit
12-
139
release-please:
1410
runs-on: ubuntu-latest
15-
needs: run-ci
1611
permissions:
1712
contents: write
1813
pull-requests: write

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ data/
55
**/*.rs.bk
66
*.pdb
77
huly-coder-local.yaml
8-
/.fastembed_cache/
8+
/.fastembed_cache/
9+
/npm/huly-coder-*

npm/huly-coder/.gitignore

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Typescript build artifacts
2+
lib
3+
4+
# Logs
5+
logs
6+
*.log
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
lerna-debug.log*
11+
.pnpm-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
node_modules/
46+
jspm_packages/
47+
48+
# Snowpack dependency directory (https://snowpack.dev/)
49+
web_modules/
50+
51+
# TypeScript cache
52+
*.tsbuildinfo
53+
54+
# Optional npm cache directory
55+
.npm
56+
57+
# Optional eslint cache
58+
.eslintcache
59+
60+
# Optional stylelint cache
61+
.stylelintcache
62+
63+
# Microbundle cache
64+
.rpt2_cache/
65+
.rts2_cache_cjs/
66+
.rts2_cache_es/
67+
.rts2_cache_umd/
68+
69+
# Optional REPL history
70+
.node_repl_history
71+
72+
# Output of 'npm pack'
73+
*.tgz
74+
75+
# Yarn Integrity file
76+
.yarn-integrity
77+
78+
# dotenv environment variable files
79+
.env
80+
.env.development.local
81+
.env.test.local
82+
.env.production.local
83+
.env.local
84+
85+
# parcel-bundler cache (https://parceljs.org/)
86+
.cache
87+
.parcel-cache
88+
89+
# Next.js build output
90+
.next
91+
out
92+
93+
# Nuxt.js build / generate output
94+
.nuxt
95+
dist
96+
97+
# Gatsby files
98+
.cache/
99+
# Comment in the public line in if your project uses Gatsby and not Next.js
100+
# https://nextjs.org/blog/next-9-1#public-directory-support
101+
# public
102+
103+
# vuepress build output
104+
.vuepress/dist
105+
106+
# vuepress v2.x temp and cache directory
107+
.temp
108+
.cache
109+
110+
# Docusaurus cache and generated files
111+
.docusaurus
112+
113+
# Serverless directories
114+
.serverless/
115+
116+
# FuseBox cache
117+
.fusebox/
118+
119+
# DynamoDB Local files
120+
.dynamodb/
121+
122+
# TernJS port file
123+
.tern-port
124+
125+
# Stores VSCode versions used for testing VSCode extensions
126+
.vscode-test
127+
128+
# yarn berry
129+
.yarn/cache
130+
.yarn/unplugged
131+
.yarn/build-state.yml
132+
.yarn/install-state.gz
133+
.pnp.*

npm/huly-coder/.yarn/releases/yarn-4.1.0.cjs

Lines changed: 893 additions & 0 deletions
Large diffs are not rendered by default.

npm/huly-coder/.yarnrc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
enableGlobalCache: true
2+
3+
nodeLinker: node-modules
4+
5+
yarnPath: .yarn/releases/yarn-4.1.0.cjs

0 commit comments

Comments
 (0)