mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-10-03 12:30:46 +00:00
fe2d970574
Complete stable release after PR #196 merge. Delete stale release branch before push in version-bump-main workflow to avoid non-fast-forward failures.
93 lines
3.1 KiB
YAML
93 lines
3.1 KiB
YAML
# =============================================================================
|
|
# BetterDesk — stable release on merge to main
|
|
# =============================================================================
|
|
# When a PR is merged into main, bump minor version (+0.1.0), tag vX.Y.Z,
|
|
# and publish a GitHub Release. Existing release-server and docker-publish
|
|
# workflows run on the new tag / release event.
|
|
# =============================================================================
|
|
|
|
name: Version Bump & Release (main)
|
|
|
|
on:
|
|
pull_request:
|
|
types: [closed]
|
|
branches: [main]
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
release-stable:
|
|
if: github.event.pull_request.merged == true
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
ref: main
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Bump minor version
|
|
id: bump
|
|
run: |
|
|
node scripts/bump-version.js --minor
|
|
NEW_VERSION=$(cat VERSION | tr -d '\n')
|
|
echo "version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Commit version bump via release PR
|
|
env:
|
|
NEW_VERSION: ${{ steps.bump.outputs.version }}
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add $(node scripts/bump-version.js --list-paths)
|
|
BRANCH="release/v${NEW_VERSION}"
|
|
git push origin --delete "$BRANCH" 2>/dev/null || true
|
|
git checkout -b "$BRANCH"
|
|
git commit -m "chore: release version ${NEW_VERSION} [version-bump]"
|
|
git push -u origin "$BRANCH"
|
|
gh pr create --base main --head "$BRANCH" \
|
|
--title "chore: release version ${NEW_VERSION}" \
|
|
--body "Automated stable release version bump after merge to main."
|
|
gh pr merge --merge --admin --delete-branch
|
|
|
|
- name: Sync checkout to bumped main
|
|
run: git pull origin main
|
|
|
|
- name: Create tag and GitHub Release
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
NEW_VERSION: ${{ steps.bump.outputs.version }}
|
|
run: |
|
|
TAG="v${NEW_VERSION}"
|
|
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
|
echo "Tag ${TAG} already exists — skipping tag/release creation"
|
|
exit 0
|
|
fi
|
|
git tag "$TAG"
|
|
git push origin "$TAG"
|
|
|
|
NOTES_FILE=$(mktemp)
|
|
awk -v ver="${NEW_VERSION}" '
|
|
BEGIN { found=0 }
|
|
/^## \[/ {
|
|
if ($0 ~ "\\[" ver "\\]") { found=1; print; next }
|
|
if (found && /^## \[/ && $0 !~ "\\[" ver "\\]") { exit }
|
|
}
|
|
found { print }
|
|
' CHANGELOG.md > "$NOTES_FILE"
|
|
|
|
if [ ! -s "$NOTES_FILE" ]; then
|
|
echo "BetterDesk ${NEW_VERSION} stable release." > "$NOTES_FILE"
|
|
fi
|
|
|
|
gh release create "$TAG" \
|
|
--title "BetterDesk ${NEW_VERSION}" \
|
|
--notes-file "$NOTES_FILE"
|