Skip to content

Commit 801492f

Browse files
committed
Add Windows release workflow
- Build, test, package, and publish Windows releases from main - Document package-version driven release behavior - Add node-pre-gyp tooling for packaged native dependencies
1 parent a96703c commit 801492f

4 files changed

Lines changed: 128 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
concurrency:
13+
group: release-${{ github.ref }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
windows-release:
18+
name: Windows release
19+
runs-on: windows-latest
20+
21+
steps:
22+
- name: Check out repository
23+
uses: actions/checkout@v4
24+
25+
- name: Read package version
26+
id: version
27+
shell: pwsh
28+
env:
29+
GH_TOKEN: ${{ github.token }}
30+
run: |
31+
$package = Get-Content package.json | ConvertFrom-Json
32+
$version = $package.version
33+
$tag = "v$version"
34+
35+
"version=$version" >> $env:GITHUB_OUTPUT
36+
"tag=$tag" >> $env:GITHUB_OUTPUT
37+
38+
gh release view $tag --repo $env:GITHUB_REPOSITORY *> $null
39+
if ($LASTEXITCODE -eq 0) {
40+
"release_exists=true" >> $env:GITHUB_OUTPUT
41+
"Release $tag already exists; skipping build and publish." >> $env:GITHUB_STEP_SUMMARY
42+
} else {
43+
"release_exists=false" >> $env:GITHUB_OUTPUT
44+
"Release $tag does not exist; building Windows installer." >> $env:GITHUB_STEP_SUMMARY
45+
}
46+
47+
- name: Set up Bun
48+
if: steps.version.outputs.release_exists != 'true'
49+
uses: oven-sh/setup-bun@v2
50+
51+
- name: Install dependencies
52+
if: steps.version.outputs.release_exists != 'true'
53+
run: bun install --frozen-lockfile
54+
55+
- name: Run checks
56+
if: steps.version.outputs.release_exists != 'true'
57+
run: bun run check
58+
59+
- name: Run unit tests
60+
if: steps.version.outputs.release_exists != 'true'
61+
run: bun run test:unit
62+
63+
- name: Build Windows installer
64+
if: steps.version.outputs.release_exists != 'true'
65+
run: bun run dist:win
66+
67+
- name: Upload workflow artifact
68+
if: steps.version.outputs.release_exists != 'true'
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: path-profile-windows-${{ steps.version.outputs.version }}
72+
path: dist/Path-Profile*-win-x64.*
73+
if-no-files-found: error
74+
75+
- name: Create GitHub release
76+
if: steps.version.outputs.release_exists != 'true'
77+
shell: pwsh
78+
env:
79+
GH_TOKEN: ${{ github.token }}
80+
run: |
81+
$tag = "${{ steps.version.outputs.tag }}"
82+
$version = "${{ steps.version.outputs.version }}"
83+
$artifacts = Get-ChildItem dist -File |
84+
Where-Object { $_.Name -like "Path-Profile*-win-x64.*" } |
85+
ForEach-Object { $_.FullName }
86+
87+
if (-not $artifacts) {
88+
throw "No release artifacts were found in dist/."
89+
}
90+
91+
gh release create $tag @artifacts `
92+
--repo $env:GITHUB_REPOSITORY `
93+
--title "Path Profile $version" `
94+
--generate-notes

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ assets.
6666

6767
## Release
6868

69+
Merging to `main` runs the GitHub Actions release workflow. The workflow reads
70+
`package.json` and creates a GitHub release named `v<version>` when that release
71+
does not already exist, so release PRs should bump the package version before
72+
merge.
73+
6974
Create an unpacked Windows x64 app directory for smoke testing:
7075

7176
```bash

bun.lock

Lines changed: 28 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"dependencies": {},
3131
"devDependencies": {
3232
"@eslint/eslintrc": "^3.3.1",
33+
"@mapbox/node-pre-gyp": "^2.0.0",
3334
"@tailwindcss/postcss": "^4.0.15",
3435
"@types/node": "^20.14.10",
3536
"@types/pngjs": "^6.0.5",

0 commit comments

Comments
 (0)