forked from countincognito/Zametek.ProjectPlan
-
Notifications
You must be signed in to change notification settings - Fork 0
284 lines (229 loc) · 9.66 KB
/
release.yml
File metadata and controls
284 lines (229 loc) · 9.66 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
permissions:
contents: write
jobs:
build-windows:
name: Build Windows (${{ matrix.arch }})
runs-on: windows-latest
strategy:
matrix:
arch: [x64, x86, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.x'
- name: Restore
run: dotnet restore
env:
HUSKY: 0
- name: Publish Desktop
run: |
dotnet publish -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained=true -c Release --os win --arch ${{ matrix.arch }} src/Zametek.ProjectPlan/Zametek.ProjectPlan.csproj --output artifacts/desktop/win-${{ matrix.arch }}
env:
HUSKY: 0
- name: Publish CLI
run: |
dotnet publish -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained=true -c Release --os win --arch ${{ matrix.arch }} src/Zametek.ProjectPlan.CommandLine/Zametek.ProjectPlan.CommandLine.csproj --output artifacts/cli/win-${{ matrix.arch }}
env:
HUSKY: 0
- name: Package Desktop
shell: pwsh
run: |
$version = "${{ github.ref_name }}"
Compress-Archive -Path artifacts/desktop/win-${{ matrix.arch }}/* -DestinationPath "projectplandotnet-${version}-win-${{ matrix.arch }}.zip"
- name: Package CLI
shell: pwsh
run: |
$version = "${{ github.ref_name }}"
Compress-Archive -Path artifacts/cli/win-${{ matrix.arch }}/* -DestinationPath "zpp-${version}-win-${{ matrix.arch }}.zip"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.arch }}
path: "*.zip"
retention-days: 1
build-linux:
name: Build Linux (${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.x'
- name: Restore
run: dotnet restore
env:
HUSKY: 0
- name: Publish Desktop
run: |
dotnet publish -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained=true -c Release --os linux --arch ${{ matrix.arch }} src/Zametek.ProjectPlan/Zametek.ProjectPlan.csproj --output artifacts/desktop/linux-${{ matrix.arch }}
env:
HUSKY: 0
- name: Publish CLI
run: |
dotnet publish -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained=true -c Release --os linux --arch ${{ matrix.arch }} src/Zametek.ProjectPlan.CommandLine/Zametek.ProjectPlan.CommandLine.csproj --output artifacts/cli/linux-${{ matrix.arch }}
env:
HUSKY: 0
- name: Package Desktop
run: |
VERSION="${{ github.ref_name }}"
tar -czf "projectplandotnet-${VERSION}-linux-${{ matrix.arch }}.tar.gz" -C artifacts/desktop/linux-${{ matrix.arch }} .
- name: Package CLI
run: |
VERSION="${{ github.ref_name }}"
tar -czf "zpp-${VERSION}-linux-${{ matrix.arch }}.tar.gz" -C artifacts/cli/linux-${{ matrix.arch }} .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: linux-${{ matrix.arch }}
path: "*.tar.gz"
retention-days: 1
build-macos:
name: Build macOS (${{ matrix.arch }})
runs-on: macos-latest
strategy:
matrix:
arch: [x64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.x'
- name: Restore
run: dotnet restore
env:
HUSKY: 0
- name: Publish Desktop
run: |
dotnet publish -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained=true -c Release --os osx --arch ${{ matrix.arch }} src/Zametek.ProjectPlan/Zametek.ProjectPlan.csproj --output artifacts/desktop/osx-${{ matrix.arch }}
env:
HUSKY: 0
- name: Publish CLI
run: |
dotnet publish -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained=true -c Release --os osx --arch ${{ matrix.arch }} src/Zametek.ProjectPlan.CommandLine/Zametek.ProjectPlan.CommandLine.csproj --output artifacts/cli/osx-${{ matrix.arch }}
env:
HUSKY: 0
- name: Package Desktop
run: |
VERSION="${{ github.ref_name }}"
tar -czf "projectplandotnet-${VERSION}-osx-${{ matrix.arch }}.tar.gz" -C artifacts/desktop/osx-${{ matrix.arch }} .
- name: Package CLI
run: |
VERSION="${{ github.ref_name }}"
tar -czf "zpp-${VERSION}-osx-${{ matrix.arch }}.tar.gz" -C artifacts/cli/osx-${{ matrix.arch }} .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: macos-${{ matrix.arch }}
path: "*.tar.gz"
retention-days: 1
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build-windows, build-linux, build-macos]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
merge-multiple: true
- name: List artifacts
run: ls -la release-artifacts/
- name: Generate release notes
id: release-notes
run: |
VERSION="${{ github.ref_name }}"
SEMVER_REGEX="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-((?:0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
if [[ "$VERSION" =~ $SEMVER_REGEX ]]; then
echo "Valid SemVer: $VERSION"
else
echo "Invalid SemVer: $VERSION"
exit 1
fi
cat > release-notes.md << EOF
## $VERSION
### Downloads
#### projectplan.net Desktop
| Platform | Architecture | Download |
|----------|-------------|---------|
| Windows | x64 | \`projectplandotnet-${VERSION}-win-x64.zip\` |
| Windows | x86 | \`projectplandotnet-${VERSION}-win-x86.zip\` |
| Windows | arm64 | \`projectplandotnet-${VERSION}-win-arm64.zip\` |
| Linux | x64 | \`projectplandotnet-${VERSION}-linux-x64.tar.gz\` |
| Linux | arm64 | \`projectplandotnet-${VERSION}-linux-arm64.tar.gz\` |
| macOS | x64 (Intel) | \`projectplandotnet-${VERSION}-osx-x64.tar.gz\` |
| macOS | arm64 (Apple Silicon) | \`projectplandotnet-${VERSION}-osx-arm64.tar.gz\` |
#### zpp CLI
| Platform | Architecture | Download |
|----------|-------------|---------|
| Windows | x64 | \`zpp-${VERSION}-win-x64.zip\` |
| Windows | x86 | \`zpp-${VERSION}-win-x86.zip\` |
| Windows | arm64 | \`zpp-${VERSION}-win-arm64.zip\` |
| Linux | x64 | \`zpp-${VERSION}-linux-x64.tar.gz\` |
| Linux | arm64 | \`zpp-${VERSION}-linux-arm64.tar.gz\` |
| macOS | x64 (Intel) | \`zpp-${VERSION}-osx-x64.tar.gz\` |
| macOS | arm64 (Apple Silicon) | \`zpp-${VERSION}-osx-arm64.tar.gz\` |
### Installation
**Windows:** Extract the zip file and run \`projectplandotnet.exe\` (Desktop) or \`zpp.exe\` (CLI). No installer required — self-contained, no .NET runtime needed.
**Linux/macOS:** Extract the tar.gz, make executable (\`chmod +x projectplandotnet\`), and run. Self-contained, no .NET runtime needed.
EOF
- name: Create GitHub Release
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
const releaseNotes = fs.readFileSync('release-notes.md', 'utf8');
const tag = context.ref.replace('refs/tags/', '');
// Create the release
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: tag,
body: releaseNotes,
draft: false,
prerelease: tag.includes('-'),
});
// Upload all artifacts
const artifactsDir = 'release-artifacts';
const files = fs.readdirSync(artifactsDir);
for (const file of files) {
const filePath = path.join(artifactsDir, file);
const stat = fs.statSync(filePath);
if (!stat.isFile()) continue;
const contentType = file.endsWith('.zip')
? 'application/zip'
: 'application/gzip';
console.log(`Uploading ${file} (${stat.size} bytes)...`);
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: file,
data: fs.readFileSync(filePath),
headers: {
'content-type': contentType,
'content-length': stat.size,
},
});
console.log(`Uploaded ${file}`);
}
console.log(`Release ${tag} created: ${release.data.html_url}`);