name: 'release: github' run-name: 'release: github' # PRESET — seeded once from template/presets/ (onboarding or first cascade), # then repo-owned: customize what THIS repo releases. The fleet base actions # do the heavy lifting — github-release-app-token mints the release App token, # github-release cuts the immutable 3-step release tied to the pushed tag # (create --draft → upload assets → edit --draft=false). # # Default flow: push a signed v* tag → this workflow cuts a GitHub Release for # it. A manual dispatch is a DRY-RUN (prints the cut plan) unless # `release: true`. Add build steps + assets for whatever this repo ships. # # ORDER RULE: the tag + immutable GH release are the FINAL markers of a # release — they may only exist AFTER the registry publish is live. A STAGED # npm package is not published (staging may never be approved), so this # workflow refuses to cut when the tagged version is not resolvable on its # registry (npm packument / crates.io sparse index). Registry-less repos # (private, github-release-only) skip the gate. on: workflow_dispatch: inputs: release: description: 'Cut the release for real (false = dry-run plan, the default).' type: boolean default: false tag: description: 'Tag to release. Required on dispatch (tag pushes use the pushed tag).' type: string default: '' push: tags: - 'v*' permissions: contents: read jobs: # Does this repo cut GitHub Releases at all? Read from the repo's own # settings, never hard-coded here: a member publishing to npm or crates.io # uses the release as the immutable marker its consumers and provenance # checks read, while a repo distributing through GHCR alone (the wheelhouse # and its fleet pack) would only be minting a second name for bytes nobody # fetches under it. Defaults to enabled, so a member that says nothing keeps # what it has. gate: name: Check release eligibility runs-on: ubuntu-26.04 outputs: asset_workflow: ${{ steps.flag.outputs.asset_workflow }} enabled: ${{ steps.flag.outputs.enabled }} steps: - name: Bootstrap checkout shell: bash env: GITHUB_TOKEN: ${{ github.token }} REPOSITORY: ${{ github.repository }} SERVER_URL: ${{ github.server_url }} TRIGGER_REF: ${{ github.ref }} run: | set -euo pipefail git init -q git config --local advice.detachedHead false git remote remove origin 2>/dev/null || true git remote add origin "${SERVER_URL}/${REPOSITORY}" FETCH_ARGS=(--no-tags --prune --depth 1 origin "${TRIGGER_REF}") if [ -n "${GITHUB_TOKEN}" ]; then AUTH_B64="$(printf 'x-access-token:%s' "${GITHUB_TOKEN}" | base64 | tr -d '\n')" export GIT_CONFIG_COUNT=1 export GIT_CONFIG_KEY_0="http.${SERVER_URL}/.extraheader" export GIT_CONFIG_VALUE_0="AUTHORIZATION: basic ${AUTH_B64}" git fetch "${FETCH_ARGS[@]}" else git fetch "${FETCH_ARGS[@]}" fi git checkout -q --detach FETCH_HEAD - name: Set up and install uses: ./.github/actions/fleet/setup-and-install with: socket-api-token: ${{ secrets.SOCKET_API_TOKEN_FOR_CLI_AND_SFW }} payload-token-client-id: ${{ secrets.SOCKET_RELEASE_CLIENT_ID || vars.SOCKET_RELEASE_CLIENT_ID }} payload-token-private-key: ${{ secrets.SOCKET_RELEASE_APP_PRIVATE_KEY }} - name: Read release.github id: flag run: node scripts/fleet/release/github/enabled.mts - name: Say so when the repo opts out if: steps.flag.outputs.enabled != 'true' run: | set -euo pipefail echo 'release.github is false in .config/repo/socket-wheelhouse.json — this repo does not cut GitHub Releases. Skipping.' github-release: name: Publish GitHub release needs: gate if: needs.gate.outputs.enabled == 'true' runs-on: ubuntu-26.04 permissions: actions: read contents: read steps: # Retain the current default branch's fleet actions before checking out # historical release content. The archive digest protects the retained # definitions until they are restored after checkout. - name: Bootstrap fleet Actions shell: bash env: # Route context through env (no ${{ }} in the shell body — # zizmor expression-injection). Token authorizes the fetch inline and # is never persisted to .git/config. DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} GITHUB_TOKEN: ${{ github.token }} REPOSITORY: ${{ github.repository }} SERVER_URL: ${{ github.server_url }} run: | set -euo pipefail if [ -z "${DEFAULT_BRANCH}" ]; then echo '::error::Cannot retain fleet actions: repository default branch is empty.' >&2 exit 1 fi git init -q git config --local advice.detachedHead false git remote remove origin 2>/dev/null || true git remote add origin "${SERVER_URL}/${REPOSITORY}" FETCH_ARGS=(--no-tags --prune --depth 1 origin "refs/heads/${DEFAULT_BRANCH}") if [ -n "${GITHUB_TOKEN}" ]; then AUTH_B64="$(printf 'x-access-token:%s' "${GITHUB_TOKEN}" | base64 | tr -d '\n')" export GIT_CONFIG_COUNT=1 export GIT_CONFIG_KEY_0="http.${SERVER_URL}/.extraheader" export GIT_CONFIG_VALUE_0="AUTHORIZATION: basic ${AUTH_B64}" git fetch "${FETCH_ARGS[@]}" else git fetch "${FETCH_ARGS[@]}" fi ACTIONS_SHA="$(git rev-parse 'FETCH_HEAD^{commit}')" git checkout -q --detach "${ACTIONS_SHA}" ACTUAL_SHA="$(git rev-parse 'HEAD^{commit}')" if [ "${ACTUAL_SHA}" != "${ACTIONS_SHA}" ]; then echo "::error::Fleet action source mismatch: expected ${ACTIONS_SHA}, got ${ACTUAL_SHA}." >&2 exit 1 fi tar -czf "${RUNNER_TEMP}/fleet-actions.tar.gz" .github/actions/fleet ( cd "${RUNNER_TEMP}" sha256sum fleet-actions.tar.gz > fleet-actions.tar.gz.sha256 ) printf '%s\n' "${ACTIONS_SHA}" > "${RUNNER_TEMP}/fleet-actions.sha" - name: Checkout release content id: release-source shell: bash env: GITHUB_TOKEN: ${{ github.token }} INPUT_TAG: ${{ inputs.tag }} REPOSITORY: ${{ github.repository }} SERVER_URL: ${{ github.server_url }} TRIGGER_SHA: ${{ github.sha }} run: | set -euo pipefail FETCH_REF="${TRIGGER_SHA}" if [ -n "${INPUT_TAG}" ]; then FETCH_REF="refs/tags/${INPUT_TAG}" fi FETCH_ARGS=(--no-tags --prune --depth 1 origin "${FETCH_REF}") if [ -n "${GITHUB_TOKEN}" ]; then AUTH_B64="$(printf 'x-access-token:%s' "${GITHUB_TOKEN}" | base64 | tr -d '\n')" export GIT_CONFIG_COUNT=1 export GIT_CONFIG_KEY_0="http.${SERVER_URL}/.extraheader" export GIT_CONFIG_VALUE_0="AUTHORIZATION: basic ${AUTH_B64}" git fetch "${FETCH_ARGS[@]}" else git fetch "${FETCH_ARGS[@]}" fi RELEASE_SHA="$(git rev-parse 'FETCH_HEAD^{commit}')" git checkout -q --detach "${RELEASE_SHA}" ACTUAL_SHA="$(git rev-parse 'HEAD^{commit}')" if [ "${ACTUAL_SHA}" != "${RELEASE_SHA}" ]; then echo "::error::Release source mismatch: expected ${RELEASE_SHA}, got ${ACTUAL_SHA}." >&2 exit 1 fi echo "revision=${RELEASE_SHA}" >> "${GITHUB_OUTPUT}" - name: Restore fleet Actions shell: bash run: | set -euo pipefail ( cd "${RUNNER_TEMP}" sha256sum -c fleet-actions.tar.gz.sha256 ) tar -xzf "${RUNNER_TEMP}/fleet-actions.tar.gz" -C "${GITHUB_WORKSPACE}" echo "Restored fleet actions from $(cat "${RUNNER_TEMP}/fleet-actions.sha")." - name: Hydrate release content uses: ./.github/actions/fleet/checkout with: checkout: 'false' payload-token-client-id: ${{ secrets.SOCKET_RELEASE_CLIENT_ID || vars.SOCKET_RELEASE_CLIENT_ID }} payload-token-private-key: ${{ secrets.SOCKET_RELEASE_APP_PRIVATE_KEY }} # The resolved tag is the single input every later step trusts — it # feeds the registry-liveness gate as TAG and names the release cut, so # wrong resolution here silently bypasses the publish-before-release # order rule. The branch logic lives in the dependency-free # scripts/fleet/resolve-release-tag.mjs (system Node only — no install # has run here), where the wheelhouse unit suite regression-tests it; # byte-parity with the inline predecessor is pinned per scenario. - name: Resolve tag id: tag env: EVENT_NAME: ${{ github.event_name }} INPUT_TAG: ${{ inputs.tag }} REF_NAME: ${{ github.ref_name }} run: node scripts/fleet/resolve-release-tag.mjs # Belt-and-braces publish-before-release gate: refuse to cut when the # tagged version is not actually live on its registry. Runs only when a # real cut would happen (tag push, or dispatch with release: true) so a # dry-run plan stays inspectable pre-publish. The branch logic lives in # the dependency-free scripts/fleet/registry-liveness-gate.mjs (system # Node only — no install has run here), where the wheelhouse unit suite # regression-tests it; the inline predecessor was untestable and shipped # a regressed single-crate-only gate to cargo workspaces in v1.0.13. - name: Registry publish is live if: ${{ github.event_name == 'push' || inputs.release }} env: TAG: ${{ steps.tag.outputs.tag }} run: node scripts/fleet/registry-liveness-gate.mjs - name: Set up and install if: ${{ needs.gate.outputs.asset_workflow != '' && (github.event_name == 'push' || inputs.release) }} uses: ./.github/actions/fleet/setup-and-install with: checkout: 'false' socket-api-token: ${{ secrets.SOCKET_API_TOKEN_FOR_CLI_AND_SFW }} payload-token-client-id: ${{ secrets.SOCKET_RELEASE_CLIENT_ID || vars.SOCKET_RELEASE_CLIENT_ID }} payload-token-private-key: ${{ secrets.SOCKET_RELEASE_APP_PRIVATE_KEY }} - name: Collect verified release assets id: assets if: ${{ needs.gate.outputs.asset_workflow != '' && (github.event_name == 'push' || inputs.release) }} env: GH_TOKEN: ${{ github.token }} RELEASE_ASSET_WORKFLOW: ${{ needs.gate.outputs.asset_workflow }} RELEASE_REVISION: ${{ steps.release-source.outputs.revision }} RELEASE_TAG: ${{ steps.tag.outputs.tag }} run: node scripts/fleet/release/github/assets.mts - name: Mint release-app token id: app-token uses: ./.github/actions/fleet/github-release-app-token with: client-id: ${{ secrets.SOCKET_RELEASE_CLIENT_ID || vars.SOCKET_RELEASE_CLIENT_ID }} private-key: ${{ secrets.SOCKET_RELEASE_APP_PRIVATE_KEY }} repositories: ${{ github.event.repository.name }} owner: ${{ github.repository_owner }} # Build this repo's release assets here, then list them under the cut # step's `assets:` (newline-separated paths; each must exist). - name: Cut immutable GitHub release uses: ./.github/actions/fleet/github-release with: tag: ${{ steps.tag.outputs.tag }} dry-run: ${{ (github.event_name == 'push' || inputs.release) && 'false' || 'true' }} assets: ${{ steps.assets.outputs.assets }} token: ${{ steps.app-token.outputs.token }}