Skip to content
Open
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
84 changes: 84 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,87 @@ jobs:

- name: Push to RubyGems
run: gem push try-cli-*.gem

# Upload try-linux-x86_64.tar.gz (a `try` binary at the tarball root) to the
# GitHub release. The AUR PKGBUILD fetches that asset. Spinel is not on GHA
# by default — do not clone/build matz/spinel here. This job no-ops unless
# `spinel` is already on PATH. continue-on-error so a missing native build
# never fails the gem release.
native-release:
name: Native Linux release asset
if: startsWith(github.ref, 'refs/tags/')
needs: [release]
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Build native binary if Spinel is available
run: |
if ! command -v spinel >/dev/null 2>&1; then
echo "Spinel not on runner; skip native build."
echo "Upload try-linux-x86_64.tar.gz (contains a try binary at the root) to the GitHub release so AUR can fetch it."
exit 0
fi
make native
tar -czf try-linux-x86_64.tar.gz -C dist try

- name: Upload native tarball to GitHub Release
if: hashFiles('try-linux-x86_64.tar.gz') != ''
uses: softprops/action-gh-release@v2
with:
files: try-linux-x86_64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Publish the try-cli AUR package (prebuilt native binary).
# AUR_USERNAME, AUR_EMAIL, and AUR_SSH_PRIVATE_KEY must be copied from
# tobi/try-cli's OpenSource environment onto this repo's OpenSource
# environment before this job can publish. Until those secrets exist,
# this job will fail and AUR stays at try-cli 1.5.3-1 — that is expected.
aur-publish:
name: Publish to AUR
if: startsWith(github.ref, 'refs/tags/')
needs: [release]
runs-on: ubuntu-latest
container: archlinux:latest
environment: OpenSource

steps:
- name: Install dependencies
run: pacman -Sy --noconfirm git openssh pacman-contrib base-devel sudo

- name: Setup build user
run: |
useradd -m builder
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

- name: Checkout code
uses: actions/checkout@v4

- name: Fix permissions
run: chown -R builder:builder .

- name: Update PKGBUILD version and checksums
run: |
su builder -c '
VERSION=$(cat VERSION | tr -d "\n")
sed -i "s/^pkgver=.*/pkgver=$VERSION/" PKGBUILD
updpkgsums
makepkg --printsrcinfo > .SRCINFO
'

- name: Publish to AUR
uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
with:
pkgname: try-cli
pkgbuild: ./PKGBUILD
assets: .SRCINFO
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "Update to ${{ github.ref_name }}"
force_push: true
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SHELL := /bin/bash
RUBY := ruby
SCRIPT := try.rb
TEST_DIR := tests
VERSION := $(shell cat VERSION 2>/dev/null || echo "dev")

# Default target
.PHONY: help
Expand Down Expand Up @@ -145,3 +146,10 @@ native-test: $(NATIVE)

native-compare: $(NATIVE)
bash spec/tests/runner_and_compare.sh ./try.rb $(NATIVE)

# Update PKGBUILD and .SRCINFO with current VERSION (AUR try-cli)
.PHONY: update-pkg
update-pkg: ## Sync PKGBUILD pkgver from VERSION and regenerate .SRCINFO
@perl -pi -e 's/^pkgver=.*/pkgver=$(VERSION)/' PKGBUILD
@makepkg --printsrcinfo > .SRCINFO
@echo "Updated PKGBUILD and .SRCINFO to version $(VERSION)"
17 changes: 17 additions & 0 deletions PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Maintainer: Tobi Lutke <tobi@shopify.com>
pkgname=try-cli
pkgver=1.10.1
pkgrel=1
pkgdesc="Fresh directories for every vibe (native Spinel binary)"
arch=('x86_64')
url="https://github.com/tobi/try"
license=('MIT')
depends=('glibc' 'libxcrypt')
provides=('try')
conflicts=('try')
source=("$pkgname-$pkgver-x86_64.tar.gz::https://github.com/tobi/try/releases/download/v$pkgver/try-linux-x86_64.tar.gz")
sha256sums=('SKIP')

