Skip to content

Release Pipeline

Release Pipeline #12

Workflow file for this run

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: $_"
}