-
-
Notifications
You must be signed in to change notification settings - Fork 2
193 lines (174 loc) · 6.9 KB
/
Copy pathrelease.yml
File metadata and controls
193 lines (174 loc) · 6.9 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
name: Release Pipeline
on:
workflow_run:
workflows: ["Continuous Integration"]
types:
- completed
branches:
- master
permissions:
contents: write
jobs:
release-build:
if: github.event.workflow_run.conclusion == 'success'
runs-on: windows-latest
env:
DOTNET_VERSION: "8.0.x"
RUNTIME: win-x64
APP_ID: PocketMC
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Parse Root Configuration
id: config
shell: pwsh
run: |
$content = Get-Content pocketmc.yml -Raw
$version = if ($content -match '(?m)^version:\s*(.+)$') { $matches[1].Trim() } else { "1.0.0" }
$channel = if ($content -match '(?m)^channel:\s*(.+)$') { $matches[1].Trim() } else { "none" }
echo "version=$version" >> $env:GITHUB_OUTPUT
echo "channel=$channel" >> $env:GITHUB_OUTPUT
- name: Ensure Release Channel
id: check_channel
shell: pwsh
run: |
if ("${{ steps.config.outputs.channel }}" -ne "release") {
echo "skip=true" >> $env:GITHUB_OUTPUT
Write-Host "Channel is not release. Exiting gracefully..."
} else {
echo "skip=false" >> $env:GITHUB_OUTPUT
}
- uses: actions/setup-dotnet@v4
if: steps.check_channel.outputs.skip == 'false'
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install Velopack
if: steps.check_channel.outputs.skip == 'false'
run: dotnet tool install -g vpk
- name: Restore (win-x64 RID)
if: steps.check_channel.outputs.skip == 'false'
run: dotnet restore PocketMC.Desktop/PocketMC.Desktop.csproj -r ${{ env.RUNTIME }}
- name: Publish Multi-DLL (Velopack input)
if: steps.check_channel.outputs.skip == 'false'
run: |
dotnet publish PocketMC.Desktop/PocketMC.Desktop.csproj `
-c Release `
-r $env:RUNTIME `
--self-contained false `
--no-restore `
-p:Version=${{ steps.config.outputs.version }} `
-o publish
- name: Download previous release assets
if: steps.check_channel.outputs.skip == 'false'
uses: robinraju/release-downloader@v1
with:
repository: PocketMC/pocket-mc-windows
latest: true
fileName: "*"
out-file-path: Releases
token: ${{ secrets.GITHUB_TOKEN }}
- name: Pack with Velopack
if: steps.check_channel.outputs.skip == 'false'
run: >
vpk pack
--packId ${{ env.APP_ID }}
--packVersion ${{ steps.config.outputs.version }}
--packDir publish
--mainExe PocketMC.Desktop.exe
--framework net8.0,net8.0-aspnetcore
--runtime ${{ env.RUNTIME }}
--outputDir Releases
- name: Upload Release Artifacts
if: steps.check_channel.outputs.skip == 'false'
uses: actions/upload-artifact@v4
with:
name: PocketMC-Release-${{ steps.config.outputs.version }}
path: Releases/
- name: Extract release notes
if: steps.check_channel.outputs.skip == 'false'
id: notes
shell: pwsh
run: |
$whatsnew = Get-Content -Path PocketMC.Desktop/Assets/WhatsNew.txt -Raw
$lines = $whatsnew -split '\r?\n'
$formatted = @()
foreach ($line in $lines) {
$line = $line.Trim()
if ($line -match "^VERSION=") { continue }
elseif ($line -eq "[FEATURES]") { $formatted += "`n### ❯ Features" }
elseif ($line -eq "[FIXES]") { $formatted += "`n### ❯ Fixes" }
elseif ($line -eq "[IMPROVEMENTS]") { $formatted += "`n### ❯ Improvements" }
elseif ([string]::IsNullOrWhiteSpace($line)) { continue }
else { $formatted += " • $line" }
}
$body = $formatted -join "`n"
$body = $body -replace '(?m)^### ❯ [^\n]+\n+(?=### ❯|$)', ''
$body = $body.Trim()
$EOF = [guid]::NewGuid().ToString()
Add-Content -Path $env:GITHUB_OUTPUT -Value "body<<$EOF"
Add-Content -Path $env:GITHUB_OUTPUT -Value $body
Add-Content -Path $env:GITHUB_OUTPUT -Value $EOF
- name: Create GitHub Release
if: steps.check_channel.outputs.skip == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.config.outputs.version }}
name: PocketMC v${{ steps.config.outputs.version }}
body: ${{ steps.notes.outputs.body }}
files: |
Releases/PocketMC-${{ steps.config.outputs.version }}-full.nupkg
Releases/PocketMC-${{ steps.config.outputs.version }}-delta.nupkg
Releases/PocketMC-win-Setup.exe
Releases/PocketMC-win-Portable.zip
Releases/releases.win.json
Releases/assets.win.json
Releases/RELEASES
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Discord Release Notification
if: steps.check_channel.outputs.skip == 'false'
shell: pwsh
env:
BODY: ${{ steps.notes.outputs.body }}
run: |
$webhookUrl = "${{ secrets.DISCORD_RELEASE_WEBHOOK }}"
if (-not $webhookUrl) { Write-Warning "DISCORD_RELEASE_WEBHOOK not set."; exit 0 }
$body = $env:BODY
if ($body.Length -gt 3900) { $body = $body.Substring(0, 3900) + "... *(truncated)*" }
$payload = @{
content = "<@&1493922983742537819>"
embeds = @(@{
title = "❖ PocketMC v${{ steps.config.outputs.version }} Available ❖"
description = $body
color = 3066993
image = @{ url = "https://cdn.discordapp.com/attachments/1493841758864412715/1512177063572934717/banner.png" }
footer = @{ text = "PocketMC Build System" }
})
components = @(
@{
type = 1
components = @(
@{
type = 2
style = 5
label = "Download Release"
url = "https://github.com/PocketMC/pocket-mc-windows/releases/tag/v${{ steps.config.outputs.version }}"
},
@{
type = 2
style = 5
label = "View Full Changelog"
url = "https://github.com/PocketMC/pocket-mc-windows/blob/master/CHANGELOG.md"
}
)
}
)
}
try {
Invoke-RestMethod -Uri $webhookUrl -Method Post -Body ($payload | ConvertTo-Json -Depth 5) -ContentType "application/json"
} catch {
Write-Warning "Failed to send Discord notification: $_"
}