Skip to content

Commit 31411e5

Browse files
Merge pull request #18 from BitCurator/update-node24
Update to build with Node 24
2 parents eac15ce + a12fc1d commit 31411e5

6 files changed

Lines changed: 770 additions & 542 deletions

File tree

.github/workflows/build.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Build bitcurator-cli
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
branches: [main]
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Node.js 24
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '24'
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run linter
30+
run: npm run lint --if-present
31+
32+
- name: Fetch tags
33+
run: git fetch --prune --unshallow --tags 2>/dev/null || git fetch --prune --tags 2>/dev/null || true
34+
35+
- name: Prepare package config
36+
run: |
37+
VERSION=$(jq -r '.version' package.json)
38+
EXACT_TAG=$(git describe --exact-match 2>/dev/null | sed -e 's/^v//g' || echo "")
39+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
40+
REVISION=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
41+
42+
# If we're on an exact tag, use it
43+
if echo "$EXACT_TAG" | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+(-rc\.?[0-9]+)?$"; then
44+
FINAL_VERSION="$EXACT_TAG"
45+
elif [ -n "$LAST_TAG" ]; then
46+
COMMITS=$(git log --oneline ${LAST_TAG}..HEAD | wc -l | tr -d '[:space:]')
47+
FINAL_VERSION="${VERSION}.${COMMITS}.g${REVISION}"
48+
else
49+
FINAL_VERSION="${VERSION}.0.g${REVISION}"
50+
fi
51+
52+
echo "{\"version\":\"${FINAL_VERSION}\"}" > config.json
53+
echo "Generated config.json with version: ${FINAL_VERSION}"
54+
cat config.json
55+
56+
- name: Build executable
57+
run: npm run pkg:build
58+
59+
- name: Generate checksum
60+
run: npm run pkg:hash
61+
62+
- name: Import GPG key
63+
uses: crazy-max/ghaction-import-gpg@v6
64+
with:
65+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
66+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
67+
68+
- name: Sign checksum
69+
run: |
70+
cd release
71+
gpg --armor --clearsign --digest-algo SHA256 -u 1ACB8887 bitcurator-cli-linux.sha256
72+
rm bitcurator-cli-linux.sha256
73+
74+
- name: Upload build artifact
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: bitcurator-cli-linux
78+
path: |
79+
release/bitcurator-cli-linux
80+
release/bitcurator-cli-linux.sha256.asc
81+
82+
release:
83+
needs: build
84+
runs-on: ubuntu-latest
85+
if: startsWith(github.ref, 'refs/tags/v')
86+
87+
permissions:
88+
contents: write
89+
90+
steps:
91+
- name: Download build artifact
92+
uses: actions/download-artifact@v4
93+
with:
94+
name: bitcurator-cli-linux
95+
path: release
96+
97+
- name: Create GitHub Release
98+
uses: softprops/action-gh-release@v2
99+
with:
100+
files: |
101+
release/bitcurator-cli-linux
102+
release/bitcurator-cli-linux.sha256.asc
103+
generate_release_notes: true

BUILD.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,26 @@ This documentation is intended for developers and maintainers. To install BitCur
77
- jq
88
- gpg
99
- git
10-
- nodejs (minimum v22, with npm - see instructions [here](https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions))
10+
- nodejs (v24, with npm - see instructions [here](https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions))
1111

1212
```bash
13-
$ sudo apt-get install jo jq gpg nodejs npm
13+
$ sudo apt-get install jo jq gpg
1414
```
15+
16+
```bash
17+
# Follow the instructions at: https://nodejs.org/en/download (example here)
18+
# Download and install nvm:
19+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
20+
# in lieu of restarting the shell
21+
\. "$HOME/.nvm/nvm.sh"
22+
# Download and install Node.js:
23+
nvm install 24
24+
# Verify the Node.js version:
25+
node -v # Should print "v24.11.1".
26+
# Verify npm version:
27+
npm -v # Should print "11.6.2".
28+
```
29+
1530
### Modifying
1631
To customize the CLI, it's important to change the following spots in the CLI (as desired):
1732
#### xxx-cli.js
@@ -38,7 +53,7 @@ Important areas to modify:
3853
### Building
3954
Change to the CLI directory and run the following:
4055
```bash
41-
$ sudo npm install -g pkg docopt @octokit/rest js-yaml mkdirp openpgp semver split username
56+
$ sudo npm install -g pkg docopt @octokit/rest js-yaml mkdirp openpgp semver split
4257
$ npm install
4358
```
4459
To avoid having the node_modules folder, and the soon-to-be-created release folder, uploaded during a `git push`, create a `.gitignore` file and ensure these are added.
@@ -49,7 +64,14 @@ While still in the directory, run: `npm run pkg`
4964

