Skip to content

Commit c88ef7d

Browse files
committed
target strategy testing
1 parent 3811bba commit c88ef7d

4 files changed

Lines changed: 84 additions & 118 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
5+
const dirname = path.dirname(fileURLToPath(import.meta.url));
6+
const root = path.resolve(dirname, '..', '..');
7+
8+
const version = process.argv[2];
9+
10+
if (!version) {
11+
throw new Error('Expected a version argument, for example: 0.9.2');
12+
}
13+
14+
const packageFile = path.join(root, 'packages', 'idea-node', 'package.json');
15+
const packageJson = JSON.parse(fs.readFileSync(packageFile, 'utf8'));
16+
17+
for (const name of Object.keys(packageJson.optionalDependencies || {})) {
18+
packageJson.optionalDependencies[name] = version;
19+
}
20+
21+
fs.writeFileSync(packageFile, `${JSON.stringify(packageJson, null, 2)}\n`);
22+
console.log(`prepared packages/idea-node/package.json for publish version ${version}`);
Lines changed: 31 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,60 @@
1-
name: Build and Release Binaries
1+
name: Build Release Artifacts
22

33
on:
44
push:
55
tags:
66
- 'v*'
77
workflow_dispatch:
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
build:
14+
name: ${{ matrix.package }}
15+
runs-on: ${{ matrix.runs_on }}
1116
strategy:
1217
fail-fast: false
1318
matrix:
14-
settings:
15-
- host: macos-latest
16-
target: x86_64-apple-darwin
17-
build: yarn build:rs --target x86_64-apple-darwin
18-
- host: macos-latest
19-
target: aarch64-apple-darwin
20-
build: yarn build:rs --target aarch64-apple-darwin
21-
- host: windows-latest
22-
target: x86_64-pc-windows-msvc
23-
build: yarn build:rs --target x86_64-pc-windows-msvc
24-
- host: windows-latest
25-
target: i686-pc-windows-msvc
26-
build: yarn build:rs --target i686-pc-windows-msvc
27-
- host: ubuntu-latest
28-
target: x86_64-unknown-linux-gnu
29-
build: yarn build:rs --target x86_64-unknown-linux-gnu
30-
- host: ubuntu-latest
31-
target: x86_64-unknown-linux-musl
32-
build: |
33-
sudo apt-get update
34-
sudo apt-get install musl-tools
35-
yarn build:rs --target x86_64-unknown-linux-musl
36-
- host: ubuntu-latest
37-
target: aarch64-unknown-linux-gnu
38-
build: |
39-
sudo apt-get update
40-
sudo apt-get install gcc-aarch64-linux-gnu
41-
yarn build:rs --target aarch64-unknown-linux-gnu
42-
- host: ubuntu-latest
43-
target: i686-unknown-linux-gnu
44-
build: |
45-
sudo apt-get update
46-
sudo apt-get install gcc-multilib
47-
yarn build:rs --target i686-unknown-linux-gnu
48-
- host: ubuntu-latest
49-
target: armv7-unknown-linux-gnueabihf
50-
build: |
51-
sudo apt-get update
52-
sudo apt-get install gcc-arm-linux-gnueabihf
53-
yarn build:rs --target armv7-unknown-linux-gnueabihf
54-
- host: ubuntu-latest
55-
target: x86_64-unknown-freebsd
56-
build: yarn build:rs --target x86_64-unknown-freebsd
19+
include:
20+
- runs_on: macos-14
21+
package: idea-node-darwin-arm64
22+
binary: idea_node.darwin-arm64.node
23+
24+
- runs_on: macos-13
25+
package: idea-node-darwin-x64
26+
binary: idea_node.darwin-x64.node
5727

58-
name: Build ${{ matrix.settings.target }}
59-
runs-on: ${{ matrix.settings.host }}
28+
- runs_on: ubuntu-24.04
29+
package: idea-node-linux-x64-gnu
30+
binary: idea_node.linux-x64-gnu.node
31+
32+
- runs_on: windows-2022
33+
package: idea-node-win32-x64-msvc
34+
binary: idea_node.win32-x64-msvc.node
6035

6136
steps:
6237
- uses: actions/checkout@v4
6338

64-
- name: Setup Node.js
39+
- name: Set up Node.js
6540
uses: actions/setup-node@v4
6641
with:
67-
node-version: '18'
42+
node-version: '22.14.0'
6843
cache: 'yarn'
6944

