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
182 changes: 182 additions & 0 deletions .github/workflows/prep-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
name: Prepare Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.0.2)'
required: true
type: string

env:
CARGO_TERM_COLOR: always

jobs:
create-tag:
name: Create Tag
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ steps.create_tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Update version in Cargo.toml
run: |
sed -i.bak 's/^version = ".*"/version = "${{ inputs.version }}"/' Cargo.toml
rm Cargo.toml.bak
git add Cargo.toml
git commit -m "Bump version to ${{ inputs.version }}"
git push

- name: Create and push tag
id: create_tag
run: |
TAG="v${{ inputs.version }}"
echo "Creating tag: $TAG"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT

build:
name: Build ${{ matrix.target }}
needs: create-tag
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# macOS Apple Silicon
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: nb
asset_name: nb-macos-arm64

# macOS Intel
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: nb
asset_name: nb-macos-amd64

# Linux x86_64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: nb
asset_name: nb-linux-amd64

# Linux ARM64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact_name: nb
asset_name: nb-linux-arm64

# Windows
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: nb.exe
asset_name: nb-windows-amd64.exe

steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-tag.outputs.tag }}

- name: Set up Rust cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Install cross-compilation tools (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu

- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}

- name: Strip binary (Linux/macOS)
if: matrix.os != 'windows-latest'
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}

create-draft-release:
name: Create Draft Release
needs: [create-tag, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-tag.outputs.tag }}

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Prepare release assets
run: |
mkdir -p release-assets
find artifacts -type f -exec cp {} release-assets/ \;
cd release-assets
chmod +x nb-* || true
ls -lh

- name: Generate checksums
run: |
cd release-assets
sha256sum * > SHA256SUMS || shasum -a 256 * > SHA256SUMS
cat SHA256SUMS

- name: Create Draft Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ needs.create-tag.outputs.tag }} \
--draft \
--title "${{ needs.create-tag.outputs.tag }}" \
--notes "Draft release for ${{ needs.create-tag.outputs.tag }}

See \`SHA256SUMS\` in the assets for checksums.

**Note**: Review the binaries before publishing." \
release-assets/*

- name: Summary
run: |
echo "## ✅ Draft Release Created" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tag**: ${{ needs.create-tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "**Release**: https://github.com/${{ github.repository }}/releases/tag/${{ needs.create-tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Next Steps" >> $GITHUB_STEP_SUMMARY
echo "1. Review the draft release" >> $GITHUB_STEP_SUMMARY
echo "2. Test the binaries" >> $GITHUB_STEP_SUMMARY
echo "3. Run the \`Release\` workflow to publish to crates.io and GitHub" >> $GITHUB_STEP_SUMMARY
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Release

on:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
find-draft:
name: Find Draft Release
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
tag: ${{ steps.find_draft.outputs.tag }}
steps:
- uses: actions/checkout@v4

- name: Find draft release
id: find_draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DRAFT_TAG=$(gh release list --json isDraft,tagName --jq '.[] | select(.isDraft==true) | .tagName' | head -n 1)

if [ -z "$DRAFT_TAG" ]; then
echo "❌ No draft release found"
exit 1
fi

echo "Found draft release: $DRAFT_TAG"
echo "tag=$DRAFT_TAG" >> $GITHUB_OUTPUT

publish-crates:
name: Publish to crates.io
needs: find-draft
runs-on: ubuntu-latest
permissions:
id-token: write # Required for trusted publishing
contents: read
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.find-draft.outputs.tag }}

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Publish to crates.io
run: cargo publish

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo publish with no CARGO_REGISTRY_TOKEN assumes trusted publishing is configured on crates.io for this repo. If not, this will fail. Worth double checking.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, I will turn it on once the release.yml is merged.


publish-github:
name: Publish GitHub Release
needs: find-draft
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.find-draft.outputs.tag }}

- name: Publish Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release edit ${{ needs.find-draft.outputs.tag }} --draft=false

- name: Summary
run: |
echo "## ✅ Release Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tag**: ${{ needs.find-draft.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "**Release**: https://github.com/${{ github.repository }}/releases/tag/${{ needs.find-draft.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "**Crates.io**: https://crates.io/crates/nb-cli" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Next Steps" >> $GITHUB_STEP_SUMMARY
echo "1. Verify the release on GitHub" >> $GITHUB_STEP_SUMMARY
echo "2. Check that crates.io shows the new version" >> $GITHUB_STEP_SUMMARY
echo "3. Test installation: \`cargo install nb-cli\`" >> $GITHUB_STEP_SUMMARY
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,38 @@ A fast, programmatic command-line interface for working with Jupyter notebooks.

## Installation

### Quick Install (macOS Apple Silicon only)

```bash
curl -fsSL https://raw.githubusercontent.com/jupyter-ai-contrib/nb-cli/main/install.sh | bash
```

This installs the binary to `~/.nb-cli/bin/nb`. Follow the instructions to add it to your PATH.

**Note**: Pre-built binaries are currently only available for macOS Apple Silicon (M1/M2/M3/M4). For other platforms, please use `cargo install` or build from source.

@andrii-i andrii-i Mar 13, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Note to bring attention, not a request for change)
This is accurate for v0.0.1 but prep-release.yml also builds macOS arm64/amd64, Linux amd64/arm64, Windows. So we should update this after next release.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, have to verify those actually work in the CI yet, will update README after that.


### Manual Binary Download

**macOS (Apple Silicon - M1/M2/M3/M4)**:
```bash
curl -L https://github.com/jupyter-ai-contrib/nb-cli/releases/download/v0.0.1/nb-macos-arm64 -o nb
chmod +x nb
sudo mv nb /usr/local/bin/
```

**Other platforms**: Use `cargo install nb-cli` or build from source (see below).

### Install from crates.io

```bash
cargo install nb-cli
```

### Build from Source

```bash
git clone https://github.com/jupyter-ai-contrib/nb-cli.git
cd nb-cli
cargo build --release
```

Expand Down
Loading
Loading