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
4 changes: 2 additions & 2 deletions .agents/skills/publishing-dim-nightlies/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Fetch `origin/main` and read remote tags with `git ls-remote --tags --refs origi

For an authorized publication, choose one entry point:

- By default, or to pin an exact source commit, push only the new tag at the selected main SHA.
- For a requested manual run, first check that `origin/main` has `workflow_dispatch` in `.github/workflows/nightly.yml`. In **Publish curl nightly → Run workflow**, select `main` and enter the unused tag. The run creates the tag at the dispatch commit; do not push it yourself. Verify the resulting tag's source before reporting the release.
- To publish the current `main` head by tag, push only the new tag. For a historical source, dispatch from `main` instead, so the historical workflow does not publish.
- For a manual run, select `main` in **Publish curl nightly → Run workflow** and enter the unused tag. For a pinned source, check that the workflow on `origin/main` accepts `source`, then enter the full commit SHA. The run creates the tag; do not push it yourself. Verify the resulting tag's source before reporting the release.

If the tag is taken, inspect its source and run; never move or reuse it. On failure, report the failed job and run URL without rerunning it or triggering a replacement build. Select the next number on the next release request.

Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
description: Unused nightly tag (vX.Y.Z-nightly.N)
required: true
type: string
source:
description: Optional full SHA of a main ancestor (defaults to the dispatched commit)
type: string
permissions:
contents: read
jobs:
Expand All @@ -30,11 +33,17 @@ jobs:
shell: bash
env:
MANUAL_TAG: ${{ inputs.tag }}
MANUAL_SOURCE: ${{ inputs.source }}
run: |
sha=$(git rev-parse HEAD)
if [[ "$GITHUB_EVENT_NAME" == workflow_dispatch ]]; then
[[ "$GITHUB_REF" == refs/heads/main ]] || { echo 'Select main to publish a nightly.' >&2; exit 1; }
[[ "$sha" == "$GITHUB_SHA" ]] || { echo 'Checkout does not match the dispatched commit.' >&2; exit 1; }
if [[ -n "$MANUAL_SOURCE" ]]; then
[[ "$MANUAL_SOURCE" =~ ^[0-9a-f]{40}$ && $(git cat-file -t "$MANUAL_SOURCE") == commit ]] || { echo 'Expected a full source commit SHA.' >&2; exit 1; }
git merge-base --is-ancestor "$MANUAL_SOURCE" "$sha" || { echo 'Source must be an ancestor of the dispatched main commit.' >&2; exit 1; }
sha=$MANUAL_SOURCE
fi
tag=$MANUAL_TAG
else
[[ $(git rev-parse "$GITHUB_REF^{commit}") == "$sha" ]] || { echo 'Checkout does not match the pushed tag.' >&2; exit 1; }
Expand All @@ -43,6 +52,7 @@ jobs:
n='(0|[1-9][0-9]*)'
[[ "$tag" =~ ^v$n\.$n\.$n-nightly\.$n$ ]] || { echo 'Expected a nightly tag in the form vX.Y.Z-nightly.N.' >&2; exit 1; }
git merge-base --is-ancestor "$sha" origin/main
git checkout --detach "$sha"
printf 'sha=%s\ntag=%s\n' "$sha" "$tag" >> "$GITHUB_OUTPUT"
- name: Reserve the manually requested tag
if: github.event_name == 'workflow_dispatch'
Expand Down Expand Up @@ -171,7 +181,7 @@ jobs:
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
ref: ${{ needs.prepare.outputs.sha }}
ref: refs/heads/main
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
Expand Down
10 changes: 5 additions & 5 deletions docs/release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ Run `dim-nightly` from `~/.local/bin`. Installation and upgrades also offer `dim

Nightly (`X.Y.Z-nightly.N`) and npm alpha (`X.Y.Z-alpha.N`) number releases independently. Start a nightly without a version PR in either of two ways:

