You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.5 KiB
80 lines
2.5 KiB
# Release workflow
|
|
#
|
|
# master: python-semantic-release on push → semver tag + GitHub Release → sync develop
|
|
|
|
name: release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
concurrency:
|
|
group: release-${{ github.repository }}-${{ github.ref_name }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.ref_name }}
|
|
fetch-depth: 0
|
|
|
|
- name: Reset to workflow SHA
|
|
run: git reset --hard ${{ github.sha }}
|
|
|
|
- name: Semantic Release
|
|
id: semantic
|
|
uses: python-semantic-release/python-semantic-release@v10.5.3
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
git_committer_name: github-actions[bot]
|
|
git_committer_email: 41898282+github-actions[bot]@users.noreply.github.com
|
|
vcs_release: "false"
|
|
|
|
- name: Create GitHub Release
|
|
if: steps.semantic.outputs.released == 'true' && steps.semantic.outputs.tag != ''
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
TAG: ${{ steps.semantic.outputs.tag }}
|
|
VERSION: ${{ steps.semantic.outputs.version }}
|
|
RELEASE_NOTES: ${{ steps.semantic.outputs.release_notes }}
|
|
run: |
|
|
set -euo pipefail
|
|
if gh release view "$TAG" >/dev/null 2>&1; then
|
|
echo "Release already exists for $TAG"
|
|
gh release view "$TAG" --json url -q .url
|
|
exit 0
|
|
fi
|
|
NOTES_FILE="$(mktemp)"
|
|
if [[ -n "$RELEASE_NOTES" ]]; then
|
|
printf '%s\n' "$RELEASE_NOTES" > "$NOTES_FILE"
|
|
else
|
|
printf 'Release %s\n' "$VERSION" > "$NOTES_FILE"
|
|
fi
|
|
gh release create "$TAG" --title "$VERSION" --notes-file "$NOTES_FILE"
|
|
rm -f "$NOTES_FILE"
|
|
|
|
- name: Verify GitHub Release
|
|
if: steps.semantic.outputs.released == 'true' && steps.semantic.outputs.tag != ''
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
TAG: ${{ steps.semantic.outputs.tag }}
|
|
run: gh release view "$TAG"
|
|
|
|
- name: Sync develop from master
|
|
if: steps.semantic.outputs.released == 'true'
|
|
run: |
|
|
set -euo pipefail
|
|
git fetch origin master develop
|
|
# Squash merges to master diverge from develop; reset develop to released master.
|
|
git push origin origin/master:refs/heads/develop \
|
|
--force-with-lease=refs/heads/develop:refs/remotes/origin/develop
|