Skip to content

Commit 165a9f6

Browse files
committed
fix: isolate runAfter Ctrl-C during rebase
1 parent 3e2d895 commit 165a9f6

9 files changed

Lines changed: 874 additions & 86 deletions

File tree

.github/workflows/publish-test.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Publish Test Package
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: npm dist-tag for the test package
8+
required: true
9+
default: beta
10+
type: choice
11+
options:
12+
- alpha
13+
- beta
14+
- next
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
build-foreground:
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- runner: ubuntu-latest
26+
package_target: linux-x64-gnu
27+
setup: ""
28+
cc: cc
29+
ldflags: -Wl,--gc-sections
30+
- runner: ubuntu-latest
31+
package_target: linux-x64-musl
32+
setup: sudo apt-get update && sudo apt-get install -y musl-tools
33+
cc: musl-gcc
34+
ldflags: -Wl,--gc-sections
35+
- runner: ubuntu-24.04-arm
36+
package_target: linux-arm64-gnu
37+
setup: ""
38+
cc: cc
39+
ldflags: -Wl,--gc-sections
40+
- runner: macos-15-intel
41+
package_target: darwin-x64
42+
setup: ""
43+
cc: cc
44+
ldflags: -Wl,-dead_strip
45+
- runner: macos-15
46+
package_target: darwin-arm64
47+
setup: ""
48+
cc: cc
49+
ldflags: -Wl,-dead_strip
50+
runs-on: ${{ matrix.runner }}
51+
steps:
52+
- uses: actions/checkout@v6.0.3
53+
54+
- name: Install target dependencies
55+
if: matrix.setup
56+
run: ${{ matrix.setup }}
57+
58+
- name: Build foreground helper
59+
env:
60+
CC: ${{ matrix.cc }}
61+
LDFLAGS: ${{ matrix.ldflags }}
62+
run: |
63+
mkdir -p "bin/${{ matrix.package_target }}"
64+
"$CC" -Os -fdata-sections -ffunction-sections \
65+
native/foreground/foreground.c \
66+
$LDFLAGS \
67+
-o "bin/${{ matrix.package_target }}/foreground"
68+
strip "bin/${{ matrix.package_target }}/foreground" || true
69+
chmod +x "bin/${{ matrix.package_target }}/foreground"
70+
ls -lh "bin/${{ matrix.package_target }}/foreground"
71+
72+
- uses: actions/upload-artifact@v4
73+
with:
74+
name: foreground-${{ matrix.package_target }}
75+
path: bin/${{ matrix.package_target }}/foreground
76+
if-no-files-found: error
77+
78+
publish-test:
79+
needs: build-foreground
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v6.0.3
83+
84+
- uses: actions/setup-node@v6.4.0
85+
with:
86+
node-version: 24
87+
registry-url: https://registry.npmjs.org
88+
89+
- uses: pnpm/action-setup@v6.0.8
90+
with:
91+
run_install: true
92+
93+
- uses: actions/download-artifact@v4
94+
with:
95+
pattern: foreground-*
96+
path: bin-artifacts
97+
98+
- name: Install foreground helper artifacts
99+
run: |
100+
mkdir -p bin
101+
for artifact in bin-artifacts/foreground-*; do
102+
target="${artifact##*/foreground-}"
103+
mkdir -p "bin/$target"
104+
cp "$artifact/foreground" "bin/$target/foreground"
105+
chmod +x "bin/$target/foreground"
106+
done
107+
find bin -maxdepth 2 -type f -print
108+
109+
- name: Set timestamp prerelease version
110+
id: test-version
111+
env:
112+
TEST_TAG: ${{ inputs.tag }}
113+
run: |
114+
timestamp="$(date -u +%Y%m%d%H%M%S)"
115+
version="$(TIMESTAMP="$timestamp" node -e "const fs=require('fs'); const p=require('./package.json'); const base=p.version.split('-')[0]; p.version=base+'-'+process.env.TEST_TAG+'.'+process.env.TIMESTAMP; fs.writeFileSync('package.json', JSON.stringify(p, null, 2)+'\n'); console.log(p.version)")"
116+
echo "version=$version" >> "$GITHUB_OUTPUT"
117+
echo "Prepared test version: $version"
118+
119+
- name: Build package
120+
run: pnpm run build
121+
122+
- name: Publish test package
123+
env:
124+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
125+
run: npm publish --tag "${{ inputs.tag }}"
126+
127+
- name: Summary
128+
run: |
129+
echo "Published lockfile-conflicts@${{ steps.test-version.outputs.version }} with tag ${{ inputs.tag }}" >> "$GITHUB_STEP_SUMMARY"
130+
echo "Install with: npm install lockfile-conflicts@${{ inputs.tag }}" >> "$GITHUB_STEP_SUMMARY"

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,68 @@ permissions:
1313
contents: write
1414

