Skip to content

Commit d9a7e45

Browse files
committed
Added possibility of specifying versions
1 parent ab89397 commit d9a7e45

5 files changed

Lines changed: 16 additions & 8 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ on:
6969
required: false
7070
type: number
7171
nightly-versions:
72-
description: Build with nightly Node.js versions
73-
default: ''
72+
description: Build with nightly Node.js versions, for latest use 'latest' for specified version use the following format nodeVersion,abiVersion,alpineVersion
7473
required: false
75-
type: boolean
74+
type: string
7675

7776
concurrency:
7877
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ GitHub Actions reusable workflow to generate prebuilds for a Node native add-on.
44

55
## Usage
66

7-
This workflow can be used to generate Node 12 - 25 prebuilds for Linux, macOS
7+
This workflow can be used to generate Node 12 - 25 and nightly prebuilds for Linux, macOS
88
and Windows. The prebuilds will be stored in the `prebuilds` folder which should
99
be added to `.gitignore`, and can be loaded using
1010
[node-gyp-build](https://www.npmjs.com/package/node-gyp-build) with
@@ -22,6 +22,7 @@ jobs:
2222
cache: false # enable caching of dependencies based on lockfile
2323
directory-path: '.' # The path to the directory containing your build files, relative to the repo root.
2424
min-node-version: 12 # The minimum Node.js version to build and test
25+
nightly-versions: '' # Full nightly node, abi and alpine version to build (e.g., "v26.0.0-1234567890,142,~3.17" or "latest")
2526
napi: false # generate single Node-API binary for all versions of Node
2627
napi-rs: false # Whether or not this build is for a napi-rs project.
2728
neon: false # Whether or not this build is for a Neon project.

prebuild/fetch_node_headers.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ function fetchNodeHeaders (version, devDir) {
2424
return new Promise((resolve, reject) => {
2525
operation.attempt(() => {
2626
let cmd
27-
if (version.includes('nightly')) {
27+
const isNightly = version.includes('nightly')
28+
29+
if (isNightly) {
2830
cmd = [
2931
'node-gyp install',
30-
'--dist-url=https://nodejs.org/download/nightly/v26.0.0-nightly202511108a76958005',
32+
'--dist-url=https://nodejs.org/download/nightly',
3133
`--target=${version}`,
3234
`--devdir=${devDir}`
3335
].join(' ')
@@ -42,6 +44,10 @@ function fetchNodeHeaders (version, devDir) {
4244
try {
4345
execSync(cmd, { stdio, shell })
4446
} catch (err) {
47+
if (isNightly) {
48+
console.log('Failed to execute nightly: ', err) // eslint-disable-line no-console
49+
return
50+
}
4551
if (operation.retry(err)) {
4652
return
4753
} else if (err) {
@@ -65,7 +71,7 @@ function computeNodeTargetsHash (targets) {
6571

6672
async function fetchAllNodeHeaders (targets, targetDir) {
6773
for (const target of targets) {
68-
await fetchNodeHeaders(target.version, targetDir)
74+
fetchNodeHeaders(target.version, targetDir)
6975
}
7076
}
7177

@@ -79,6 +85,7 @@ async function main () {
7985
}
8086
}
8187

88+
8289
main().catch((err) => {
8390
console.error(err) // eslint-disable-line no-console
8491
process.exit(1)

prebuild/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ async function run () {
6868
if (NAPI === 'true' || NAPI_RS === 'true' || NEON === 'true' || RUST === 'true') {
6969
prebuildTarget(arch, { version: targets[0].version, abi: 'napi' })
7070
} else {
71+
console.log(`These are the targets ${targets}`) // eslint-disable-line no-console
7172
targets.forEach(target => prebuildTarget(arch, target))
7273
}
7374

prebuild/targets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict'
22

33
const semver = require('semver')
4-
const fetch = require('node-fetch')
54

65
const nodeTargets = [
76
{ version: '12.0.0', abi: '72', alpineVersion: '~3.14' },
@@ -59,6 +58,7 @@ async function getNightlyTarget () {
5958
let response
6059
try {
6160
response = await fetch('https://nodejs.org/download/nightly/index.json')
61+
console.log('This is the response ', response) // eslint-disable-line no-console
6262
} catch (error) {
6363
return
6464
}

0 commit comments

Comments
 (0)