Files
ask-form/.github/workflows/release.yml
gabrielvidal aecb37086d security(cli,ci,docs): default auto-upgrade to notify, harden installer/CLI/skills and pin CI actions
- Change default ASK_FORM_AUTO_UPGRADE to notify, enforce HTTPS/no-downgrade redirects,
  block pre-release auto-installs, and run smoke tests with an empty environment
- Validate browser URLs (http/https only) and relay URLs, write secrets atomically at 0600,
  add --token-file/--key-file, and harden systemd/launchd unit generation
- Enforce TLS 1.2 + strict semver tag validation in install.sh and npm publish scripts
- Validate and quote origins/keys in Claude.ai and MCP plugin zips
- Pin GitHub Actions to commit SHAs, scope job permissions, and document relay trust boundaries
2026-11-23 11:32:50 +01:00

110 lines
4.1 KiB
YAML

name: Release
# Push a tag vX.Y.Z: builds every platform, publishes a GitHub release with
# the raw binaries + checksums.txt (`ask-form upgrade`, the auto-upgrade in
# `ask-form serve` and install.sh all read from there), then the same
# binaries to npm (`npx ask-form`: Claude's code sandbox reaches npm only).
on:
push:
tags: ["v*.*.*"]
# Publish an existing release to npm again (a failed npm step): Actions →
# Release → Run workflow, or `gh workflow run release.yml -f tag=vX.Y.Z`.
# The same file, so npm's trusted publishing (bound to release.yml) holds.
workflow_dispatch:
inputs:
tag:
description: "The release to publish to npm (vX.Y.Z)"
required: true
permissions:
contents: read
jobs:
release:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7
with:
go-version: "1.24"
cache: false # stdlib only: no go.sum to key a cache on
- run: go vet ./... && go test ./...
- name: Build every platform
run: make dist VERSION="${GITHUB_REF_NAME}"
- name: Check the stamped version
run: test "$(./dist/ask-form-linux-amd64 version)" = "{\"version\":\"${GITHUB_REF_NAME}\"}"
- uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4
with:
subject-path: |
dist/ask-form*
dist/checksums.txt
- name: Publish the release
env:
GH_TOKEN: ${{ github.token }}
run: |
pre=""
case "$GITHUB_REF_NAME" in *-*) pre="--prerelease" ;; esac
gh release create "$GITHUB_REF_NAME" dist/* --verify-tag --generate-notes $pre
# npm: ask-form + one package per platform (scripts/npm-publish.sh).
# Trusted publishing (OIDC, id-token above) once each package trusts
# this workflow; until then an NPM_TOKEN secret. The very first
# publish is by hand (`npm login && scripts/npm-publish.sh vX.Y.Z
# --trust`): a package must exist before it can trust a workflow. A
# failure here never holds the GitHub release back.
# No registry-url: setup-node would write an .npmrc whose token is
# NODE_AUTH_TOKEN, and an empty one (no NPM_TOKEN secret) makes npm
# stop at ENEEDAUTH instead of trying the OIDC token (v0.18.0).
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: "24"
- name: Publish to npm
continue-on-error: true
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm install -g npm@11.10.0
if [ -n "$NPM_TOKEN" ]; then
umask 077
printf '//registry.npmjs.org/:_authToken=%s\n' "$NPM_TOKEN" > "$HOME/.npmrc"
fi
scripts/npm-publish.sh "$GITHUB_REF_NAME" --dist dist
npm:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: "24"
- name: Publish the release to npm
env:
TAG: ${{ inputs.tag }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if ! printf '%s\n' "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then
echo "not a release tag: $TAG" >&2
exit 1
fi
npm install -g npm@11.10.0
if [ -n "$NPM_TOKEN" ]; then
umask 077
printf '//registry.npmjs.org/:_authToken=%s\n' "$NPM_TOKEN" > "$HOME/.npmrc"
fi
# The binaries come from the GitHub release, checked against its
# checksums.txt.
scripts/npm-publish.sh "$TAG"