Files
actual/.github/workflows/release-notes.yml
Matt FiddamanandGitHub 62a18ba770 fix release automation with branch protection (#8842)
* open PRs instead of pushing

* use release notes on the release branch only
2026-09-01 21:44:31 +00:00

116 lines
4.4 KiB
YAML

name: Release notes
on:
pull_request:
push:
branches:
- release
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
check-release-notes:
if: >-
github.event_name == 'pull_request'
&& github.head_ref != 'release'
&& startsWith(github.head_ref, 'release-notes/') == false
&& github.event.pull_request.user.login != 'dependabot[bot]'
runs-on: depot-ubuntu-latest
permissions:
contents: read
steps:
- name: Check if triggered by bot
id: bot-check
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const { data: commit } = await github.rest.git.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.payload.pull_request.head.sha,
});
const skip = commit.author.name === 'github-actions[bot]'
&& commit.message.startsWith('Generate release notes');
console.log(`Head commit by "${commit.author.name}": ${commit.message.split('\n')[0]}`);
console.log(`Skip: ${skip}`);
core.setOutput('skip', String(skip));
- name: Checkout
if: steps.bot-check.outputs.skip != 'true'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Get changed files
if: steps.bot-check.outputs.skip != 'true'
id: changed-files
run: |
git fetch origin ${GITHUB_BASE_REF}
CHANGED_FILES=$(git diff --name-only origin/${GITHUB_BASE_REF}...HEAD)
NON_DOCS_FILES=$(echo "$CHANGED_FILES" | grep -v -e "^packages/docs/" -e "^\.github/actions/docs-spelling/" || true)
if [ -z "$NON_DOCS_FILES" ] && [ -n "$CHANGED_FILES" ]; then
echo "only_docs=true" >> $GITHUB_OUTPUT
echo "only documentation files changed, skipping release notes check"
else
echo "only_docs=false" >> $GITHUB_OUTPUT
fi
- name: Check release notes
if: >-
steps.bot-check.outputs.skip != 'true'
&& steps.changed-files.outputs.only_docs != 'true'
uses: ./.github/actions/release-notes/check
generate-release-notes:
if: github.event_name == 'push'
runs-on: depot-ubuntu-latest
environment: release
permissions:
contents: write
pull-requests: read
steps:
- name: Resolve version
id: version
env:
GH_TOKEN: ${{ github.token }}
run: |
version=$(gh api "repos/${GITHUB_REPOSITORY}/contents/packages/desktop-client/package.json?ref=release" --jq '.content' | base64 -d | jq -r .version)
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "notes_branch=release-notes/$version" >> "$GITHUB_OUTPUT"
# Pushes to release can happen outside a cut (e.g. hotfix commits
# landing before the version bump). Only generate notes when the cut
# has opened the notes branch and the version has not shipped yet.
repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
if git ls-remote --exit-code "$repo_url" "refs/tags/v$version" >/dev/null 2>&1; then
echo "Tag v$version already published; skipping generation"
echo "skip=true" >> "$GITHUB_OUTPUT"
elif ! git ls-remote --exit-code "$repo_url" "refs/heads/release-notes/$version" >/dev/null 2>&1; then
echo "Notes branch release-notes/$version does not exist yet; skipping generation"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Checkout release-notes branch
if: steps.version.outputs.skip != 'true'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ steps.version.outputs.notes_branch }}
fetch-depth: 0
persist-credentials: true
- name: Generate release notes
if: steps.version.outputs.skip != 'true'
uses: ./.github/actions/release-notes/generate
with:
release-branch: release
notes-branch: ${{ steps.version.outputs.notes_branch }}
version: ${{ steps.version.outputs.version }}