Skip to content

Commit b65fa85

Browse files
committed
feat: Include builds for linux-x64 and linux-arm64
1 parent e1fa50a commit b65fa85

9 files changed

Lines changed: 5777 additions & 389 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
- name: 'Debug: List post build files'
2727
run: find * \( -path node_modules -o -path .git \) -print -prune -o -type f -print | tee /tmp/build.list
2828

29+
- name: 'Get Package Name'
30+
run: echo "PACKAGE_NAME=$(jq -r .name package.json)" >> "$GITHUB_ENV"
31+
2932
# Prepare Test Environment
3033

3134
- name: Create Dummy Package.json
@@ -37,7 +40,7 @@ jobs:
3740

3841
- name: 'Debug: List Dependency Folder Contents'
3942
working-directory: test
40-
run: find node_modules/userid -type f -print
43+
run: find "node_modules/${PACKAGE_NAME}" -type f -print
4144

4245
# Ensure the code works
4346

@@ -50,7 +53,7 @@ jobs:
5053
- name: Run Tests with Prepared Git Dependency
5154
run: npm test -- --color
5255
env:
53-
MOCHA_IMPORT_OVERRIDE: userid
56+
MOCHA_IMPORT_OVERRIDE: ${{env.PACKAGE_NAME}}
5457
LONG_USERNAME_TEST: UsernameWithMoreThan15Chars
5558
LONG_GROUPNAME_TEST: GroupnameWithMoreThan15Chars
5659