1515
jobs:
16+
build-foreground:
17+
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- runner: ubuntu-latest
23+
package_target: linux-x64-gnu
24+
setup: ""
25+
cc: cc
26+
ldflags: -Wl,--gc-sections
27+
- runner: ubuntu-latest
28+
package_target: linux-x64-musl
29+
setup: sudo apt-get update && sudo apt-get install -y musl-tools
30+
cc: musl-gcc
31+
ldflags: -Wl,--gc-sections
32+
- runner: ubuntu-24.04-arm
33+
package_target: linux-arm64-gnu
34+
setup: ""
35+
cc: cc
36+
ldflags: -Wl,--gc-sections
37+
- runner: macos-15-intel
38+
package_target: darwin-x64
39+
setup: ""
40+
cc: cc
41+
ldflags: -Wl,-dead_strip
42+
- runner: macos-15
43+
package_target: darwin-arm64
44+
setup: ""
45+
cc: cc
46+
ldflags: -Wl,-dead_strip
47+
runs-on: ${{ matrix.runner }}
48+
steps:
49+
- uses: actions/checkout@v6.0.3
50+
51+
- name: Install target dependencies
52+
if: matrix.setup
53+
run: ${{ matrix.setup }}
54+
55+
- name: Build foreground helper
56+
env:
57+
CC: ${{ matrix.cc }}
58+
LDFLAGS: ${{ matrix.ldflags }}
59+
run: |
60+
mkdir -p "bin/${{ matrix.package_target }}"
61+
"$CC" -Os -fdata-sections -ffunction-sections \
62+
native/foreground/foreground.c \
63+
$LDFLAGS \
64+
-o "bin/${{ matrix.package_target }}/foreground"
65+
strip "bin/${{ matrix.package_target }}/foreground" || true
66+
chmod +x "bin/${{ matrix.package_target }}/foreground"
67+
ls -lh "bin/${{ matrix.package_target }}/foreground"
68+
69+
- uses: actions/upload-artifact@v4
70+
with:
71+
name: foreground-${{ matrix.package_target }}
72+
path: bin/${{ matrix.package_target }}/foreground
73+
if-no-files-found: error
74+
1675
release-package:
1776
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged
77+
needs: build-foreground
1878
runs-on: ubuntu-latest
1979
steps:
2080
- uses: actions/checkout@v6.0.3
@@ -27,6 +87,22 @@ jobs:
2787
with:
2888
run_install: true
2989

90+
- uses: actions/download-artifact@v4
91+
with:
92+
pattern: foreground-*
93+
path: bin-artifacts
94+
95+
- name: Install foreground helper artifacts
96+
run: |
97+
mkdir -p bin
98+
for artifact in bin-artifacts/foreground-*; do
99+
target="${artifact##*/foreground-}"
100+
mkdir -p "bin/$target"
101+
cp "$artifact/foreground" "bin/$target/foreground"
102+
chmod +x "bin/$target/foreground"
103+
done
104+
find bin -maxdepth 2 -type f -print
105+
30106
- name: Version Package
31107
id: versioning
32108
run: |

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ dist
33
types
44
.idea
55
.DS_Store
6+
7+
# Native build output
8+
native/**/target
9+
bin

native/foreground/build.mjs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { $, fs, path } from 'zx';
2+
3+
const root = process.cwd();
4+
5+
function readOption(name) {
6+
const prefix = `${name}=`;
7+
const index = process.argv.indexOf(name);
8+
if (index !== -1) return process.argv[index + 1];
9+
const item = process.argv.find((arg) => arg.startsWith(prefix));
10+
return item ? item.slice(prefix.length) : undefined;
11+
}
12+
13+
function linuxLibcSuffix() {
14+
if (process.platform !== 'linux') return '';
15+
const report = process.report?.getReport?.();
16+
return report?.header?.glibcVersionRuntime ? '-gnu' : '-musl';
17+
}
18+
19+
function defaultPackageTarget() {
20+
if (process.platform !== 'darwin' && process.platform !== 'linux') {
21+
throw new Error(`unsupported platform: ${process.platform}`);
22+
}
23+
if (process.arch !== 'x64' && process.arch !== 'arm64') {
24+
throw new Error(`unsupported arch: ${process.arch}`);
25+
}
26+
return `${process.platform}-${process.arch}${linuxLibcSuffix()}`;
27+
}
28+
29+
const packageTarget = readOption('--package-target') || defaultPackageTarget();
30+
const cc = readOption('--cc') || process.env.CC || 'cc';
31+
const extraCflags = (process.env.CFLAGS || '').split(/\s+/).filter(Boolean);
32+
function defaultLdflags() {
33+
if (process.platform === 'darwin') return ['-Wl,-dead_strip'];
34+
if (process.platform === 'linux') return ['-Wl,--gc-sections'];
35+
return [];
36+
}
37+
38+
const extraLdflags = (process.env.LDFLAGS || '').split(/\s+/).filter(Boolean);
39+
const ldflags = extraLdflags.length ? extraLdflags : defaultLdflags();
40+
const source = path.join(root, 'native/foreground/foreground.c');
41+
const destination = path.join(root, 'bin', packageTarget, 'foreground');
42+
43+
await fs.ensureDir(path.dirname(destination));
44+
await $`${cc} -Os -s -fdata-sections -ffunction-sections ${extraCflags} ${source} ${ldflags} -o ${destination}`;
45+
await fs.chmod(destination, 0o755);
46+
await $({ nothrow: true })`strip ${destination}`;
47+
console.log(`built ${destination}`);

0 commit comments

Comments
 (0)