-
Notifications
You must be signed in to change notification settings - Fork 1
249 lines (211 loc) · 8.29 KB
/
Copy pathrelease.yml
File metadata and controls
249 lines (211 loc) · 8.29 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: release
on:
push:
branches: [main, prerelease]
paths:
- 'Lazybones/PackageVersion.txt'
workflow_dispatch:
permissions:
contents: write
jobs:
validate-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.read.outputs.value }}
isPrerelease: ${{ steps.read.outputs.prerelease }}
steps:
- uses: actions/checkout@v6
- name: Read version and validate against branch
id: read
shell: bash
run: |
VERSION=$(cat Lazybones/PackageVersion.txt | tr -d '\r' | tr -d '\n' | xargs)
echo "Version: $VERSION"
if [[ "$VERSION" == *"-"* ]]; then
HAS_SUFFIX=true
else
HAS_SUFFIX=false
fi
BRANCH="${GITHUB_REF#refs/heads/}"
if [ "$BRANCH" = "main" ] && [ "$HAS_SUFFIX" = "true" ]; then
echo "ERROR: main branch must not have a prerelease suffix (got '$VERSION')"
exit 1
fi
if [ "$BRANCH" = "prerelease" ] && [ "$HAS_SUFFIX" = "false" ]; then
echo "ERROR: prerelease branch requires a suffix (got '$VERSION')"
exit 1
fi
echo "value=$VERSION" >> "$GITHUB_OUTPUT"
echo "prerelease=$HAS_SUFFIX" >> "$GITHUB_OUTPUT"
test:
needs: validate-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Test
shell: bash
run: dotnet test Lazybones.Tests/Lazybones.Tests.csproj -c Release --nologo
pack:
needs: test
name: Pack ${{ matrix.rid }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
rid: win-x64
framework: net10.0-windows10.0.17763.0
mainExe: Lazybones.exe
iconPath: Lazybones/Assets/appicon.ico
extraVpkArgs: ''
- os: macos-latest
rid: osx-arm64
framework: net10.0
mainExe: Lazybones
iconPath: icon.icns
extraVpkArgs: --bundleId dev.malforge.lazybones
- os: macos-latest
rid: osx-x64
framework: net10.0
mainExe: Lazybones
iconPath: icon.icns
extraVpkArgs: --bundleId dev.malforge.lazybones
steps:
- uses: actions/checkout@v6
- uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Install Velopack CLI
shell: bash
run: dotnet tool install --global vpk
# macOS bundles want an .icns file. Build an iconset directory from the
# PNG and use iconutil to produce the icns — works at any source size.
# When the icon gets redesigned, just drop a higher-resolution PNG into
# Assets/ (1024x1024 ideal) and this step produces a crisp icns.
# `sips` and `iconutil` are preinstalled on macOS runners.
- name: Generate macOS .icns from PNG
if: runner.os == 'macOS'
shell: bash
run: |
set -e
src=Lazybones/Assets/appicon.png
mkdir -p icon.iconset
sips -z 16 16 "$src" --out icon.iconset/icon_16x16.png
sips -z 32 32 "$src" --out icon.iconset/icon_16x16@2x.png
sips -z 32 32 "$src" --out icon.iconset/icon_32x32.png
sips -z 64 64 "$src" --out icon.iconset/icon_32x32@2x.png
sips -z 128 128 "$src" --out icon.iconset/icon_128x128.png
sips -z 256 256 "$src" --out icon.iconset/icon_128x128@2x.png
sips -z 256 256 "$src" --out icon.iconset/icon_256x256.png
sips -z 512 512 "$src" --out icon.iconset/icon_256x256@2x.png
sips -z 512 512 "$src" --out icon.iconset/icon_512x512.png
sips -z 1024 1024 "$src" --out icon.iconset/icon_512x512@2x.png
iconutil -c icns icon.iconset -o icon.icns
- name: Publish
shell: bash
run: |
dotnet publish Lazybones/Lazybones.csproj \
-c Release \
-f ${{ matrix.framework }} \
-r ${{ matrix.rid }} \
--self-contained \
-p:PublishSingleFile=true \
-o publish
- name: vpk pack
shell: bash
run: |
vpk pack \
--packId Lazybones \
--packVersion ${{ needs.validate-version.outputs.version }} \
--packDir publish \
--mainExe ${{ matrix.mainExe }} \
--packTitle "Get Up, Lazybones!" \
--packAuthors "Morten Aune Lyrstad" \
--runtime ${{ matrix.rid }} \
--icon ${{ matrix.iconPath }} \
${{ matrix.extraVpkArgs }}
- name: Upload pack artifacts
uses: actions/upload-artifact@v7
with:
name: pack-${{ matrix.rid }}
if-no-files-found: error
retention-days: 7
path: Releases/*
release:
needs: [validate-version, pack]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Compose release body
id: notes
shell: bash
run: |
VERSION="${{ needs.validate-version.outputs.version }}"
IS_PRERELEASE="${{ needs.validate-version.outputs.isPrerelease }}"
# State-machine extraction: print lines after the "v.<VERSION>" header
# and before the next "v.<anything>" header. Tolerant of CRLF endings.
# Avoids awk's range-pattern gotcha (range collapses to a single line
# when both endpoint patterns happen to match the same line, which
# happens when ReleaseNotes.txt only has one version entry).
NOTES=$(awk -v ver="$VERSION" '
{ sub(/\r$/, "") }
$0 == "v." ver { found=1; next }
found && /^v\./ { exit }
found { print }
' Lazybones/ReleaseNotes.txt)
echo "::group::Extracted release notes for v$VERSION"
echo "$NOTES"
echo "::endgroup::"
if [ -z "$NOTES" ]; then
NOTES="No release notes provided for v$VERSION."
fi
INSTALL_GUIDE=$(cat <<'EOF'
## First time installing?
Lazybones is an open-source personal project and isn't code-signed. Windows SmartScreen and macOS Gatekeeper will both show a warning on first install — **that's expected**. Code-signing certificates cost real money and aren't worth it for a free personal tool. The source is public on this repo; you can read it.
**Windows**
1. Download `Lazybones-win-Setup.exe` below.
2. Run it. SmartScreen will warn that the app is from an unknown publisher.
3. Click **More info**, then **Run anyway**.
**macOS**
1. Download `Lazybones-osx-Setup.pkg` below.
2. Open it. Gatekeeper will refuse to run it.
3. **Control-click** the `.pkg` in Finder, choose **Open**, then click **Open** in the warning dialog.
Once installed, future updates download and apply themselves the next time you launch the app — you don't need to repeat any of this.
---
EOF
)
PRERELEASE_WARNING=""
if [ "$IS_PRERELEASE" = "true" ]; then
PRERELEASE_WARNING=$'\n> **Pre-release notice:** this is a pre-release build intended for testing. It may contain bugs or incomplete features. Please report anything weird.\n'
fi
BODY="${INSTALL_GUIDE}${PRERELEASE_WARNING}
## What's new
${NOTES}"
{
echo "value<<EOF"
echo "$BODY"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Download all pack artifacts
uses: actions/download-artifact@v8
with:
path: releases
pattern: pack-*
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.validate-version.outputs.version }}
name: Get Up, Lazybones! v${{ needs.validate-version.outputs.version }}
body: ${{ steps.notes.outputs.value }}
prerelease: ${{ needs.validate-version.outputs.isPrerelease == 'true' }}
target_commitish: ${{ github.sha }}
files: releases/*