package() {
install -Dm755 try "$pkgdir/usr/bin/try"
}
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ After installation, add to your shell:
try init ~/src/tries | source
```

## Arch Linux

Install from the AUR:

```bash
yay -S try-cli
# or
paru -S try-cli
```

This is the native Spinel binary of this repo (the old C rewrite at tobi/try-cli is archived). Then add shell integration (see Installation above). Building the native binary yourself is still optional via `make native`.

## Why Ruby?

- One file, no dependencies
Expand Down
56 changes: 56 additions & 0 deletions docs/AUR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# AUR packaging plan (`try-cli`)

Keep the user-facing install command as:

```bash
yay -S try-cli
# or
paru -S try-cli
```

Do not rename the package. Do not fight the existing community `try-cli-bin` package.

## Current AUR state

| Package | Version | Maintainer | Notes |
| --- | --- | --- | --- |
| [`try-cli`](https://aur.archlinux.org/packages/try-cli) | **1.5.3-1** | tobilu | 0 votes. Upstream is the C rewrite at [tobi/try-cli](https://github.com/tobi/try-cli). |
| [`try-cli-bin`](https://aur.archlinux.org/packages/try-cli-bin) | 1.5.3-2 | Dominiquini (tobilu co-maintainer) | Separate community binary package. Leave it alone. |

This repo takes over **`try-cli` only**. Same pkgname, same `provides=('try')` / `conflicts=('try')`, so `yay -S try-cli` keeps working. Upstream URL becomes [tobi/try](https://github.com/tobi/try). The payload is the Spinel-compiled native `dist/try` binary, not the old C rewrite (that repo is the historical snapshot).

## Why a prebuilt binary, not a source PKGBUILD

AUR cannot depend on unpublished Spinel. `make native` emits `dist/try.c` and links `libspinel_rt.a`; neither Spinel nor that runtime is on AUR. Compiling on the AUR builder is not possible today.

The PKGBUILD therefore fetches a GitHub Release asset:

- asset name: `try-linux-x86_64.tar.gz`
- contents: a `try` binary at the tarball root
- URL: `https://github.com/tobi/try/releases/download/v$pkgver/try-linux-x86_64.tar.gz`

Native links `glibc`, `libm`, and `libcrypt` (`libxcrypt` on Arch). `sha256sums` is `SKIP` in git; CI runs `updpkgsums` before publish.

Building the native binary yourself remains optional (`make native`). The AUR package is the prebuilt path for Arch users.

## What CI does

`.github/workflows/release.yml` on a version tag:

1. **`release`** — existing gem push (RubyGems trusted publishing). Must keep working.
2. **`native-release`** — optional. If `spinel` is on the runner, builds `dist/try` and uploads `try-linux-x86_64.tar.gz` via `softprops/action-gh-release`. Spinel is **not** on GitHub Actions by default; the job is `continue-on-error` and must not fail the gem release. Until Spinel is available, upload that tarball to the GitHub release by hand.
3. **`aur-publish`** — copied from try-cli: Arch container, `updpkgsums`, `KSXGitHub/github-actions-deploy-aur@v4.1.1`, pkgname `try-cli`, environment `OpenSource`.

## To actually push to AUR

Until the secrets exist on **this** repo, do not pretend AUR was updated. The live package stays 1.5.3-1.

1. Copy secrets from **tobi/try-cli**'s `OpenSource` GitHub environment onto **tobi/try**'s `OpenSource` environment:
- `AUR_USERNAME`
- `AUR_EMAIL`
- `AUR_SSH_PRIVATE_KEY`
tobi/try currently has no `OpenSource` env (it has Rubygems, github-pages, copilot). Create `OpenSource` and paste those three secrets.
2. Build `dist/try` locally (`make native`) and upload `try-linux-x86_64.tar.gz` (binary named `try` at the tarball root) to the GitHub release for `vX.Y.Z`.
3. Tag `vX.Y.Z` (or re-run the `aur-publish` job on that tag). CI updates `pkgver`, runs `updpkgsums`, and force-pushes the AUR repo.

Local helper: `make update-pkg` (perl `pkgver` from `VERSION`, then `makepkg --printsrcinfo`).