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
29 changes: 25 additions & 4 deletions .github/workflows/ci-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,41 @@ on:
required: false

jobs:
windows:
name: Windows eligibility
if: inputs.windows && (github.event_name == 'schedule' || ((github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') && (inputs.windows-merge-queue || inputs.windows-pull-requests)))
runs-on: ${{ vars.RUNNER_CI || 'ubuntu-latest' }}
timeout-minutes: 5
permissions:
contents: read
outputs:
visibility: ${{ steps.visibility.outputs.visibility }}
steps:
- name: Read the repository visibility
id: visibility
env:
GH_TOKEN: ${{ github.token }}
run: |
visibility=$(gh api "repos/$GITHUB_REPOSITORY" --jq .visibility)
echo "visibility=$visibility" >> "$GITHUB_OUTPUT"

node:
needs: windows
if: ${{ !cancelled() && needs.windows.result != 'failure' }}
name: ${{ matrix.part == 'test' && 'Test' || matrix.part == 'extra' && 'Extra' || 'Node' }} ${{ matrix.node-version || '.nvmrc' }}${{ matrix.os == 'windows-latest' && ' on Windows' || '' }}
# Linux legs on our runners when the CALLING repository's variable RUNNER_CI names a scale set (the
# private repositories: antelope-ci), and on GitHub's runners when RUNNER_CI is empty or unset (every
# public repository). Windows legs run only for a public calling repository, on GitHub's runners: no
# private or internal repository gets one. Set RUNNER_CI per repository, never at organisation
# public repository). Windows legs run only for a calling repository the API reports public, on
# GitHub's runners: no private or internal repository gets one, and a schedule payload carries no
# repository to read it from. Set RUNNER_CI per repository, never at organisation
# level: the runner group refuses public repositories, and their jobs would wait forever.
runs-on: ${{ matrix.os == 'ubuntu-latest' && vars.RUNNER_CI || matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(inputs.windows && github.event.repository.visibility == 'public' && (github.event_name == 'schedule' || ((github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch') && (inputs.windows-merge-queue || inputs.windows-pull-requests))) && '["ubuntu-latest","windows-latest"]' || '["ubuntu-latest"]') }}
os: ${{ fromJSON(needs.windows.outputs.visibility == 'public' && '["ubuntu-latest","windows-latest"]' || '["ubuntu-latest"]') }}
node-version: ${{ fromJSON(inputs.node-versions || '[""]') }}
part: ${{ fromJSON(format('[{0}{1}]', inputs.single-job && inputs.services-compose-file == '' && '"all"' || '"checks","test"', inputs.extra-commands-job && inputs.extra-commands != '' && ',"extra"' || '')) }}
defaults:
Expand Down Expand Up @@ -586,7 +607,7 @@ jobs:

checks:
if: always()
needs: [node, stress]
needs: [windows, node, stress]
runs-on: ${{ vars.RUNNER_CI || 'ubuntu-latest' }}
timeout-minutes: 5
permissions: {}
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/module-locks-refresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ jobs:
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: env.STATE == 'changed'
Expand All @@ -221,6 +223,33 @@ jobs:
name: module-locks
path: ${{ runner.temp }}/module-locks

- name: Check the refresh patch
if: env.STATE == 'changed'
run: |
out="$RUNNER_TEMP/module-locks"
export GIT_INDEX_FILE="$out/check.index"
git read-tree HEAD
git apply --cached "$out/refresh.patch" || {
echo "::error::The refresh patch does not apply to $(git rev-parse HEAD). Nothing was pushed."
exit 1
}
git diff --cached --no-renames --raw -z HEAD > "$out/check.raw"
refused=0
while IFS= read -r -d '' meta && IFS= read -r -d '' path; do
read -r _ mode _ <<< "$meta"
case "$path" in
.github/* | .gitmodules) reason="is under .github or declares submodules" ;;
*) case "$mode" in
120000) reason="is a symlink" ;;
160000) reason="is a submodule" ;;
*) continue ;;
esac ;;
esac
printf '::error::The refresh patch changes %q, which %s. Nothing was pushed.\n' "$path" "$reason"
refused=1
done < "$out/check.raw"
exit "$refused"

- name: Push the refreshed locks
if: env.STATE == 'changed'
env:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/module-locks-renovate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
}
END { exit !found }' "$1"
}
git ls-files -z --others --exclude-standard -- ':(glob)**/antelope-lock/**' | xargs -0 -r -n1 dirname | sort -u > "$work/recorded"
git ls-files -z --others --exclude-standard -- ':(glob)**/antelope-lock/**' | xargs -0 -r -n1 dirname -- | sort -u > "$work/recorded"
while IFS= read -r lock; do
name="${lock%@*}"
while IFS= read -r committed; do
Expand All @@ -104,7 +104,7 @@ jobs:
git rm -rq -- "$committed"
echo "Deleted ${committed}: the bump replaces ${version}."
fi
done < <(git ls-tree -d --name-only HEAD -- "$(dirname "$lock")/")
done < <(git ls-tree -d --name-only HEAD -- "$(dirname -- "$lock")/")
done < "$work/recorded"

- name: Commit the locks
Expand Down Expand Up @@ -135,6 +135,7 @@ jobs:
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-contents: write

- name: Push the locks to the Renovate branch
if: steps.commit.outputs.committed == 'true'
Expand Down
24 changes: 21 additions & 3 deletions .github/workflows/next-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
type: string
secrets:
RELEASE_GITHUB_TOKEN:
description: Unused, kept so that callers which still pass it are accepted
description: Token the sync pushes with while RELEASE_APP_ID or RELEASE_APP_PRIVATE_KEY is unset. Removed once every caller forwards the app secrets
required: false
RELEASE_APP_ID:
description: ID of the GitHub App whose installation token pushes the merge, which the branch's ruleset lets push
Expand Down Expand Up @@ -46,17 +46,35 @@ jobs:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- name: Pick the push credentials
id: credentials
env:
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
run: |
if [ -n "$RELEASE_APP_ID" ] && [ -n "$RELEASE_APP_PRIVATE_KEY" ]; then
echo "app=true" >> "$GITHUB_OUTPUT"
elif [ -n "$RELEASE_GITHUB_TOKEN" ]; then
echo "::warning::RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are not forwarded, so this sync pushes with RELEASE_GITHUB_TOKEN. Run antelopejs-sync to forward them before the token is revoked."
else
echo "::error::RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are not configured, and no RELEASE_GITHUB_TOKEN stands in for them."
exit 1
fi

- name: Create the push token
id: token
if: steps.credentials.outputs.app == 'true'
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-contents: write

- name: Merge
id: merge
env:
TOKEN: ${{ steps.token.outputs.token }}
TOKEN: ${{ steps.token.outputs.token || secrets.RELEASE_GITHUB_TOKEN }}
run: |
git init -q
git remote add origin "https://github.com/${GH_REPO}.git"
Expand Down Expand Up @@ -86,7 +104,7 @@ jobs:
fi
[ "$attempt" = 3 ] || sleep 5
done
echo "::error::The merge was not pushed to ${BRANCH} after 3 attempts. Either ${BRANCH} moved each time, or the release GitHub App is not a bypass actor of its ruleset."
echo "::error::The merge was not pushed to ${BRANCH} after 3 attempts. Either ${BRANCH} moved each time, or the release GitHub App, or the owner of RELEASE_GITHUB_TOKEN when the app secrets are unset, is not a bypass actor of its ruleset."
exit 1

- name: Open or update the conflict issue
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release-npm-private.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ on:
type: string
secrets:
RELEASE_GITHUB_TOKEN:
description: Unused. Kept so that a caller that passes it keeps working
description: Token the release falls back to while RELEASE_APP_ID or RELEASE_APP_PRIVATE_KEY is unset. Removed once every caller forwards the app secrets
required: false
RELEASE_APP_ID:
description: ID of the GitHub App whose installation token creates the release commit, tag, and GitHub release
Expand Down Expand Up @@ -56,6 +56,7 @@ jobs:
install-core: ${{ inputs.install-core }}
package-directory: ${{ inputs.package-directory }}
secrets:
RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
NPM_ANTELOPE_TOKEN: ${{ secrets.NPM_ANTELOPE_TOKEN }}
3 changes: 2 additions & 1 deletion .github/workflows/release-npm-public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ on:
type: string
secrets:
RELEASE_GITHUB_TOKEN:
description: Unused. Kept so that a caller that passes it keeps working
description: Token the release falls back to while RELEASE_APP_ID or RELEASE_APP_PRIVATE_KEY is unset. Removed once every caller forwards the app secrets
required: false
RELEASE_APP_ID:
description: ID of the GitHub App whose installation token creates the release commit, tag, and GitHub release
Expand All @@ -54,5 +54,6 @@ jobs:
install-core: ${{ inputs.install-core }}
package-directory: ${{ inputs.package-directory }}
secrets:
RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
29 changes: 19 additions & 10 deletions .github/workflows/release-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ on:
default: .
type: string
secrets:
RELEASE_GITHUB_TOKEN:
description: Token the release falls back to while RELEASE_APP_ID or RELEASE_APP_PRIVATE_KEY is unset. Removed once every caller forwards the app secrets
required: false
RELEASE_APP_ID:
description: ID of the GitHub App whose installation token creates the release commit, tag, and GitHub release
required: false
Expand Down Expand Up @@ -81,11 +84,13 @@ jobs:
fi

- name: Validate release credentials
id: credentials
env:
MODE: ${{ steps.mode.outputs.mode }}
REGISTRY: ${{ inputs.registry }}
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
NPM_ANTELOPE_TOKEN: ${{ secrets.NPM_ANTELOPE_TOKEN }}
run: |
case "$REGISTRY" in
Expand All @@ -102,21 +107,25 @@ jobs:
;;
esac
if [ "$MODE" = stable ] || [ "$MODE" = repin ]; then
for name in RELEASE_APP_ID RELEASE_APP_PRIVATE_KEY; do
test -n "${!name}" || {
echo "$name is not configured." >&2
exit 1
}
done
if [ -n "$RELEASE_APP_ID" ] && [ -n "$RELEASE_APP_PRIVATE_KEY" ]; then
echo "app=true" >> "$GITHUB_OUTPUT"
elif [ -n "$RELEASE_GITHUB_TOKEN" ]; then
echo "::warning::RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are not forwarded, so this release writes with RELEASE_GITHUB_TOKEN. Run antelopejs-sync to forward them before the token is revoked."
else
echo "RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are not configured, and no RELEASE_GITHUB_TOKEN stands in for them." >&2
exit 1
fi
fi

- name: Create the release token
id: token
if: steps.mode.outputs.mode == 'stable' || steps.mode.outputs.mode == 'repin'
if: steps.credentials.outputs.app == 'true'
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: read

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
Expand Down Expand Up @@ -561,7 +570,7 @@ jobs:
if: steps.mode.outputs.mode == 'repin'
env:
MESSAGE: ${{ steps.ranges.outputs.message }}
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
GITHUB_TOKEN: ${{ steps.token.outputs.token || secrets.RELEASE_GITHUB_TOKEN }}
run: |
set -euo pipefail
git commit --quiet -m "$MESSAGE"
Expand All @@ -576,7 +585,7 @@ jobs:
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
DEPENDENCY_RANGES: ${{ inputs.dependency-ranges }}
GH_TOKEN: ${{ steps.token.outputs.token }}
GH_TOKEN: ${{ steps.token.outputs.token || secrets.RELEASE_GITHUB_TOKEN }}
RELEASE_VERSION: ${{ steps.version.outputs.version }}
RESUME: ${{ steps.version.outputs.resume }}
run: |
Expand Down Expand Up @@ -818,7 +827,7 @@ jobs:
working-directory: ${{ inputs.package-directory }}
env:
RELEASE_VERSION: ${{ steps.version.outputs.version }}
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
GITHUB_TOKEN: ${{ steps.token.outputs.token || secrets.RELEASE_GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_ANTELOPE_TOKEN }}
run: |
auth=$(printf 'x-access-token:%s' "$GITHUB_TOKEN" | base64 -w0)
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This repository holds the AntelopeJS organization defaults: the community health

## Callers

Every repository calls the shared workflows at the `v2` tag, as in `AntelopeJS/.github/.github/workflows/ci-node.yml@v2`. A change on `main` reaches no caller until the tag moves, and `v2` moves only when Antony says so. The callers are frozen: a change keeps every existing input, default, secret and permission as they are, so each caller keeps working without an edit. `scripts/release-train/frozen-caller.yml` is the release caller that `antelopejs-sync` writes, and `caller.test.ts` checks the release workflows against it.
Every repository calls the shared workflows at the `v2` tag, as in `AntelopeJS/.github/.github/workflows/ci-node.yml@v2`. A change on `main` reaches no caller until the tag moves, and `v2` moves only when Antony says so. The callers are frozen: a change keeps every existing input, default, secret and permission as they are, so each caller keeps working without an edit. Release and next-sync callers forward `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY`, as `antelopejs-sync` writes them. Until every caller is re-synced, a run without them falls back to `RELEASE_GITHUB_TOKEN`, so an older caller keeps working when `v2` moves. The fallback goes away once every caller is re-synced and the token is revoked. `scripts/release-train/frozen-caller.yml` is the release caller that `antelopejs-sync` writes, and `caller.test.ts` checks the release workflows against it.

## Checks

Expand Down
Loading