mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-18 11:32:15 -05:00
Bumps the github-actions group with 14 updates in the / directory: | Package | From | To | | --- | --- | --- | | [actions/checkout](https://github.com/actions/checkout) | `6.0.3` | `7.0.1` | | [pnpm/action-setup](https://github.com/pnpm/action-setup) | `6.0.8` | `6.1.0` | | [actions/setup-node](https://github.com/actions/setup-node) | `6.4.0` | `7.1.0` | | [actions/labeler](https://github.com/actions/labeler) | `6.1.0` | `7.0.0` | | [korthout/backport-action](https://github.com/korthout/backport-action) | `4.5.2` | `4.7.0` | | [actions/cache](https://github.com/actions/cache) | `5.0.5` | `6.1.0` | | [re-actors/alls-green](https://github.com/re-actors/alls-green) | `1.2.2` | `1.3.0` | | [anthropics/claude-code-action](https://github.com/anthropics/claude-code-action) | `1.0.142` | `1.0.248` | | [denoland/setup-deno](https://github.com/denoland/setup-deno) | `2.0.4` | `2.0.5` | | [actions/upload-artifact](https://github.com/actions/upload-artifact) | `4.6.2` | `7.0.2` | | [actions/download-artifact](https://github.com/actions/download-artifact) | `8.0.1` | `8.0.2` | | [changesets/action](https://github.com/changesets/action) | `1.9.0` | `2.1.2` | | [marocchino/sticky-pull-request-comment](https://github.com/marocchino/sticky-pull-request-comment) | `3.0.4` | `3.0.5` | | [zizmorcore/zizmor-action](https://github.com/zizmorcore/zizmor-action) | `0.5.6` | `0.6.4` | Updates `actions/checkout` from 6.0.3 to 7.0.1 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/df4cb1c069e1874edd31b4311f1884172cec0e10...3d3c42e5aac5ba805825da76410c181273ba90b1) Updates `pnpm/action-setup` from 6.0.8 to 6.1.0 - [Release notes](https://github.com/pnpm/action-setup/releases) - [Commits](https://github.com/pnpm/action-setup/compare/0e279bb959325dab635dd2c09392533439d90093...ea17c68df8912ef543352723c149a84f56e3d413) Updates `actions/setup-node` from 6.4.0 to 7.1.0 - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e...949feb2413d6458794dcd2491c4babbbce0c15c1) Updates `actions/labeler` from 6.1.0 to 7.0.0 - [Release notes](https://github.com/actions/labeler/releases) - [Commits](https://github.com/actions/labeler/compare/f27b608878404679385c85cfa523b85ccb86e213...bf12e9b00b37c5c0ca2b87b79b2daf7891dbda13) Updates `korthout/backport-action` from 4.5.2 to 4.7.0 - [Release notes](https://github.com/korthout/backport-action/releases) - [Commits](https://github.com/korthout/backport-action/compare/66065406958f46e82238fd59546f5a99e69e22aa...8560fb503c275d433c56f05a2f64850093baa9f7) Updates `actions/cache` from 5.0.5 to 6.1.0 - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/27d5ce7f107fe9357f9df03efb73ab90386fccae...55cc8345863c7cc4c66a329aec7e433d2d1c52a9) Updates `re-actors/alls-green` from 1.2.2 to 1.3.0 - [Release notes](https://github.com/re-actors/alls-green/releases) - [Commits](https://github.com/re-actors/alls-green/compare/05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe...b5b5b37504aa4183270bd3d855c52a67f212be35) Updates `anthropics/claude-code-action` from 1.0.142 to 1.0.248 - [Release notes](https://github.com/anthropics/claude-code-action/releases) - [Commits](https://github.com/anthropics/claude-code-action/compare/11ba60486e4aec9ddfeafcf4bb3f00b028ac2c16...1d6de8cb0c237e7c15e9e1bdf973826ebae490cc) Updates `denoland/setup-deno` from 2.0.4 to 2.0.5 - [Release notes](https://github.com/denoland/setup-deno/releases) - [Commits](https://github.com/denoland/setup-deno/compare/667a34cdef165d8d2b2e98dde39547c9daac7282...22d081ff2d3a40755e97629de92e3bcbfa7cf2ed) Updates `actions/upload-artifact` from 4.6.2 to 7.0.2 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.6.2...cf430e030ddbb5b0abf93d22962f4752f3646cd9) Updates `actions/download-artifact` from 8.0.1 to 8.0.2 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c...9000827ccba6bdab643e8b6fd33ac0654aef8333) Updates `changesets/action` from 1.9.0 to 2.1.2 - [Release notes](https://github.com/changesets/action/releases) - [Changelog](https://github.com/changesets/action/blob/main/CHANGELOG.md) - [Commits](https://github.com/changesets/action/compare/a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d...ae32849d5ba541f9ae29e40e22a623bc13562f51) Updates `marocchino/sticky-pull-request-comment` from 3.0.4 to 3.0.5 - [Release notes](https://github.com/marocchino/sticky-pull-request-comment/releases) - [Commits](https://github.com/marocchino/sticky-pull-request-comment/compare/0ea0beb66eb9baf113663a64ec522f60e49231c0...5770ad5eb8f42dd2c4f34da00c94c5381e49af88) Updates `zizmorcore/zizmor-action` from 0.5.6 to 0.6.4 - [Release notes](https://github.com/zizmorcore/zizmor-action/releases) - [Commits](https://github.com/zizmorcore/zizmor-action/compare/5f14fd08f7cf1cb1609c1e344975f152c7ee938d...cc914d7f3750a2d13d75c7f184a1060aa0e9d482) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 7.0.1 dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: pnpm/action-setup dependency-version: 6.1.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions - dependency-name: actions/setup-node dependency-version: 7.1.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: actions/labeler dependency-version: 7.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: korthout/backport-action dependency-version: 4.7.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions - dependency-name: actions/cache dependency-version: 6.1.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: re-actors/alls-green dependency-version: 1.3.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions - dependency-name: anthropics/claude-code-action dependency-version: 1.0.248 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions - dependency-name: denoland/setup-deno dependency-version: 2.0.5 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions - dependency-name: actions/upload-artifact dependency-version: 7.0.2 dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: actions/download-artifact dependency-version: 8.0.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions - dependency-name: changesets/action dependency-version: 2.1.2 dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: marocchino/sticky-pull-request-comment dependency-version: 3.0.5 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions - dependency-name: zizmorcore/zizmor-action dependency-version: 0.6.4 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions ... Signed-off-by: dependabot[bot] <support@github.com>
534 lines
21 KiB
YAML
534 lines
21 KiB
YAML
name: Release Notes Command
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
permissions: {}
|
|
|
|
concurrency:
|
|
group: >-
|
|
release-notes-command-${{
|
|
github.event.issue.pull_request != null &&
|
|
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) &&
|
|
startsWith(github.event.comment.body, '/release-notes') &&
|
|
github.event.issue.number || github.run_id
|
|
}}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
acknowledge:
|
|
if: >-
|
|
github.repository_owner == 'better-auth' &&
|
|
github.event.issue.pull_request &&
|
|
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) &&
|
|
startsWith(github.event.comment.body, '/release-notes')
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 1
|
|
continue-on-error: true
|
|
permissions:
|
|
issues: write
|
|
pull-requests: write
|
|
outputs:
|
|
reaction_id: ${{ steps.reaction.outputs.reaction_id }}
|
|
token_source: ${{ steps.reaction.outputs.token_source }}
|
|
steps:
|
|
- name: Generate scoped App token
|
|
id: app-token
|
|
continue-on-error: true
|
|
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
|
if: vars.RELEASE_APP_ID != ''
|
|
with:
|
|
app-id: ${{ vars.RELEASE_APP_ID }}
|
|
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
|
permission-issues: write
|
|
permission-pull-requests: write
|
|
|
|
- name: Acknowledge command
|
|
id: reaction
|
|
continue-on-error: true
|
|
env:
|
|
APP_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
|
|
COMMENT_ID: ${{ github.event.comment.id }}
|
|
run: |
|
|
if [[ ! "$COMMENT_ID" =~ ^[0-9]+$ ]]; then
|
|
echo "::error::Comment ID is invalid"
|
|
exit 1
|
|
fi
|
|
REACTION_ID=$(gh api --method POST \
|
|
"repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}/reactions" \
|
|
-f content='eyes' --jq '.id')
|
|
if [[ ! "$REACTION_ID" =~ ^[0-9]+$ ]]; then
|
|
echo "::error::Reaction ID is invalid"
|
|
exit 1
|
|
fi
|
|
echo "reaction_id=$REACTION_ID" >> "$GITHUB_OUTPUT"
|
|
if [ -n "$APP_TOKEN" ]; then
|
|
echo "token_source=app" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "token_source=github" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
generate:
|
|
if: >-
|
|
github.repository_owner == 'better-auth' &&
|
|
github.event.issue.pull_request &&
|
|
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) &&
|
|
startsWith(github.event.comment.body, '/release-notes')
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
permissions:
|
|
contents: read
|
|
issues: read
|
|
pull-requests: read
|
|
outputs:
|
|
base_ref: ${{ steps.command.outputs.base_ref }}
|
|
head_sha: ${{ steps.command.outputs.head_sha }}
|
|
head_ref: ${{ steps.command.outputs.head_ref }}
|
|
merged: ${{ steps.command.outputs.merged }}
|
|
pr_number: ${{ steps.command.outputs.pr_number }}
|
|
version: ${{ steps.candidate.outputs.version }}
|
|
steps:
|
|
- name: Authorize command and resolve PR
|
|
id: command
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
COMMENT_BODY: ${{ github.event.comment.body }}
|
|
COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
|
|
PR_NUMBER: ${{ github.event.issue.number }}
|
|
run: |
|
|
if ! printf '%s' "$COMMENT_BODY" | grep -qE '^/release-notes[[:space:]]*$'; then
|
|
echo "::error::The supported command is /release-notes"
|
|
exit 1
|
|
fi
|
|
|
|
PERMISSION=$(gh api "repos/${GITHUB_REPOSITORY}/collaborators/${COMMENT_AUTHOR}/permission" --jq '.permission')
|
|
case "$PERMISSION" in
|
|
admin|maintain|write) ;;
|
|
*)
|
|
echo "::error::${COMMENT_AUTHOR} does not have permission to generate release notes"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
PR=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}")
|
|
HEAD_REPO=$(echo "$PR" | jq -r '.head.repo.full_name')
|
|
HEAD_REF=$(echo "$PR" | jq -r '.head.ref')
|
|
HEAD_SHA=$(echo "$PR" | jq -r '.head.sha')
|
|
BASE_REPO=$(echo "$PR" | jq -r '.base.repo.full_name')
|
|
BASE_REF=$(echo "$PR" | jq -r '.base.ref')
|
|
STATE=$(echo "$PR" | jq -r '.state')
|
|
MERGED=$(echo "$PR" | jq -r '.merged')
|
|
if [ "$HEAD_REPO" != "$GITHUB_REPOSITORY" ] \
|
|
|| [ "$BASE_REPO" != "$GITHUB_REPOSITORY" ]; then
|
|
echo "::error::Release notes commands only run on PRs in this repository"
|
|
exit 1
|
|
fi
|
|
if [ "$STATE" != "open" ] && [ "$MERGED" != "true" ]; then
|
|
echo "::error::Release notes commands only run on open or merged PRs"
|
|
exit 1
|
|
fi
|
|
|
|
RELEASE_CARRIER=false
|
|
if [[ "$HEAD_REF" == changeset-release/* ]]; then
|
|
RELEASE_CARRIER=true
|
|
elif [ "$HEAD_REF" = "next" ] && [ "$BASE_REF" = "main" ]; then
|
|
RELEASE_CARRIER=true
|
|
fi
|
|
if [ "$RELEASE_CARRIER" != "true" ]; then
|
|
echo "::error::Release notes commands only run on Version PRs or next-to-main promotion PRs"
|
|
exit 1
|
|
fi
|
|
if [[ "$BASE_REF" != "main" && "$BASE_REF" != "next" && \
|
|
! "$BASE_REF" =~ ^v[0-9]+\.[0-9]+\.x$ ]]; then
|
|
echo "::error::Unsupported release base branch ${BASE_REF}"
|
|
exit 1
|
|
fi
|
|
|
|
{
|
|
echo "pr_number=$PR_NUMBER"
|
|
echo "base_ref=$BASE_REF"
|
|
echo "head_sha=$HEAD_SHA"
|
|
echo "head_ref=$HEAD_REF"
|
|
echo "merged=$MERGED"
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
# issue_comment runs from the default branch. Execute that trusted code
|
|
# and read the release head only as git data.
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
ref: ${{ github.sha }}
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
|
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: pnpm
|
|
|
|
- name: Install release tooling
|
|
run: pnpm install --frozen-lockfile --filter @better-auth/release-tooling
|
|
|
|
- name: Verify release PR head
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ steps.command.outputs.pr_number }}
|
|
EXPECTED_HEAD_SHA: ${{ steps.command.outputs.head_sha }}
|
|
run: |
|
|
if [[ ! "$PR_NUMBER" =~ ^[1-9][0-9]*$ ]] || \
|
|
[[ ! "$EXPECTED_HEAD_SHA" =~ ^[0-9a-f]{40}$ ]]; then
|
|
echo "::error::Release PR identity is invalid"
|
|
exit 1
|
|
fi
|
|
if ! CURRENT_HEAD_SHA=$(gh api \
|
|
"repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" \
|
|
--jq '.head.sha'); then
|
|
echo "::error::Could not read the current release PR head"
|
|
exit 1
|
|
fi
|
|
if [[ ! "$CURRENT_HEAD_SHA" =~ ^[0-9a-f]{40}$ ]]; then
|
|
echo "::error::GitHub returned an invalid release PR head SHA"
|
|
exit 1
|
|
fi
|
|
if [ "$CURRENT_HEAD_SHA" != "$EXPECTED_HEAD_SHA" ]; then
|
|
echo "::error::The release PR changed before candidate resolution"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Resolve release candidate
|
|
id: candidate
|
|
env:
|
|
HEAD_SHA: ${{ steps.command.outputs.head_sha }}
|
|
MERGED: ${{ steps.command.outputs.merged }}
|
|
run: |
|
|
if [[ ! "$HEAD_SHA" =~ ^[0-9a-f]{40}$ ]]; then
|
|
echo "::error::Release head is not a valid commit SHA"
|
|
exit 1
|
|
fi
|
|
# Fetch the immutable commit as data. Never check out or execute the PR tree.
|
|
if ! git cat-file -e "${HEAD_SHA}^{commit}" 2>/dev/null; then
|
|
git fetch --no-tags --no-write-fetch-head origin "$HEAD_SHA"
|
|
fi
|
|
git cat-file -e "${HEAD_SHA}^{commit}"
|
|
VERSION=$(git show "${HEAD_SHA}:packages/better-auth/package.json" | jq -r '.version')
|
|
if ! pnpm --filter @better-auth/release-tooling release-notes \
|
|
validate --version "$VERSION"; then
|
|
echo "::error::Could not determine a valid release candidate version"
|
|
exit 1
|
|
fi
|
|
if [ "$MERGED" = "true" ] && \
|
|
git rev-parse --verify "v${VERSION}^{commit}" >/dev/null 2>&1; then
|
|
echo "::error::Release v${VERSION} is already tagged"
|
|
exit 1
|
|
fi
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Generate release manifest
|
|
id: raw-notes
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
VERSION: ${{ steps.candidate.outputs.version }}
|
|
HEAD_SHA: ${{ steps.command.outputs.head_sha }}
|
|
run: |
|
|
pnpm --filter @better-auth/release-tooling release-notes collect \
|
|
--version "$VERSION" \
|
|
--branch "$HEAD_SHA" \
|
|
--commit-ref "$HEAD_SHA"
|
|
|
|
- name: Rewrite release notes with AI
|
|
id: rewrites
|
|
continue-on-error: true
|
|
env:
|
|
AI_GATEWAY_API_KEY: ${{ secrets.AI_GATEWAY_API_KEY }}
|
|
CONTEXT_PATH: ${{ steps.raw-notes.outputs.context_path }}
|
|
run: |
|
|
REWRITES_PATH="${CONTEXT_PATH}.rewrites.json"
|
|
pnpm --filter @better-auth/release-tooling release-notes rewrite \
|
|
--context "$CONTEXT_PATH" \
|
|
--output "$REWRITES_PATH"
|
|
echo "path=$REWRITES_PATH" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Render and package final release notes
|
|
id: final-notes
|
|
env:
|
|
MANIFEST_PATH: ${{ steps.raw-notes.outputs.manifest_path }}
|
|
RAW_PATH: ${{ steps.raw-notes.outputs.raw_changelog_path }}
|
|
REWRITES_PATH: ${{ steps.rewrites.outputs.path }}
|
|
FALLBACKS: ${{ steps.rewrites.outputs.fallbacks }}
|
|
REWRITE_OUTCOME: ${{ steps.rewrites.outcome }}
|
|
VERSION: ${{ steps.candidate.outputs.version }}
|
|
HEAD_SHA: ${{ steps.command.outputs.head_sha }}
|
|
MERGED: ${{ steps.command.outputs.merged }}
|
|
run: |
|
|
ARTIFACT_DIR="$RUNNER_TEMP/release-notes"
|
|
NOTES_PATH="$ARTIFACT_DIR/release-notes.md"
|
|
mkdir -p "$ARTIFACT_DIR"
|
|
|
|
SOURCE="ai"
|
|
MERGED_ARGS=()
|
|
FALLBACK_ARGS=()
|
|
if [ "$MERGED" = "true" ]; then
|
|
MERGED_ARGS+=(--merged)
|
|
fi
|
|
if [ "$REWRITE_OUTCOME" = "success" ] && \
|
|
pnpm --filter @better-auth/release-tooling release-notes render \
|
|
--manifest "$MANIFEST_PATH" \
|
|
--rewrites "$REWRITES_PATH" \
|
|
--output "$NOTES_PATH"; then
|
|
echo "Using AI-rewritten release notes"
|
|
else
|
|
if [ ! -s "$RAW_PATH" ]; then
|
|
echo "::error::Deterministic release notes are missing"
|
|
exit 1
|
|
fi
|
|
cp "$RAW_PATH" "$NOTES_PATH"
|
|
SOURCE="raw"
|
|
echo "::warning::AI rewrite failed; using deterministic release notes for maintainer review"
|
|
fi
|
|
|
|
if [ "$SOURCE" = "ai" ]; then
|
|
FALLBACK_ARGS+=(--fallbacks "$FALLBACKS")
|
|
fi
|
|
|
|
pnpm --filter @better-auth/release-tooling release-notes:comment wrap \
|
|
--version "$VERSION" \
|
|
--head "$HEAD_SHA" \
|
|
--source "$SOURCE" \
|
|
"${MERGED_ARGS[@]}" \
|
|
"${FALLBACK_ARGS[@]}" \
|
|
--body "$NOTES_PATH" \
|
|
--output "$ARTIFACT_DIR/release-notes-comment.md"
|
|
echo "source=$SOURCE" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Verify release PR is unchanged
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ steps.command.outputs.pr_number }}
|
|
EXPECTED_HEAD_SHA: ${{ steps.command.outputs.head_sha }}
|
|
run: |
|
|
CURRENT_HEAD_SHA=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '.head.sha')
|
|
if [ "$CURRENT_HEAD_SHA" != "$EXPECTED_HEAD_SHA" ]; then
|
|
echo "::error::The release PR changed while release notes were being generated"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Upload validated release notes
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
with:
|
|
name: release-notes-${{ github.run_id }}
|
|
path: ${{ runner.temp }}/release-notes/release-notes-comment.md
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
publish-comment:
|
|
needs: generate
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
permissions:
|
|
contents: read
|
|
issues: write
|
|
pull-requests: write
|
|
steps:
|
|
- name: Generate scoped App token
|
|
id: app-token
|
|
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
|
if: vars.RELEASE_APP_ID != ''
|
|
with:
|
|
app-id: ${{ vars.RELEASE_APP_ID }}
|
|
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
|
permission-contents: read
|
|
permission-issues: write
|
|
permission-pull-requests: write
|
|
|
|
- name: Download validated release notes
|
|
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
with:
|
|
name: release-notes-${{ github.run_id }}
|
|
path: ${{ runner.temp }}/release-notes
|
|
|
|
- name: Verify release PR is unchanged
|
|
env:
|
|
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ needs.generate.outputs.pr_number }}
|
|
EXPECTED_HEAD_SHA: ${{ needs.generate.outputs.head_sha }}
|
|
EXPECTED_HEAD_REF: ${{ needs.generate.outputs.head_ref }}
|
|
EXPECTED_BASE_REF: ${{ needs.generate.outputs.base_ref }}
|
|
EXPECTED_MERGED: ${{ needs.generate.outputs.merged }}
|
|
run: |
|
|
if ! PR=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}"); then
|
|
echo "::error::Could not read the current release PR"
|
|
exit 1
|
|
fi
|
|
CURRENT_HEAD_SHA=$(echo "$PR" | jq -r '.head.sha')
|
|
CURRENT_HEAD_REF=$(echo "$PR" | jq -r '.head.ref')
|
|
CURRENT_BASE_REF=$(echo "$PR" | jq -r '.base.ref')
|
|
CURRENT_HEAD_REPO=$(echo "$PR" | jq -r '.head.repo.full_name')
|
|
CURRENT_BASE_REPO=$(echo "$PR" | jq -r '.base.repo.full_name')
|
|
CURRENT_STATE=$(echo "$PR" | jq -r '.state')
|
|
CURRENT_MERGED=$(echo "$PR" | jq -r '.merged')
|
|
|
|
if [[ ! "$CURRENT_HEAD_SHA" =~ ^[0-9a-f]{40}$ ]] || \
|
|
[ "$CURRENT_HEAD_SHA" != "$EXPECTED_HEAD_SHA" ] || \
|
|
[ "$CURRENT_HEAD_REF" != "$EXPECTED_HEAD_REF" ] || \
|
|
[ "$CURRENT_BASE_REF" != "$EXPECTED_BASE_REF" ] || \
|
|
[ "$CURRENT_HEAD_REPO" != "$GITHUB_REPOSITORY" ] || \
|
|
[ "$CURRENT_BASE_REPO" != "$GITHUB_REPOSITORY" ] || \
|
|
[ "$CURRENT_MERGED" != "$EXPECTED_MERGED" ] || \
|
|
{ [ "$CURRENT_STATE" != 'open' ] && [ "$CURRENT_MERGED" != 'true' ]; }; then
|
|
echo "::error::The release PR identity changed before release notes were published"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Create or update release notes comment
|
|
env:
|
|
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ needs.generate.outputs.pr_number }}
|
|
RELEASE_APP_ID: ${{ vars.RELEASE_APP_ID }}
|
|
run: |
|
|
COMMENT_FILE="$RUNNER_TEMP/release-notes/release-notes-comment.md"
|
|
|
|
COMMENTS=$(gh api --paginate "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments?per_page=100" | jq -s 'add')
|
|
if [ -n "$RELEASE_APP_ID" ]; then
|
|
COMMENT_ID=$(echo "$COMMENTS" | jq -r --arg app "$RELEASE_APP_ID" \
|
|
'[.[] | select((.performed_via_github_app.id | tostring) == $app) | select(.body | startswith("<!-- better-auth-release-notes:v1 -->"))] | sort_by(.updated_at) | last | .id // empty')
|
|
else
|
|
COMMENT_ID=$(echo "$COMMENTS" | jq -r \
|
|
'[.[] | select(.user.login == "github-actions[bot]") | select(.body | startswith("<!-- better-auth-release-notes:v1 -->"))] | sort_by(.updated_at) | last | .id // empty')
|
|
fi
|
|
|
|
if [ -n "$COMMENT_ID" ]; then
|
|
gh api --method PATCH "repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}" \
|
|
-f body="$(cat "$COMMENT_FILE")" >/dev/null
|
|
else
|
|
gh api --method POST "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
|
|
-f body="$(cat "$COMMENT_FILE")" >/dev/null
|
|
fi
|
|
|
|
- name: Mark release PR ready
|
|
if: needs.generate.outputs.merged != 'true'
|
|
env:
|
|
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ needs.generate.outputs.pr_number }}
|
|
EXPECTED_HEAD_SHA: ${{ needs.generate.outputs.head_sha }}
|
|
EXPECTED_HEAD_REF: ${{ needs.generate.outputs.head_ref }}
|
|
EXPECTED_BASE_REF: ${{ needs.generate.outputs.base_ref }}
|
|
run: |
|
|
current_identity() {
|
|
local pr head head_ref base_ref head_repo base_repo state merged
|
|
if ! pr=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}"); then
|
|
echo "::error::Could not read the current release PR" >&2
|
|
return 1
|
|
fi
|
|
head=$(echo "$pr" | jq -r '.head.sha')
|
|
head_ref=$(echo "$pr" | jq -r '.head.ref')
|
|
base_ref=$(echo "$pr" | jq -r '.base.ref')
|
|
head_repo=$(echo "$pr" | jq -r '.head.repo.full_name')
|
|
base_repo=$(echo "$pr" | jq -r '.base.repo.full_name')
|
|
state=$(echo "$pr" | jq -r '.state')
|
|
merged=$(echo "$pr" | jq -r '.merged')
|
|
if [[ ! "$head" =~ ^[0-9a-f]{40}$ ]] || \
|
|
[ "$head_ref" != "$EXPECTED_HEAD_REF" ] || \
|
|
[ "$base_ref" != "$EXPECTED_BASE_REF" ] || \
|
|
[ "$head_repo" != "$GITHUB_REPOSITORY" ] || \
|
|
[ "$base_repo" != "$GITHUB_REPOSITORY" ] || \
|
|
[ "$state" != 'open' ] || \
|
|
[ "$merged" != 'false' ]; then
|
|
echo "::error::The release PR identity changed" >&2
|
|
return 1
|
|
fi
|
|
printf '%s' "$head"
|
|
}
|
|
|
|
restore_draft() {
|
|
local is_draft
|
|
is_draft=$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json isDraft --jq '.isDraft')
|
|
if [ "$is_draft" != 'true' ]; then
|
|
gh pr ready "$PR_NUMBER" --undo --repo "$GITHUB_REPOSITORY"
|
|
fi
|
|
}
|
|
|
|
if ! HEAD_BEFORE_READY=$(current_identity); then
|
|
restore_draft
|
|
exit 1
|
|
fi
|
|
if [ "$HEAD_BEFORE_READY" != "$EXPECTED_HEAD_SHA" ]; then
|
|
restore_draft
|
|
echo "::error::The release PR changed before it was marked ready"
|
|
exit 1
|
|
fi
|
|
|
|
IS_DRAFT=$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json isDraft --jq '.isDraft')
|
|
if [ "$IS_DRAFT" = 'true' ]; then
|
|
gh pr ready "$PR_NUMBER" --repo "$GITHUB_REPOSITORY"
|
|
fi
|
|
|
|
if ! HEAD_AFTER_READY=$(current_identity); then
|
|
restore_draft
|
|
exit 1
|
|
fi
|
|
if [ "$HEAD_AFTER_READY" != "$EXPECTED_HEAD_SHA" ]; then
|
|
restore_draft
|
|
echo "::error::The release PR changed while it was being marked ready"
|
|
exit 1
|
|
fi
|
|
|
|
finalize-command:
|
|
needs: [acknowledge, generate, publish-comment]
|
|
if: >-
|
|
!cancelled() &&
|
|
contains(fromJSON('["success", "failure"]'), needs.generate.result)
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
permissions:
|
|
issues: write
|
|
pull-requests: write
|
|
steps:
|
|
- name: Generate scoped App token
|
|
id: app-token
|
|
continue-on-error: true
|
|
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
|
if: vars.RELEASE_APP_ID != ''
|
|
with:
|
|
app-id: ${{ vars.RELEASE_APP_ID }}
|
|
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
|
permission-issues: write
|
|
permission-pull-requests: write
|
|
|
|
- name: Set command status
|
|
continue-on-error: true
|
|
env:
|
|
GH_TOKEN: ${{ needs.acknowledge.outputs.token_source == 'github' && secrets.GITHUB_TOKEN || steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
|
|
COMMENT_ID: ${{ github.event.comment.id }}
|
|
REACTION_ID: ${{ needs.acknowledge.outputs.reaction_id }}
|
|
GENERATE_RESULT: ${{ needs.generate.result }}
|
|
PUBLISH_RESULT: ${{ needs.publish-comment.result }}
|
|
run: |
|
|
if [[ ! "$COMMENT_ID" =~ ^[0-9]+$ ]]; then
|
|
echo "::error::Comment ID is invalid"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -n "$REACTION_ID" ]; then
|
|
if [[ ! "$REACTION_ID" =~ ^[0-9]+$ ]]; then
|
|
echo "::error::Reaction ID is invalid"
|
|
exit 1
|
|
fi
|
|
if ! gh api --method DELETE \
|
|
"repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}/reactions/${REACTION_ID}"; then
|
|
echo "::warning::Could not clear the command acknowledgement"
|
|
fi
|
|
fi
|
|
|
|
CONTENT='-1'
|
|
if [ "$GENERATE_RESULT" = 'success' ] && \
|
|
[ "$PUBLISH_RESULT" = 'success' ]; then
|
|
CONTENT='+1'
|
|
fi
|
|
gh api --method POST "repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}/reactions" \
|
|
-f content="$CONTENT" >/dev/null
|