11name : Build & Release
22
3- # Self-versioning builds. Go to Actions → "Build & Release" → Run workflow.
4- # Each run automatically computes the next version (latest release + 0.0.1 by
5- # default), builds Windows + macOS, and publishes a GitHub Release with
6- # auto-update metadata. No manual version editing needed.
3+ # Self-versioning builds.
4+ #
5+ # Runs automatically on every push to `main` (code changes), and can also be run
6+ # by hand from Actions → "Build & Release" → Run workflow. Each run computes the
7+ # next version (latest release + 0.0.1 by default), builds Windows + macOS, and
8+ # publishes a GitHub Release with auto-update metadata — no manual version edits.
79#
810# • bump=patch (default) → 1.0.0 → 1.0.1 → 1.0.2 ...
9- # • bump=minor/major → 1.0.x → 1.1.0 / 2.0.0
11+ # • bump=minor/major (manual run only) → 1.0.x → 1.1.0 / 2.0.0
1012# • Need an exact version? Set it in desktop/package.json (higher than the
11- # latest release) and it will be used as-is for that run.
12- # • Uncheck "publish" for a test build (artifacts only, no release , no bump).
13+ # latest release) and it is used as-is for that run.
14+ # • Manual run with "publish" unchecked → test build (artifacts only, no bump).
1315on :
16+ push :
17+ branches :
18+ - main
19+ - master
20+ paths-ignore :
21+ - " **.md"
22+ - " .gitignore"
23+ - " LICENSE"
1424 workflow_dispatch :
1525 inputs :
1626 bump :
@@ -30,7 +40,8 @@ permissions:
3040 contents : write
3141
3242jobs :
33- # Resolve the next version and tag it, so the increment persists for next time.
43+ # Resolve the next version, tag it, and open a draft release up front so the
44+ # platform build jobs can upload to it without racing each other.
3445 version :
3546 runs-on : ubuntu-latest
3647 outputs :
@@ -45,10 +56,11 @@ jobs:
4556 - id : calc
4657 shell : bash
4758 run : |
48- BUMP="${{ inputs.bump }}"
49- PUBLISH="${{ inputs.publish }}"
59+ # Defaults make a push event behave like a normal patch release.
60+ BUMP="${{ inputs.bump }}"; [ -z "$BUMP" ] && BUMP=patch
61+ PUBLISH="${{ inputs.publish }}"; [ -z "$PUBLISH" ] && PUBLISH=true
62+
5063 PKG=$(node -p "require('./desktop/package.json').version")
51- # Latest semver-shaped v* tag, if any.
5264 LATEST=$(git tag -l 'v*' | sed 's/^v//' \
5365 | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)
5466
@@ -71,23 +83,27 @@ jobs:
7183 NEW="$(bump "$LATEST" "$BUMP")"
7284 fi
7385
74- echo "version=$NEW" >> "$GITHUB_OUTPUT"
75- echo "tag=v$NEW" >> "$GITHUB_OUTPUT"
86+ echo "version=$NEW" >> "$GITHUB_OUTPUT"
87+ echo "tag=v$NEW" >> "$GITHUB_OUTPUT"
7688 echo "publish=$PUBLISH" >> "$GITHUB_OUTPUT"
77- echo "Resolved: v$NEW (latest tag: ${LATEST:-none}, pkg: $PKG, bump: $BUMP, publish: $PUBLISH)"
89+ echo "Resolved: v$NEW (latest tag: ${LATEST:-none}, pkg: $PKG, bump: $BUMP, publish: $PUBLISH)"
7890
79- - name : Tag the new version
91+ - name : Tag version and open draft release
8092 if : steps.calc.outputs.publish == 'true'
93+ env :
94+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8195 run : |
8296 git config user.name "github-actions[bot]"
8397 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
8498 TAG="${{ steps.calc.outputs.tag }}"
85- if git rev-parse "$TAG" >/dev/null 2>&1; then
86- echo "Tag $TAG already exists; reusing it."
87- else
99+ if ! git rev-parse "$TAG" >/dev/null 2>&1; then
88100 git tag "$TAG"
89101 git push origin "$TAG"
90102 fi
103+ if ! gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
104+ gh release create "$TAG" --repo "$GITHUB_REPOSITORY" \
105+ --draft --title "Peek Remote $TAG" --generate-notes
106+ fi
91107
92108 build :
93109 needs : version
0 commit comments