- Push a new `vX.Y.Z-nightly.N` tag on a commit from `main`.
- In Actions, open **Publish curl nightly → Run workflow**, select `main`, and enter an unused `vX.Y.Z-nightly.N` tag. The run creates the tag at the `main` commit selected when the workflow was dispatched, before starting any platform builds. Dispatches off `main` and attempts to reuse a tag are rejected. Creating the tag must not start a second run.
- Push a new `vX.Y.Z-nightly.N` tag at the current `main` head.
- In Actions, open **Publish curl nightly → Run workflow**, select `main`, and enter an unused `vX.Y.Z-nightly.N` tag. Leave `source` empty to build the dispatched `main` commit or enter the full SHA of an ancestor to build an older commit. The run reserves the tag at the chosen source before starting any platform builds. Dispatches off `main` and attempts to reuse a tag are rejected. Creating the tag must not start a second run.

Both entry points use the version tag to identify the exact source and share the same build and publish jobs. Check the tag and source, then build and pack macOS and GNU/Linux x64 and arm64 in parallel. On each native runner, run only the packaged CLI's `--version` and compare it with the tag. Publish only when all four archives and their SHA-256 checksums are present; do not publish to npm or GHCR.
Both entry points use the version tag to identify the exact build source. The serialized publish job uses the current `main` publisher and publishes the tagged build's archives and source SHA. Use dispatch for older commits: pushing a tag at a historical commit can start the workflow from that commit, bypassing the current publisher. Let any already-started runs using the legacy publisher finish before the first release under the one-version policy. Check the tag and source, then build and pack macOS and GNU/Linux x64 and arm64 in parallel. On each native runner, run only the packaged CLI's `--version` and compare it with the tag. Publish only when all four archives and their SHA-256 checksums are present; do not publish to npm or GHCR.

Use a separate nightly workflow and concurrency group. Publish to one rolling GitHub prerelease at `releases/tag/Nightly`, not a Release per version. `Nightly` is the channel entry, not a build trigger or a source identifier. Never mark it Latest or modify alpha releases, tags, assets or npm dist-tags.

Run the platform matrix with `fail-fast: true`. On the first platform failure, cancel remaining builds and skip publication and pruning. Do not retry a failed step or run; the tag remains reserved and the next requested release gets a new number. The nightly workflow does not rerun PR/main lint, workspace tests or E2E suites. Test installer upgrades, checksum failures and retention when changing those mechanisms, not before each nightly.

Updates stay within the installation's channel. The npm alpha client keeps checking npm. The nightly client does not check npm; users rerun the same curl installer to upgrade. The installer reads the promoted version from the rolling release, verifies that version's platform archive, and switches only the nightly installation. If either channel is unavailable, it does not fall back to the other.
Updates stay within the installation's channel. The npm alpha client keeps checking npm. The nightly client does not check npm; users rerun the same curl installer to upgrade. The installer reads the promoted version from the rolling release and verifies that version's platform archive before switching the nightly installation. If an asset returns HTTP 404 during a promotion, the installer refreshes release metadata and retries the selected set once. A checksum failure is not retried and leaves the installed version in place. If either channel is unavailable, it does not fall back to the other.

Serve `scripts/install-nightly.sh` from `main`. Give archives and checksums version-specific names. Serialize publication: upload the complete set before updating the advertised version, never promote an older build over a newer one, and prune only obsolete nightly assets after promotion. Keep the three highest complete nightly versions on the rolling release and retain their source tags, including tags for pruned builds. The [nightly release skill](../../.agents/skills/publishing-dim-nightlies/SKILL.md) covers preparation and publication.
Serve `scripts/install-nightly.sh` from `main`. Give archives and checksums version-specific names. Serialize publication: upload the complete set before updating the advertised version, never promote an older build over a newer one, and prune only obsolete nightly assets after promotion. Keep only the latest complete nightly version on the rolling release, and retain source tags for all builds, including pruned builds. The [nightly release skill](../../.agents/skills/publishing-dim-nightlies/SKILL.md) covers preparation and publication.

## Version preparation