70-
- name: Setup Rust
45+
- name: Set up Rust
7146
uses: dtolnay/rust-toolchain@stable
72-
with:
73-
targets: ${{ matrix.settings.target }}
74-
75-
- name: Cache cargo
76-
uses: actions/cache@v4
77-
with:
78-
path: |
79-
~/.cargo/registry/index/
80-
~/.cargo/registry/cache/
81-
~/.cargo/git/db/
82-
.cargo-cache
83-
target/
84-
key: ${{ matrix.settings.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
8547

8648
- name: Install dependencies
87-
run: yarn install --frozen-lockfile
49+
run: yarn install --ignore-scripts
8850

89-
- name: Build binary
90-
run: ${{ matrix.settings.build }}
51+
- name: Build host binary
52+
run: yarn --cwd packages/idea-node build
9153

92-
- name: Upload binary
54+
- name: Upload platform artifact
9355
uses: actions/upload-artifact@v4
9456
with:
95-
name: binaries-${{ matrix.settings.target }}
57+
name: ${{ matrix.package }}
9658
path: |
97-
*.node
98-
cjs/*.node
99-
esm/*.node
100-
101-
release:
102-
name: Create Release
103-
runs-on: ubuntu-latest
104-
needs: build
105-
if: startsWith(github.ref, 'refs/tags/')
106-
107-
steps:
108-
- uses: actions/checkout@v4
109-
110-
- name: Download all artifacts
111-
uses: actions/download-artifact@v4
112-
with:
113-
path: artifacts
114-
115-
- name: Create Release
116-
id: create_release
117-
uses: actions/create-release@v1
118-
env:
119-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120-
with:
121-
tag_name: ${{ github.ref }}
122-
release_name: Release ${{ github.ref }}
123-
draft: false
124-
prerelease: false
125-
126-
- name: Upload Release Assets
127-
run: |
128-
for dir in artifacts/binaries-*; do
129-
target=$(basename "$dir" | sed 's/binaries-//')
130-
for file in "$dir"/*.node; do
131-
if [ -f "$file" ]; then
132-
asset_name="idea-parser-${target}.node"
133-
echo "Uploading $file as $asset_name"
134-
curl \
135-
-X POST \
136-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
137-
-H "Content-Type: application/octet-stream" \
138-
--data-binary @"$file" \
139-
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.id }}/assets?name=$asset_name"
140-
fi
141-
done
142-
done
59+
packages/${{ matrix.package }}/package.json
60+
packages/${{ matrix.package }}/${{ matrix.binary }}

AGENTS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@
9797
- The in-repo sync script only mirrors binaries that were actually built on the
9898
current machine; it does not cross-compile unsupported targets by itself.
9999

100+
## Release Workflow
101+
102+
- GitHub Actions is build-only for release artifacts.
103+
- The active workflow is:
104+
- `.github/workflows/build-binaries.yml`
105+
- It currently builds these targets:
106+
- `idea-node-darwin-arm64`
107+
- `idea-node-darwin-x64`
108+
- `idea-node-linux-x64-gnu`
109+
- `idea-node-win32-x64-msvc`
110+
- The workflow uploads package-shaped artifacts only. It does not publish.
111+
- Local release prep uses:
112+
- `.github/scripts/prepare-npm-release.mjs`
113+
- That script rewrites `packages/idea-node/package.json` optional dependencies
114+
from local `file:` references to a real version string before manual publish.
115+
100116
## Style Notes
101117

102118
- TypeScript should follow the repo style guide shared in chat:

packages/idea-node/package.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,21 @@
5858
},
5959
"typesVersions": {
6060
"*": {
61-
"index": [ "./esm/index.d.ts" ],
62-
"types": [ "./esm/types.d.ts" ],
63-
"Transformer": [ "./esm/Transformer.d.ts" ],
64-
"Terminal": [ "./esm/Terminal.d.ts" ],
65-
"bin": [ "./esm/bin.d.ts" ]
61+
"index": [
62+
"./esm/index.d.ts"
63+
],
64+
"types": [
65+
"./esm/types.d.ts"
66+
],
67+
"Transformer": [
68+
"./esm/Transformer.d.ts"
69+
],
70+
"Terminal": [
71+
"./esm/Terminal.d.ts"
72+
],
73+
"bin": [
74+
"./esm/bin.d.ts"
75+
]
6676
}
6777
},
6878
"files": [

0 commit comments

Comments
 (0)