.github/workflows/release.yml

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
6+
pull_request:
7+
branches:
8+
- master
9+
10+
release:
11+
types: [published]
12+
13+
workflow_dispatch:
14+
inputs:
15+
new-version:
16+
description: New version to be published, overrides tag
17+
required: true
18+
type: string
19+
20+
npm-tag:
21+
description: NPM tag
22+
required: true
23+
default: latest
24+
type: choice
25+
options:
26+
- latest
27+
- next
28+
29+
jobs:
30+
build:
31+
strategy:
32+
matrix:
33+
include:
34+
- os: ubuntu-22.04
35+
arch: linux-x64-glibc
36+
- os: ubuntu-22.04-arm
37+
arch: linux-arm64-glibc
38+
- os: macos-13
39+
arch: darwin-x64
40+
- os: macos-14
41+
arch: darwin-arm64
42+
43+
name: Build for ${{ matrix.arch }}
44+
runs-on: ${{ matrix.os }}
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
with:
50+
submodules: true
51+
52+
- name: Use Node.js 20
53+
uses: actions/setup-node@v4
54+
with:
55+
cache: npm
56+
node-version: 20
57+
58+
- name: Install dependencies
59+
run: npm ci
60+
61+
- name: Prebuild
62+
run: npm run build
63+
64+
- name: Upload artifacts
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: prebuild-${{ matrix.arch }}
68+
path: prebuilds/**/*.node
69+
70+
build-musl:
71+
strategy:
72+
matrix:
73+
include:
74+
- os: ubuntu-22.04
75+
arch: x64
76+
platform: linux/amd64
77+
- os: ubuntu-22.04-arm
78+
arch: arm64
79+
platform: linux/arm64
80+
- os: ubuntu-22.04-arm
81+
arch: armv7
82+
platform: linux/arm/v7
83+
84+
name: Build for linux-${{ matrix.arch }}-musl
85+
runs-on: ${{ matrix.os }}
86+
87+
steps:
88+
- name: Checkout
89+
uses: actions/checkout@v4
90+
with:
91+
submodules: true
92+
93+
- name: Set up QEMU
94+
uses: docker/setup-qemu-action@v3
95+
with:
96+
platforms: ${{ matrix.platform }}
97+
98+
- name: Prebuild
99+
uses: addnab/docker-run-action@v3
100+
with:
101+
image: node:20-alpine
102+
options: --platform=${{ matrix.platform }} --volume=${{ github.workspace }}:/repo --workdir=/repo
103+
run: |
104+
apk add --no-cache g++ make python3
105+
npm ci
106+
npm run build
107+
108+
- name: Upload artifacts
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: prebuild-linux-${{ matrix.arch }}-musl
112+
path: prebuilds/**/*.node
113+
114+
build-freebsd-x64:
115+
name: Build for freebsd-x64
116+
runs-on: ubuntu-latest
117+
118+
steps:
119+
- name: Checkout
120+
uses: actions/checkout@v4
121+
with:
122+
submodules: true
123+
124+
- name: Prebuild
125+
uses: vmactions/freebsd-vm@v1
126+
with:
127+
prepare: |
128+
pkg install -y gmake python3 npm-node20
129+
run: |
130+
npm ci
131+
npm run build
132+
sync: sshfs
133+
134+
- name: Upload artifacts
135+
uses: actions/upload-artifact@v4
136+
with:
137+
name: prebuild-freebsd-x64
138+
path: prebuilds/**/*.node
139+
140+
build-linux-armv7-glibc:
141+
name: Build for linux-armv7-glibc
142+
runs-on: ubuntu-latest
143+
144+
steps:
145+
- name: Checkout
146+
uses: actions/checkout@v4
147+
with:
148+
submodules: true
149+
150+
- name: Set up QEMU
151+
uses: docker/setup-qemu-action@v3
152+
with:
153+
platforms: linux/arm/v7
154+
155+
- name: Prebuild
156+
uses: addnab/docker-run-action@v3
157+
with:
158+
image: node:20-bullseye
159+
options: --platform=linux/arm/v7 --volume=${{ github.workspace }}:/repo --workdir=/repo
160+
run: |
161+
apt update -yq && apt install -yq wget
162+
wget -qL https://deb.nodesource.com/setup_20.x | bash -
163+
apt install -yq g++ make python3 nodejs
164+
npm ci
165+
npm run build
166+
167+
- name: Upload artifacts
168+
uses: actions/upload-artifact@v4
169+
with:
170+
name: prebuild-linux-armv7-glibc
171+
path: prebuilds/**/*.node
172+
173+
publish:
174+
name: Publish package
175+
runs-on: ubuntu-latest
176+
177+
permissions:
178+
contents: read
179+
id-token: write
180+
181+
needs:
182+
- build
183+
- build-musl
184+
- build-freebsd-x64
185+
- build-linux-armv7-glibc
186+
187+
steps:
188+
- name: Checkout
189+
uses: actions/checkout@v4
190+
with:
191+
submodules: true
192+
193+
- name: Setup npm with Node.js 20
194+
uses: actions/setup-node@v4
195+
with:
196+
cache: npm
197+
node-version: 20
198+
token: ${{ secrets.NPM_TOKEN }}
199+
registry-url: 'https://registry.npmjs.org'
200+
201+
- name: Install dependencies
202+
run: npm ci --ignore-scripts
203+
204+
- name: Download artifacts
205+
id: download-artifact
206+
uses: actions/download-artifact@v4
207+
208+
- name: Move prebuild artifacts
209+
run: mkdir prebuilds && cp --recursive prebuild-*/* prebuilds/
210+
211+
- name: Pack package
212+
run: npm pack
213+
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
214+
215+
- name: Upload package artifact
216+
uses: actions/upload-artifact@v4
217+
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
218+
with:
219+
name: package
220+
path: '*.tgz'
221+
222+
- name: Publish to NPM
223+
run: |
224+
npm version --allow-same-version --no-git-tag-version $VERSION
225+
npm publish --provenance --tag $TAG
226+
if: ${{ !env.ACT && (github.event_name == 'release' || github.event_name == 'workflow_dispatch') }}
227+
env:
228+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
229+
TAG: ${{ inputs.npm-tag || 'latest' }}
230+
VERSION: ${{ inputs.new-version || github.ref_name }}

.github/workflows/versions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
os: [ubuntu-latest, macos-latest]
20+
os: [ubuntu-latest, macos-latest, macos-13]
2121
# There are problems on various architectures on lower versions that are more work to fix. Please open an issue if you need more version support
22-
node: [12, 13, 14, 15, 16]
22+
node: [16, 18, 20, 22]
2323

2424
runs-on: ${{ matrix.os }}
2525

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
build/
2+
prebuilds/
23
*.swp
34
node_modules
5+
.idea/

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
Simple Node.js library with native bindings for getting uid and gid information.
44

5-
[![](https://github.com/cinderblock/node-userid/workflows/Main/badge.svg)](https://github.com/cinderblock/node-userid/actions)
6-
[![](https://github.com/cinderblock/node-userid/workflows/Test%20All%20Versions/badge.svg)](https://github.com/cinderblock/node-userid/actions)
7-
[![Coverage Status](https://coveralls.io/repos/github/cinderblock/node-userid/badge.svg?branch=master)](https://coveralls.io/github/cinderblock/node-userid?branch=master)
5+
[![](https://github.com/matthewh/node-userid/workflows/Main/badge.svg)](https://github.com/cinderblock/node-userid/actions)
6+
[![](https://github.com/matthewh/node-userid/workflows/Test%20All%20Versions/badge.svg)](https://github.com/cinderblock/node-userid/actions)
7+
[![Coverage Status](https://coveralls.io/repos/github/matthewh/node-userid/badge.svg?branch=master)](https://coveralls.io/github/cinderblock/node-userid?branch=master)
88

99
## Installation
1010

1111
```bash
12-
$ npm install userid
13-
# Or, alternatively, directly from github:
14-
$ npm install cinderblock/node-userid
12+
$ npm install @hershbergien/userid
1513
```
1614

1715
This relies on GNU `getgrname` and `getgrid`.
@@ -80,6 +78,8 @@ Pull requests that would bring Windows into the fold would be welcome.
8078

8179
## History
8280

81+
Version 1.3.0 adds prebuilt binaries for compatible architectures.
82+
8383
This package was originally created by [Jen Andre](https://github.com/jandre/node-userid) <jandre@gmail.com>.
8484

8585
In 2019, it was, unfortunately, missing updates that are required to run on the latest versions of Node.js.
@@ -91,7 +91,7 @@ It also signals the change to using Github Actions to run all our full coverage
9191

9292
## License
9393

94-
The license, when the package was created, had some mix of GLPv3 and Public Domain.
94+
The license, when the package was created, had some mix of GPLv3 and Public Domain.
9595

9696
Since the main source code has always been Public Domain, I believe it should stay that way.
9797
I've also explicitly extended it to the rest of the main (published) source code.

cSpell.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
"passwd",
4141
"userid",
4242
"tracefile",
43-
"xcode"
43+
"xcode",
44+
"Hershberger",
45+
"hershbergien",
46+
"prebuildify",
47+
"prebuilds",
48+
"armv"
4449
]
4550
}

lib/userid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This code is PUBLIC DOMAIN, and is distributed on an "AS IS" BASIS,
22
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
33

4-
module.exports = require('bindings')('userid.node');
4+
module.exports = require('node-gyp-build')(`${__dirname}/..`);
55

66
// Historically, this function was defined similar to this by Jen's original implementation
77
module.exports.uid = (...args) => module.exports.ids(...args).uid;

0 commit comments

Comments
 (0)