Expand Down
20 changes: 13 additions & 7 deletions scripts/install-nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ install_nightly() (
elif [ -e "$entry" ]; then fail "Refusing to replace $entry"; fi

repo=arcships/dim
curl -fsSL "https://api.github.com/repos/$repo/releases/tags/Nightly" -o "$lock/release.json"
version=$(jq -er 'select(.tag_name == "Nightly" and .prerelease and (.draft | not)) | .name | capture("^Nightly v(?<v>[0-9]+\\.[0-9]+\\.[0-9]+-nightly\\.[0-9]+)$").v' "$lock/release.json")
dest=$root/$version
if [ ! -d "$dest" ]; then
base=https://github.com/$repo/releases/download/Nightly
base=https://github.com/$repo/releases/download/Nightly
for attempt in 1 2; do
curl -fsSL "https://api.github.com/repos/$repo/releases/tags/Nightly" -o "$lock/release.json"
version=$(jq -er 'select(.tag_name == "Nightly" and .prerelease and (.draft | not)) | .name | capture("^Nightly v(?<v>[0-9]+\\.[0-9]+\\.[0-9]+-nightly\\.[0-9]+)$").v' "$lock/release.json")
dest=$root/$version
[ ! -d "$dest" ] || break
archive=dimcode-$os-$arch-$version.tar.gz
curl -fsSL "$base/SHA256SUMS-$version" -o "$lock/sums"
curl -fsSL "$base/$archive" -o "$lock/$archive"
if status=$(curl -fsSL "$base/SHA256SUMS-$version" -o "$lock/sums" -w '%{http_code}') &&
status=$(curl -fsSL "$base/$archive" -o "$lock/$archive" -w '%{http_code}'); then
break
fi
[ "$status" = 404 ] && [ "$attempt" = 1 ] || fail "Could not download Nightly assets for $version (HTTP $status)"
done
if [ ! -d "$dest" ]; then
expected=$(awk -v file="$archive" '$2 == file { print $1 }' "$lock/sums")
if [ "$os" = darwin ]; then actual=$(shasum -a 256 "$lock/$archive"); else actual=$(sha256sum "$lock/$archive"); fi
[ "$expected" = "${actual%% *}" ] || fail "Checksum mismatch for $archive"
Expand Down
44 changes: 38 additions & 6 deletions scripts/nightly.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { tmpdir } from 'node:os';
import path from 'node:path';
import test from 'node:test';

test('rolling nightly installs only complete releases and retains the three highest versions', { skip: process.platform === 'win32' }, t => {
test('rolling nightly installs only complete releases and retains only the latest version', { skip: process.platform === 'win32' }, t => {
const root = mkdtempSync(path.join(tmpdir(), 'dim-nightly-'));
t.after(() => rmSync(root, { recursive: true, force: true }));
const file = (...parts) => path.join(root, ...parts);
const env = { ...process.env, HOME: root, XDG_DATA_HOME: file('data'), PATH: `${root}:${process.env.PATH}` };
const env = { ...process.env, HOME: root, XDG_DATA_HOME: file('data'), RELEASE_FIXTURE: root, PATH: `${root}:${process.env.PATH}` };
const assets = file('assets');
mkdirSync(assets);
mkdirSync(file('payload/bin'), { recursive: true });
Expand All @@ -27,8 +27,23 @@ esac\n`, { mode: 0o755 });
writeFileSync(file('curl'), `#!/bin/sh
set -eu
case "$2" in
https://api.github.com/repos/arcships/dim/releases/tags/Nightly) cp "$HOME/release" "$4";;
https://github.com/arcships/dim/releases/download/Nightly/*) cp "$HOME/assets/\${2##*/}" "$4";;
https://api.github.com/repos/arcships/dim/releases/tags/Nightly)
if [ -f "$RELEASE_FIXTURE/stale-release" ]; then
mv "$RELEASE_FIXTURE/stale-release" "$4"
else
cp "$RELEASE_FIXTURE/release" "$4"
fi;;
https://github.com/arcships/dim/releases/download/Nightly/*)
asset=\${2##*/}
if [ "$asset" = SHA256SUMS-1.2.3-nightly.9 ] && [ -f "$RELEASE_FIXTURE/stale-sums" ]; then
mv "$RELEASE_FIXTURE/stale-sums" "$4"
elif [ -f "$RELEASE_FIXTURE/assets/$asset" ]; then
cp "$RELEASE_FIXTURE/assets/$asset" "$4"
else
printf 404
exit 22
fi
if [ "\${5:-}" = -w ]; then printf 200; fi;;
*) exit 2;;
esac\n`, { mode: 0o755 });
const platforms = ['linux-arm64', 'linux-x64', 'darwin-arm64', 'darwin-x64'];
Expand All @@ -40,7 +55,9 @@ esac\n`, { mode: 0o755 });
const run = spawnSync(process.execPath, [path.join(import.meta.dirname, 'publish-nightly.mjs'), dir, `v${v}`, 'a'.repeat(40)], { env, encoding: 'utf8' });
assert.equal(run.status === 0, ok, run.stderr);
}
const install = () => spawnSync('sh', [path.join(import.meta.dirname, 'install-nightly.sh')], { env, encoding: 'utf8' });
const install = (home = root) => spawnSync('sh', [path.join(import.meta.dirname, 'install-nightly.sh')], {
env: { ...env, HOME: home, XDG_DATA_HOME: path.join(home, 'data') }, encoding: 'utf8', timeout: 5000,
});
const installed = (command = 'dim-nightly') => execFileSync(file('.local/bin', command), ['--version'], { env, encoding: 'utf8' }).trim();
const shortcut = file('.local/bin/dimn');
const release = () => JSON.parse(readFileSync(file('release'))).name;
Expand All @@ -56,19 +73,34 @@ esac\n`, { mode: 0o755 });
writeFileSync(file('interrupt'), '');
publish(12, false);
assert.equal(release(), 'Nightly v1.2.3-nightly.8');
assert.equal(install(file('fresh-after-interruption')).status, 0);
rmSync(file('interrupt'));
publish(9);
const oldRelease = readFileSync(file('release'));
const oldSums = readFileSync(file('assets/SHA256SUMS-1.2.3-nightly.9'));
publish(11);
publish(10);
assert.equal(release(), 'Nightly v1.2.3-nightly.11');
const expected = [9, 10, 11].flatMap(n => [...platforms.map(p => `dimcode-${p}-1.2.3-nightly.${n}.tar.gz`), `SHA256SUMS-1.2.3-nightly.${n}`]);
const expected = [...platforms.map(p => `dimcode-${p}-1.2.3-nightly.11.tar.gz`), 'SHA256SUMS-1.2.3-nightly.11'];
assert.deepEqual(readdirSync(assets).sort(), [...expected, 'unrelated.txt'].sort());
const tar = file('assets', `dimcode-${process.platform}-${process.arch}-1.2.3-nightly.11.tar.gz`);
const bytes = readFileSync(tar);
writeFileSync(tar, 'corrupted');
assert.match(install().stderr, /Checksum mismatch/);
assert.equal(installed(), 'dimcode 1.2.3-nightly.8');
writeFileSync(tar, bytes);
for (const missing of ['checksum', 'archive']) {
writeFileSync(file('stale-release'), oldRelease);
if (missing === 'archive') writeFileSync(file('stale-sums'), oldSums);
const home = file(`promotion-before-${missing}`);
const run = install(home);
assert.equal(run.status, 0, `Expected recovery when promotion removes the ${missing}: ${run.stderr}`);
assert.equal(execFileSync(path.join(home, '.local/bin/dim-nightly'), ['--version'], { encoding: 'utf8' }).trim(), 'dimcode 1.2.3-nightly.11');
}
rmSync(tar);
assert.match(install().stderr, /Could not download Nightly assets.*404/);
assert.equal(installed(), 'dimcode 1.2.3-nightly.8');
writeFileSync(tar, bytes);
for (let i = 0; i < 2; i++) {
const run = install();
assert.equal(run.status, 0, run.stderr);
Expand Down
5 changes: 2 additions & 3 deletions scripts/publish-nightly.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ for (const name of names) {
sets.get(v).push(name);
}
const latest = !promoted || compare(current, promoted) < 0 ? current : promoted;
const keep = [...sets.keys()].filter(v => compare(v, latest) >= 0 && sets.get(v).length === 5).sort(compare).slice(0, 3);
assert(keep.includes(latest));
assert.equal(sets.get(latest)?.length, 5, `Incomplete Nightly asset set for ${latest}`);
for (const [v, files] of sets) {
if (!keep.includes(v)) for (const file of files) gh('release', 'delete-asset', 'Nightly', file, '--yes');
if (v !== latest) for (const file of files) gh('release', 'delete-asset', 'Nightly', file, '--yes');
}