5065
This will create the release folder with a `.sha256.asc` signature and the generated binary. Once your build is tested and you're satisfied with the way it turned out, it's time to release it.
5166

52-
### Release
67+
### Release (new style, GitHub Workflow)
68+
There is a workflow in .github/workflows/build.yml. It includes:
69+
70+
Triggers: Runs on pushes/PRs to main, version tags (v\*), and manual dispatch
71+
Build job: Sets up Node 24, installs dependencies, runs the linter if present, and builds the executable with checksum
72+
Release job: Automatically creates a GitHub Release with the built artifacts when you push a version tag (e.g., git tag v3.1.0 && git push --tags)
73+
74+
### Release (old style, manual)
5375
First thing to do would be to add, commit, and push to the repo:
5476
```bash
5577
$ git add -A

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
# bitcurator-cli
44

55
[![GitHub issues](https://img.shields.io/github/issues/bitcurator/bitcurator-salt.svg)](https://github.com/bitcurator/bitcurator-salt/issues)
6+
[![Build](https://github.com/bitcurator/bitcurator-cli/actions/workflows/build.yml/badge.svg)](https://github.com/bitcurator/bitcurator-cli/actions/workflows/build.yml)
67
[![GitHub forks](https://img.shields.io/github/forks/bitcurator/bitcurator-salt.svg)](https://github.com/bitcurator/bitcurator-salt/network)
78

8-
This repo contains the source for the BitCurator CLI installer, a command line tool to install and upgrade the BitCurator environment. It supports BitCurator installations on Ubuntu 24.04LTS and Ubuntu 22.04LTS.
9+
This repo contains the source for the BitCurator CLI installer, a command line tool to install and upgrade the BitCurator environment. It supports BitCurator installations on Ubuntu 24.04LTS (Noble) and Ubuntu 22.04LTS (Jammy).
910

10-
Visit https://github.com/bitcurator/bitcurator-salt and view the README to get started immediately with installation. You can find additional information on BitCurator releases and installation at https://github.com/BitCurator/bitcurator-distro/wiki/Releases.
11+
Visit https://github.com/bitcurator/bitcurator-salt and view the README there for complete installation instructions. You can find additional information on BitCurator releases and installation, including a detailed Quick Start Guide, at https://github.com/BitCurator/bitcurator-distro/wiki/Releases.
1112

1213
## BitCurator documentation, help, and discussions
1314

bitcurator-cli.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ const docopt = require('docopt').docopt
1010
const { Octokit } = require('@octokit/rest')
1111
const { mkdirp } = require('mkdirp')
1212
const openpgp = require('openpgp')
13-
const username = require('username')
13+
1414
const readline = require('readline')
1515
const split = require('split')
1616
const execAsync = promisify(child_process.exec)
1717
const yaml = require('js-yaml')
1818

19-
const currentUser = process.env.SUDO_USER || username.sync()
19+
const currentUser = process.env.SUDO_USER || os.userInfo().username
2020

2121
const doc = `
2222
Usage:
@@ -156,6 +156,10 @@ const validOS = async () => {
156156
if (contents.indexOf('UBUNTU_CODENAME=noble') !== -1) {
157157
return true
158158
}
159+
160+
if (contents.indexOf('UBUNTU_CODENAME=resolute') !== -1) {
161+
return true
162+
}
159163

160164
throw new Error('Invalid OS or unable to determine Ubuntu version')
161165
} catch (err) {

0 commit comments

Comments
 (0)