Skip to content

Ignore superseded Spotify sign-in UI results #463

Ignore superseded Spotify sign-in UI results

Ignore superseded Spotify sign-in UI results #463

name: Release cadence
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
# Queue instead of cancelling: a run that just created a release still has to
# rewrite its notes and start the Release workflow, and a merge landing a few
# seconds later must not cancel that. Queued runs collapse to the newest one.
concurrency:
group: release-cadence
cancel-in-progress: false
jobs:
release-please:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- id: release
uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 # v4
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
# Some changes reached main twice (a branch commit plus its merge commit
# with the same message), so release-please lists them twice. Tidy the
# open release PR's CHANGELOG.md and body after every run.
- if: steps.release.outputs.pr
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
path: main
sparse-checkout: |
package.json
scripts/dedupe-changelog.js
sparse-checkout-cone-mode: false
persist-credentials: false
- name: Dedupe release PR changelog
if: steps.release.outputs.pr
env:
GH_TOKEN: ${{ github.token }}
PR_JSON: ${{ steps.release.outputs.pr }}
run: |
branch=$(jq -r '.headBranchName' <<<"$PR_JSON")
number=$(jq -r '.number' <<<"$PR_JSON")
[[ "$branch" =~ ^release-please--[A-Za-z0-9._/-]+$ ]] || { echo "unexpected release branch: $branch"; exit 1; }
[[ "$number" =~ ^[0-9]+$ ]] || { echo "unexpected PR number: $number"; exit 1; }
git clone --quiet --depth 1 --branch "$branch" "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" release-pr
if [ "$(node main/scripts/dedupe-changelog.js release-pr/CHANGELOG.md)" = "deduped" ]; then
git -C release-pr -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" commit --quiet -am "chore: dedupe changelog entries"
git -C release-pr push --quiet origin "HEAD:${branch}"
fi
gh pr view "$number" -R "$GITHUB_REPOSITORY" --json body --jq .body > body.md
if [ "$(node main/scripts/dedupe-changelog.js body.md)" = "deduped" ]; then
gh pr edit "$number" -R "$GITHUB_REPOSITORY" --body-file body.md
fi
# Release Please writes the whole changelog section into the GitHub release.
# Keep CHANGELOG.md complete, but cap the release page at the same ten ranked
# changes the development build shows (#145).
stable-release-notes:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
persist-credentials: false
- name: Rewrite the stable release notes
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.release-please.outputs.tag_name }}
run: |
set -euo pipefail
[[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "unexpected tag: $TAG"; exit 1; }
git fetch --quiet --tags origin
previous=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | grep -vx "$TAG" | head -1 || true)
if [[ -z "$previous" ]]; then
previous=$(git rev-list --max-parents=0 "$TAG" | tail -1)
fi
git log --reverse --no-merges --pretty=format:'%H%x09%s' "$previous..$TAG" > all-changes.tsv
: > changes.tsv
while IFS=$'\t' read -r sha subject || [[ -n "${sha:-}" ]]; do
[[ -z "${sha:-}" ]] && continue
# Release Please's own version bump is not a change worth listing.
[[ "$subject" == "chore(main): release "* ]] && continue
# shellcheck disable=SC2016 # awk field references must remain literal.
size=$(git show --numstat --format= "$sha" | awk '{a+=$1; d+=$2; f++} END {print a+d+f+0}')
pr=$(gh api "repos/$GITHUB_REPOSITORY/commits/$sha/pulls" --jq '.[0].number // empty' 2>/dev/null | grep -m1 -E '^[0-9]+$' || true)
printf '%s\t%s\t%s\t%s\n' "$sha" "$pr" "$size" "$subject" >> changes.tsv
done < all-changes.tsv
{
# Hand-written sections from docs/releasing.md (Breaking changes,
# Migration, Compatibility, Security) come first when present.
if [[ -f "docs/release-notes/$TAG.md" ]]; then
cat "docs/release-notes/$TAG.md"
printf '\n'
fi
printf "## What's Changed\n\n"
node scripts/release-notes.js changes.tsv "$GITHUB_REPOSITORY"
printf '\nEvery change is listed in [CHANGELOG.md](https://github.com/%s/blob/%s/CHANGELOG.md).\n' "$GITHUB_REPOSITORY" "$TAG"
printf '\n**Full Changelog**: https://github.com/%s/compare/%s...%s\n' "$GITHUB_REPOSITORY" "$previous" "$TAG"
} > release-notes.md
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --notes-file release-notes.md
# The tag above was created with GITHUB_TOKEN, which never starts the
# tag-triggered Release workflow. Dispatch it on the new tag instead (#353).
start-release-workflow:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Run the Release workflow on the new tag
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.release-please.outputs.tag_name }}
run: |
set -euo pipefail
[[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "unexpected tag: $TAG"; exit 1; }
gh workflow run release.yml --repo "$GITHUB_REPOSITORY" --ref "$TAG"
echo "Started release.yml on $TAG"