Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Build bitcurator-cli

on:
push:
branches: [main]
tags:
- 'v*'
pull_request:
branches: [main]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js 24
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linter
run: npm run lint --if-present

- name: Fetch tags
run: git fetch --prune --unshallow --tags 2>/dev/null || git fetch --prune --tags 2>/dev/null || true

- name: Prepare package config
run: |
VERSION=$(jq -r '.version' package.json)
EXACT_TAG=$(git describe --exact-match 2>/dev/null | sed -e 's/^v//g' || echo "")
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
REVISION=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")

# If we're on an exact tag, use it
if echo "$EXACT_TAG" | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+(-rc\.?[0-9]+)?$"; then
FINAL_VERSION="$EXACT_TAG"
elif [ -n "$LAST_TAG" ]; then
COMMITS=$(git log --oneline ${LAST_TAG}..HEAD | wc -l | tr -d '[:space:]')
FINAL_VERSION="${VERSION}.${COMMITS}.g${REVISION}"
else
FINAL_VERSION="${VERSION}.0.g${REVISION}"
fi

echo "{\"version\":\"${FINAL_VERSION}\"}" > config.json
echo "Generated config.json with version: ${FINAL_VERSION}"
cat config.json

- name: Build executable
run: npm run pkg:build

- name: Generate checksum
run: npm run pkg:hash

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Sign checksum
run: |
cd release
gpg --armor --clearsign --digest-algo SHA256 -u 1ACB8887 bitcurator-cli-linux.sha256
rm bitcurator-cli-linux.sha256

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: bitcurator-cli-linux
path: |
release/bitcurator-cli-linux
release/bitcurator-cli-linux.sha256.asc

release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')

permissions:
contents: write

steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: bitcurator-cli-linux
path: release

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
release/bitcurator-cli-linux
release/bitcurator-cli-linux.sha256.asc
generate_release_notes: true
30 changes: 26 additions & 4 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,26 @@ This documentation is intended for developers and maintainers. To install BitCur
- jq
- gpg
- git
- nodejs (minimum v22, with npm - see instructions [here](https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions))
- nodejs (v24, with npm - see instructions [here](https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions))

```bash
$ sudo apt-get install jo jq gpg nodejs npm
$ sudo apt-get install jo jq gpg
```

```bash
# Follow the instructions at: https://nodejs.org/en/download (example here)
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"
# Download and install Node.js:
nvm install 24
# Verify the Node.js version:
node -v # Should print "v24.11.1".
# Verify npm version:
npm -v # Should print "11.6.2".
```

### Modifying
To customize the CLI, it's important to change the following spots in the CLI (as desired):
#### xxx-cli.js
Expand All @@ -38,7 +53,7 @@ Important areas to modify:
### Building
Change to the CLI directory and run the following:
```bash
$ sudo npm install -g pkg docopt @octokit/rest js-yaml mkdirp openpgp semver split username
$ sudo npm install -g pkg docopt @octokit/rest js-yaml mkdirp openpgp semver split
$ npm install
```
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.
Expand All @@ -49,7 +64,14 @@ While still in the directory, run: `npm run pkg`

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.

### Release
### Release (new style, GitHub Workflow)
There is a workflow in .github/workflows/build.yml. It includes:

Triggers: Runs on pushes/PRs to main, version tags (v\*), and manual dispatch
Build job: Sets up Node 24, installs dependencies, runs the linter if present, and builds the executable with checksum
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)

### Release (old style, manual)
First thing to do would be to add, commit, and push to the repo:
```bash
$ git add -A
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
# bitcurator-cli

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

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.
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).

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.
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.

## BitCurator documentation, help, and discussions

Expand Down
8 changes: 6 additions & 2 deletions bitcurator-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const docopt = require('docopt').docopt
const { Octokit } = require('@octokit/rest')
const { mkdirp } = require('mkdirp')
const openpgp = require('openpgp')
const username = require('username')

const readline = require('readline')
const split = require('split')
const execAsync = promisify(child_process.exec)
const yaml = require('js-yaml')

const currentUser = process.env.SUDO_USER || username.sync()
const currentUser = process.env.SUDO_USER || os.userInfo().username

const doc = `
Usage:
Expand Down Expand Up @@ -156,6 +156,10 @@ const validOS = async () => {
if (contents.indexOf('UBUNTU_CODENAME=noble') !== -1) {
return true
}

if (contents.indexOf('UBUNTU_CODENAME=resolute') !== -1) {
return true
}

throw new Error('Invalid OS or unable to determine Ubuntu version')
} catch (err) {
Expand Down
Loading