Repository navigation
146 lines (119 loc) · 4.01 KB
/
Copy pathbuild-release.yml
File metadata and controls
146 lines (119 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Build & Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
publish:
description: 'Publish a release (tag v<package.json version>) after building. Run from main only.'
type: boolean
default: false
permissions:
contents: write
jobs:
build-windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Verify package.json version matches tag
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
tag_version="${GITHUB_REF_NAME#v}"
pkg_version="$(node -p "require('./package.json').version")"
if [ "$tag_version" != "$pkg_version" ]; then
echo "::error::Tag $GITHUB_REF_NAME does not match package.json version ($pkg_version). The app's built-in update checker compares its bundled package.json version against release tags, so a mismatch here makes every install think it's out of date forever. Bump package.json to $tag_version, commit, then re-tag."
exit 1
fi
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Bundle server
run: node bundle.mjs
- name: Build Windows installer
run: node_modules\.bin\electron-builder.cmd --win --x64
env:
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: List build output
run: dir dist
- name: Upload installer as workflow artifact
uses: actions/upload-artifact@v4
with:
name: nullmesh-windows-installer
path: dist/*.exe
if-no-files-found: error
build-macos:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Bundle server
run: node bundle.mjs
- name: Build macOS app (Intel + Apple Silicon)
run: pnpm exec electron-builder --mac dmg zip --x64 --arm64 --publish never
env:
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
- name: List build output
run: ls -la dist
- name: Upload macOS builds as workflow artifact
uses: actions/upload-artifact@v4
with:
name: nullmesh-macos
path: |
dist/*.dmg
dist/*.zip
if-no-files-found: error
release:
needs: [build-windows, build-macos]
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && inputs.publish && github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Work out the release tag
id: tag
run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
echo "name=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
else
echo "name=v$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
fi
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: release-files
merge-multiple: true
- name: List files
run: ls -la release-files
- name: Attach builds to GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.name }}
target_commitish: ${{ github.sha }}
files: release-files/*
fail_on_unmatched_files: true
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}