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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ jobs:
make build
docker build --progress=plain --build-arg VERSION="$(git describe --tags --always)" -t runlike-local:dev .
RUNLIKE_BIN="$PWD/build/runlike" RUNLIKE_IMAGE=runlike-local:dev go test -count=1 ./test/compat/
# The .debs from make cross, and a repository signed with a
# throwaway key, installed in debian:stable and ubuntu:24.04.
- name: apt packages and repository
env:
DOCKER_HOST: unix:///var/run/docker.sock
run: test/apt/test.sh dist

# Windows containers on Docker Engine 29.9.3: the Windows round trip, and
# the PowerShell and cmd quoting in the real shells (fuzz and live).
Expand Down
69 changes: 56 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
# publishes the GitHub release (those notes, binaries, SHA256SUMS; the macOS
# binary signed and notarized by Apple first, job build) and the
# image assaflavie/runlike:X.Y.Z (+ :latest for the newest non-prerelease),
# and, for the newest non-prerelease, the formula in lavie/homebrew-tap.
# the .deb packages (also in the release), and, for the newest
# non-prerelease, the formula in lavie/homebrew-tap and the signed APT
# repository lavie/apt (https://lavie.github.io/apt).
# A version whose release failed stays pending: the next push to master
# releases it on that newer commit.
#
# Run it by hand (Actions > release > Run workflow, on master) with a
# version: without "republish" it releases that pending version on the
# current master head (its tag must not exist); with "republish" it publishes
# the existing tag again from the tagged commit. The secrets (DOCKERHUB_TOKEN,
# HOMEBREW_TAP_TOKEN, the Apple signing and notarization secrets) live only in the environment
# HOMEBREW_TAP_TOKEN, APT_REPO_TOKEN, APT_GPG_PRIVATE_KEY, APT_GPG_PASSPHRASE,
# the Apple signing and notarization secrets) live only in the environment
# "release", which deploys from master only.
# Never publishes to PyPI.
name: release
Expand Down Expand Up @@ -168,22 +171,25 @@ jobs:
repository: lavie/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: .tap
# The formula script comes from the workflow's own commit, so a
# republish of a tag older than the script updates the tap too.
# The APT repository, for the same reason and the same versions.
- if: env.LATEST == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: lavie/apt
token: ${{ secrets.APT_REPO_TOKEN }}
path: .apt
# The formula and package scripts come from the workflow's own commit,
# so a republish of a tag older than the scripts updates them too.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: .tools
sparse-checkout: scripts/homebrew-formula.sh
sparse-checkout: |
scripts/homebrew-formula.sh
scripts/deb.sh
scripts/apt-repo.sh
LICENSE.txt
sparse-checkout-cone-mode: false
persist-credentials: false
- name: Tag the release commit
run: |
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
test "$(git rev-list -n1 "$TAG")" = "$COMMIT" || { echo "$TAG is not on $COMMIT"; exit 1; }
else
git tag "$TAG" "$COMMIT"
git push origin "refs/tags/$TAG"
fi
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-dist
Expand All @@ -197,6 +203,40 @@ jobs:
test -n "$DARWIN_SHA256"
test "$(awk '$2 == "runlike-darwin-arm64" {print $1}' SHA256SUMS)" = "$DARWIN_SHA256" \
|| { echo "runlike-darwin-arm64 is not the signed binary from build"; exit 1; }
# The .debs, from those same Linux binaries; dated by the release
# commit, so a republish builds the same bytes. deb.sh adds them to
# SHA256SUMS.
- name: .deb packages
run: |
SOURCE_DATE_EPOCH=$(git log -1 --format=%ct "$COMMIT") .tools/scripts/deb.sh "$VERSION" dist
# Sign the APT repository before the tag, so a bad key or passphrase
# stops the release here; it is pushed after the image. apt-repo.sh
# refuses a key other than the one the repository already publishes.
- name: APT repository
if: env.LATEST == 'true'
env:
APT_GPG_PRIVATE_KEY: ${{ secrets.APT_GPG_PRIVATE_KEY }}
APT_GPG_PASSPHRASE: ${{ secrets.APT_GPG_PASSPHRASE }}
run: |
command -v apt-ftparchive >/dev/null || { sudo apt-get update -q && sudo apt-get install -y -q apt-utils; }
export GNUPGHOME="$RUNNER_TEMP/gnupg"
install -d -m 700 "$GNUPGHOME"
gpg --batch --import <<<"$APT_GPG_PRIVATE_KEY"
.tools/scripts/apt-repo.sh .apt dist/runlike_*.deb
gpg --batch --verify .apt/dists/stable/InRelease
rm -rf "$GNUPGHOME"
cd .apt
git add -A
git diff --cached --quiet || git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
commit -qm "runlike $VERSION"
- name: Tag the release commit
run: |
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
test "$(git rev-list -n1 "$TAG")" = "$COMMIT" || { echo "$TAG is not on $COMMIT"; exit 1; }
else
git tag "$TAG" "$COMMIT"
git push origin "refs/tags/$TAG"
fi
- name: GitHub release
env:
GH_TOKEN: ${{ github.token }}
Expand Down Expand Up @@ -231,3 +271,6 @@ jobs:
git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
commit -qm "runlike $VERSION"
git push origin HEAD
- name: APT repository push
if: env.LATEST == 'true'
run: git -C .apt push origin HEAD
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ option of Docker CLI v29.9.3 (see [Supported options](#supported-options)).
brew install lavie/tap/runlike
```

- **apt** on Debian and Ubuntu (amd64, arm64), from the signed repository
[lavie/apt](https://github.com/lavie/apt). Once:

```
sudo install -d -m 0755 /etc/apt/keyrings
sudo curl -fsSLo /etc/apt/keyrings/runlike.asc https://lavie.github.io/apt/runlike.asc
printf 'Types: deb\nURIs: https://lavie.github.io/apt\nSuites: stable\nComponents: main\nSigned-By: /etc/apt/keyrings/runlike.asc\n' \
| sudo tee /etc/apt/sources.list.d/runlike.sources >/dev/null
```

Then `sudo apt-get update && sudo apt-get install runlike`; `apt-get
upgrade` keeps it current. Without the repository: download
`runlike_X.Y.Z_amd64.deb` (or `_arm64.deb`) from the releases page and
run `sudo apt install ./runlike_*.deb`. The package suggests the Docker
CLI but does not install it: use `docker-ce-cli`, `docker.io` or a remote
context.
- **With Go** (1.24 or later):

```
Expand Down
29 changes: 28 additions & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,16 @@ On every push to `master`:
release waits for one.
4. **publish**, in the environment `release`:
- It tags that commit `vX.Y.Z`.
- It takes the binaries and `SHA256SUMS` from build, unchanged.
- It takes the binaries and `SHA256SUMS` from build, unchanged, and
builds `runlike_X.Y.Z_amd64.deb` and `_arm64.deb` from the Linux
binaries ([scripts/deb.sh](scripts/deb.sh)), adding them to
`SHA256SUMS`.
- For the newest non-prerelease, it adds the .debs to the APT
repository [lavie/apt](https://github.com/lavie/apt) and signs it
([scripts/apt-repo.sh](scripts/apt-repo.sh)), still before the tag,
so a bad key or token stops the release there. It pushes the
repository after the image; GitHub Pages serves it at
`https://lavie.github.io/apt`.
- It creates the GitHub release with the notes file as its text and
attaches the binaries.
- It pushes the image `assaflavie/runlike:X.Y.Z` for linux/amd64 and
Expand All @@ -97,6 +106,8 @@ On every push to `master`:
([scripts/homebrew-formula.sh](scripts/homebrew-formula.sh)): the
release binaries for macOS arm64 and Linux, with their checksums.
Users install with `brew install lavie/tap/runlike`.
- It pushes the APT repository. Users install with `apt-get install
runlike` after the one-time setup in the README.

The release commit is the master commit the merge pushed, never a commit
from the pull request's branch. With a merge commit, that is the merge
Expand Down Expand Up @@ -160,6 +171,22 @@ Never publish to PyPI. The Python 1.x package is frozen.
- [ ] **The tap repository `lavie/homebrew-tap`**: public. The release
workflow writes its `Formula/runlike.rb`; do not edit that file by
hand.
- [ ] **The APT repository `lavie/apt`**: public, created with a README
(the workflow cannot check out an empty repository). Settings >
Pages: "Deploy from a branch", branch `main`, folder `/ (root)`. The
release workflow writes everything else; do not edit it by hand.
- Environment secret `APT_REPO_TOKEN`: a fine-grained GitHub token
owned by `lavie`, with access to `lavie/apt` only and the permission
Contents: Read and write. Renew it before it expires, or releases fail
before the tag.
- Environment secrets `APT_GPG_PRIVATE_KEY` (the ASCII-armored secret
key, `gpg --armor --export-secret-keys FINGERPRINT`) and
`APT_GPG_PASSPHRASE`: a dedicated ed25519 signing key that signs
nothing else, with no expiry. Keep a copy in the password manager.
Users trust the published `runlike.asc`; `scripts/apt-repo.sh`
refuses to sign with any other key. To replace the key, delete
`runlike.asc` from `lavie/apt` first, and tell users to download it
again.
- [ ] **Settings > Secrets and variables > Actions**: no repository-level
secrets. Delete `DOCKERHUB_TOKEN` there if it exists.
- [ ] **Settings > Rules > Rulesets > New branch ruleset** for `master`
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ main > section { padding: clamp(3rem, 7vw, 5.5rem) max(var(--pad), calc((100% -
.ways input.tab:checked + label.tab { color: var(--text); border-color: var(--border); border-bottom-color: var(--surface); background: var(--surface); }
.ways input.tab:focus-visible + label.tab { outline: 3px solid var(--accent); outline-offset: -3px; }
.ways .way { display: none; width: 100%; order: 1; padding: 1.4rem 0 .6rem; border-top: 1px solid var(--border); }
#way-sh:checked ~ #way-sh-panel, #way-brew:checked ~ #way-brew-panel, #way-go:checked ~ #way-go-panel, #way-docker:checked ~ #way-docker-panel { display: block; }
#way-sh:checked ~ #way-sh-panel, #way-brew:checked ~ #way-brew-panel, #way-apt:checked ~ #way-apt-panel, #way-go:checked ~ #way-go-panel, #way-docker:checked ~ #way-docker-panel { display: block; }
.copy-block { display: flex; align-items: flex-start; background: var(--term-bg); color: var(--term-text); border-radius: 10px; margin: 0 0 .8rem; }
.copy-block pre { flex: 1; min-width: 0; padding: .9rem 1rem; font: 13px/1.6 var(--mono); overflow-x: auto; }
@media (max-width: 600px) { .copy-block pre { white-space: pre-wrap; overflow-wrap: anywhere; } }
Expand Down
11 changes: 11 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ <h2>Download</h2>
<div class="ways">
<input class="tab" type="radio" name="way" id="way-sh" checked><label class="tab" for="way-sh">From the terminal</label>
<input class="tab" type="radio" name="way" id="way-brew"><label class="tab" for="way-brew">Homebrew</label>
<input class="tab" type="radio" name="way" id="way-apt"><label class="tab" for="way-apt">apt</label>
<input class="tab" type="radio" name="way" id="way-go"><label class="tab" for="way-go">With Go</label>
<input class="tab" type="radio" name="way" id="way-docker"><label class="tab" for="way-docker">Docker image</label>
<div class="way" id="way-sh-panel">
Expand All @@ -116,6 +117,16 @@ <h2>Download</h2>
<p>On macOS (Apple Silicon) and Linux, from the tap <a href="https://github.com/lavie/homebrew-tap">lavie/homebrew-tap</a>. <code>brew upgrade</code> keeps it current.</p>
<div class="copy-block"><pre><code>brew install lavie/tap/runlike</code></pre><button class="copy" type="button" hidden aria-label="Copy brew install command">Copy</button></div>
</div>
<div class="way" id="way-apt-panel">
<p>On Debian and Ubuntu (amd64, arm64), from the signed repository <a href="https://github.com/lavie/apt">lavie/apt</a>. Add it once:</p>
<div class="copy-block"><pre><code>sudo install -d -m 0755 /etc/apt/keyrings
sudo curl -fsSLo /etc/apt/keyrings/runlike.asc https://lavie.github.io/apt/runlike.asc
printf 'Types: deb\nURIs: https://lavie.github.io/apt\nSuites: stable\nComponents: main\nSigned-By: /etc/apt/keyrings/runlike.asc\n' \
| sudo tee /etc/apt/sources.list.d/runlike.sources &gt;/dev/null</code></pre><button class="copy" type="button" hidden aria-label="Copy apt repository setup commands">Copy</button></div>
<p>Then install. <code>apt-get upgrade</code> keeps it current:</p>
<div class="copy-block"><pre><code>sudo apt-get update &amp;&amp; sudo apt-get install runlike</code></pre><button class="copy" type="button" hidden aria-label="Copy apt-get install command">Copy</button></div>
<p class="small">Or download the <code>.deb</code> from the <a href="https://github.com/lavie/runlike/releases/latest">latest release</a> and <code>sudo apt install ./runlike_*.deb</code>. The Docker CLI is suggested, not installed.</p>
</div>
<div class="way" id="way-go-panel">
<p>Go 1.24 or later. Lands in <code>$(go env GOPATH)/bin</code>.</p>
<div class="copy-block"><pre><code>go install github.com/lavie/runlike/v2/cmd/runlike@latest</code></pre><button class="copy" type="button" hidden aria-label="Copy go install command">Copy</button></div>
Expand Down
50 changes: 50 additions & 0 deletions scripts/apt-repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# apt-repo.sh REPO DEB...: add the .deb files to the static APT repository
# in REPO (the checkout of lavie/apt), rebuild its indexes and sign them.
# REPO/pool/main/r/runlike/*.deb every version ever added
# REPO/dists/stable/main/binary-{amd64,arm64}/Packages{,.gz}
# REPO/dists/stable/{Release,InRelease,Release.gpg}
# REPO/runlike.asc the public signing key
# Signs with the one secret key in $GNUPGHOME; its passphrase comes from
# $APT_GPG_PASSPHRASE (may be empty). Needs apt-ftparchive (apt-utils) and gpg.
set -euo pipefail
repo=${1:?usage: apt-repo.sh REPO DEB...}
shift
[ $# -gt 0 ] || { echo "usage: apt-repo.sh REPO DEB..." >&2; exit 1; }
fpr=$(gpg --batch --with-colons --list-secret-keys | awk -F: '$1 == "fpr" {print $10; exit}')
n=$(gpg --batch --with-colons --list-secret-keys | grep -c '^sec:' || true)
[ "$n" = 1 ] || { echo "need exactly one secret key in GNUPGHOME, found $n" >&2; exit 1; }
# Users trust the key in runlike.asc: a different key would break every
# apt-get update. To rotate the key on purpose, delete runlike.asc first.
if [ -f "$repo/runlike.asc" ]; then
old=$(gpg --batch --with-colons --show-keys "$repo/runlike.asc" | awk -F: '$1 == "fpr" {print $10; exit}')
[ "$old" = "$fpr" ] || { echo "$repo is signed by $old, not by this key $fpr" >&2; exit 1; }
fi

pool=$repo/pool/main/r/runlike
mkdir -p "$pool"
cp "$@" "$pool/"
cd "$repo"
for arch in amd64 arm64; do
d=dists/stable/main/binary-$arch
mkdir -p "$d"
apt-ftparchive --arch "$arch" packages pool/main >"$d/Packages"
gzip -9nkf "$d/Packages"
done
s=dists/stable
rm -f "$s/Release" "$s/InRelease" "$s/Release.gpg"
apt-ftparchive \
-o APT::FTPArchive::Release::Origin=runlike \
-o APT::FTPArchive::Release::Label=runlike \
-o APT::FTPArchive::Release::Suite=stable \
-o APT::FTPArchive::Release::Codename=stable \
-o APT::FTPArchive::Release::Architectures="amd64 arm64" \
-o APT::FTPArchive::Release::Components=main \
-o APT::FTPArchive::Release::Description="runlike, github.com/lavie/runlike" \
release "$s" >Release.tmp
mv Release.tmp "$s/Release"
sign() { gpg --batch --yes --pinentry-mode loopback --passphrase-fd 3 --local-user "$fpr" "$@" 3<<<"${APT_GPG_PASSPHRASE:-}"; }
sign --clearsign -o "$s/InRelease" "$s/Release"
sign --armor --detach-sign -o "$s/Release.gpg" "$s/Release"
gpg --batch --armor --export "$fpr" >runlike.asc
touch .nojekyll # GitHub Pages: serve the files as they are
45 changes: 45 additions & 0 deletions scripts/deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# deb.sh VERSION DIST: build runlike_VERSION_amd64.deb and _arm64.deb in
# DIST from DIST/runlike-linux-amd64 and -arm64 (make cross output), and
# add them to DIST/SHA256SUMS. VERSION is the tag without v; a
# pre-release 2.1.0-rc.1 becomes the Debian version 2.1.0~rc.1, which
# sorts before 2.1.0. Needs dpkg-deb. Reproducible: file times and the
# archive come from SOURCE_DATE_EPOCH (default: 0).
set -euo pipefail
v=${1:?usage: deb.sh VERSION DIST}
dist=${2:?usage: deb.sh VERSION DIST}
[[ $v =~ ^[0-9][0-9A-Za-z.+-]*$ ]] || { echo "bad version: $v" >&2; exit 1; }
here=$(cd "$(dirname "$0")" && pwd)
export SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-0}
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
for arch in amd64 arm64; do
r=$tmp/$arch
install -d "$r/DEBIAN" "$r/usr/bin" "$r/usr/share/doc/runlike"
install -m 0755 "$dist/runlike-linux-$arch" "$r/usr/bin/runlike"
install -m 0644 "$here/../LICENSE.txt" "$r/usr/share/doc/runlike/copyright"
# Suggests, not Recommends: apt installs Recommends by default, and
# docker.io would pull in a whole Docker Engine. People use
# docker-ce-cli, Debian's docker-cli, docker.io or a remote context.
cat >"$r/DEBIAN/control" <<-EOF
Package: runlike
Version: ${v//-/\~}
Architecture: $arch
Maintainer: Assaf Lavie <a@assaflavie.com>
Installed-Size: $(du -sk "$r/usr" | cut -f1)
Suggests: docker-ce-cli | docker-cli | docker.io
Section: admin
Priority: optional
Homepage: https://github.com/lavie/runlike
Description: print the docker run command that recreates a container
runlike reads docker inspect output and prints the docker run command
line, with every option, that runs another container just like it.
EOF
find "$r" -exec touch -h -d "@$SOURCE_DATE_EPOCH" {} +
dpkg-deb --root-owner-group -Zxz --build "$r" "$dist/runlike_${v}_$arch.deb" >/dev/null
echo "$dist/runlike_${v}_$arch.deb"
done
cd "$dist"
# Keep SHA256SUMS one line per file: drop old .deb lines, then add.
{ grep -v '\.deb$' SHA256SUMS || true; sha256sum runlike_*.deb; } >"$tmp/sums"
mv "$tmp/sums" SHA256SUMS
Loading