stoke/.forgejo/workflows/release.yml
Claude f5615455bf Add apt distribution: deb packaging, registry publish, docs (#1)
Implements #1 — stoke installable with apt-get install stoke.

Packaging:
- scripts/build-deb.sh: builds dist/stoke_<version>_all.deb from a clean
  staging copy (src + fresh npm ci --omit=dev), pure-JS Architecture: all,
  Depends: nodejs (>= 22.12), /usr/lib/stoke payload with /usr/bin/stoke
  symlink, copyright + changelog, normalized permissions. Lintian-clean.
- scripts/publish-deb.sh: uploads a .deb to the Forgejo Debian registry
  (owner/distribution/component parameterized, defaults heavy-duty/
  stable/main), authenticating with STOKE_TOKEN or the stoke login token.
- scripts/install-apt.sh: consumer-side one-time setup — adds the
  registry key and apt source, then apt-get install stoke. Falls back to
  a [trusted=yes] source when apt's sqv verifier rejects the forge's
  registry signature (known upstream Forgejo signing bug; the script
  prefers the signed source so setups heal once the forge is fixed).
- .forgejo/workflows/release.yml: on v* tags — test, build, publish to
  the heavy-duty registry, attach the .deb to the release page. Needs a
  runner and a RELEASE_TOKEN secret with org package write.

New command:
- stoke pr merge (-n, --method merge|rebase|rebase-merge|squash,
  --title, --message, --delete-branch) — gap found while merging !2.

Docs and housekeeping:
- README: 'Install with apt' as the primary installation method with
  manual setup and dpkg fallback, signature caveat, pr merge reference,
  Packaging and releasing section with a release checklist.
- dist/ gitignored; version bumped to 1.2.0.

Verified end-to-end on this machine: built the deb (lintian-clean),
published it to the Forgejo Debian registry, installed it with
apt-get install stoke via install-apt.sh, and confirmed the installed
CLI works against the live forge. The test upload was removed from the
personal namespace afterwards; publishing under heavy-duty needs an
org-member token (401 reqPackageAccess with this restricted account).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 19:41:02 +00:00

56 lines
2.2 KiB
YAML

# Release automation: on every v* tag, build the Debian package, publish it
# to the Forgejo Debian registry (owner: heavy-duty) and attach the .deb to
# the tag's release page as a fallback for direct `dpkg -i` installs.
#
# Requirements:
# - A Forgejo Actions runner on the instance. Adjust `runs-on` to a label
# your runner actually advertises (common: docker, ubuntu-latest).
# - A repository/org secret RELEASE_TOKEN: a token with package:write and
# repository:write scopes for an account allowed to publish packages
# under the heavy-duty org.
name: release
on:
push:
tags:
- 'v*'
jobs:
deb:
runs-on: docker
container:
image: node:22-bookworm
steps:
- name: Check out tag
uses: actions/checkout@v4
- name: Run tests
run: npm ci && npm test
- name: Build .deb
run: bash scripts/build-deb.sh
- name: Publish to Debian registry
env:
STOKE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: bash scripts/publish-deb.sh dist/stoke_*_all.deb heavy-duty stable main
- name: Create release and attach .deb
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
TAG: ${{ github.ref_name }}
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
run: |
set -euo pipefail
DEB=$(ls dist/stoke_*_all.deb)
# Create the release if it does not exist yet, then grab its id.
RELEASE_ID=$(curl -sf -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG" | node -pe "JSON.parse(require('fs').readFileSync(0,'utf8')).id" 2>/dev/null || true)
if [ -z "$RELEASE_ID" ]; then
RELEASE_ID=$(curl -sf -X POST -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"draft\":false,\"prerelease\":false}" \
"$API/releases" | node -pe "JSON.parse(require('fs').readFileSync(0,'utf8')).id")
fi
curl -sf -X POST -H "Authorization: token $TOKEN" \
-F "attachment=@$DEB" \
"$API/releases/$RELEASE_ID/assets?name=$(basename "$DEB")" >/dev/null
echo "Attached $(basename "$DEB") to release $TAG"