# ============================================================================= # 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 concurrency: group: stable-release-main cancel-in-progress: false 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: '24' - name: Bump version (minor release or hotfix patch) id: bump env: PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }} PR_TITLE: ${{ github.event.pull_request.title }} run: | # Stable feature releases: +0.1.0. Hotfix PRs (label "hotfix" or title # containing "hotfix", e.g. 3.4.0 → 3.4.1): +0.0.1. BUMP_ARGS=(--minor) LABELS_LC=$(echo "$PR_LABELS" | tr '[:upper:]' '[:lower:]') TITLE_LC=$(echo "$PR_TITLE" | tr '[:upper:]' '[:lower:]') if echo "$LABELS_LC" | grep -qw 'hotfix' || echo "$TITLE_LC" | grep -q 'hotfix'; then BUMP_ARGS=(--patch) echo "Hotfix detected — using patch bump (+0.0.1)" else echo "Stable release — using minor bump (+0.1.0)" fi node scripts/bump-version.js "${BUMP_ARGS[@]}" NEW_VERSION=$(cat VERSION | tr -d '\n') echo "version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" - name: Commit version bump to main env: NEW_VERSION: ${{ steps.bump.outputs.version }} 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) if git diff --cached --quiet; then echo "No version files changed — skipping release bump commit" exit 0 fi git commit -m "chore: release version ${NEW_VERSION} [version-bump]" git push origin HEAD:main - name: Sync checkout to bumped main run: | git fetch origin main --tags git reset --hard 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"