Files
neoLegacy/.github/workflows/stable.yml
2026-07-12 18:51:57 -04:00

343 lines
12 KiB
YAML

name: Stable Release
on:
push:
paths:
- 'BUMP' #neo: this is a file. edit it. contains version number
#neo: DO NOT ADD NOTES.md HERE.
workflow_dispatch:
permissions:
contents: write
id-token: write
attestations: write
concurrency:
group: stable
cancel-in-progress: true
jobs:
build-client-and-server:
name: Build Client and Server
runs-on: windows-10
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Setup CMake
uses: lukka/get-cmake@latest
- name: Build Client
uses: lukka/run-cmake@v10
env:
VCPKG_ROOT: ""
with:
configurePreset: windows64
buildPreset: windows64-release
buildPresetAdditionalArgs: "['--target', 'Minecraft.Client']"
- name: Zip Build
shell: pwsh
run: |
$source = "./build/windows64/Minecraft.Client/Release"
$zip = "neoLegacyWindows64.zip"
$topLevel = "neoLegacyWindows64"
# Collect files, excluding unwanted extensions
$files = Get-ChildItem -Path $source -Recurse -File |
Where-Object { $_.Extension -notin '.pch', '.zip', '.ipdb', '.iobj' }
Add-Type -AssemblyName System.IO.Compression
Add-Type -AssemblyName System.IO.Compression.FileSystem
$basePath = (Resolve-Path $source).Path
$fs = [System.IO.File]::Open($zip, [System.IO.FileMode]::Create)
try {
$archive = New-Object System.IO.Compression.ZipArchive($fs, [System.IO.Compression.ZipArchiveMode]::Create)
try {
# Add directories
Get-ChildItem -Path $basePath -Recurse -Directory | ForEach-Object {
$rel = $_.FullName.Substring($basePath.Length).TrimStart('\', '/')
$archive.CreateEntry("$topLevel/$($rel -replace '\\','/')/") | Out-Null
}
# Add files
foreach ($file in $files) {
$rel = $file.FullName.Substring($basePath.Length).TrimStart('\', '/')
$entryName = "$topLevel/$($rel -replace '\\','/')"
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile(
$archive, $file.FullName, $entryName,
[System.IO.Compression.CompressionLevel]::Optimal
) | Out-Null
}
} finally { $archive.Dispose() }
} finally { $fs.Dispose() }
Write-Host "Created $zip"
- name: Stage artifacts
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path staging
Copy-Item neoLegacyWindows64.zip staging/
- name: Upload Artifacts
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path upload
Get-ChildItem staging | ForEach-Object {
Write-Host "Uploading $($_.FullName)..."
$url = curl.exe -s `
-F "reqtype=fileupload" `
-F "time=1h" `
-F "fileToUpload=@$($_.FullName)" `
https://litterbox.catbox.moe/resources/internals/api.php
"$($_.Name)=$url" | Tee-Object -Append upload/client.txt
}
- name: Upload client links
uses: christopherhx/gitea-upload-artifact@v4
with:
name: client-release
path: upload/client.txt
- name: Build Server
uses: lukka/run-cmake@v10
env:
VCPKG_ROOT: ""
with:
configurePreset: windows64
buildPreset: windows64-release
buildPresetAdditionalArgs: "['--target', 'Minecraft.Server', '--target', 'Minecraft.Server.FourKit']"
- name: Zip Build (vanilla)
shell: pwsh
run: |
$source = "./build/windows64/Minecraft.Server/Release"
$zip = "neoLegacyServerWindows64.zip"
$topLevel = "neoLegacyServerWindows64"
$files = Get-ChildItem -Path $source -Recurse -File |
Where-Object { $_.Extension -notin '.pch', '.zip', '.ipdb', '.iobj' }
Add-Type -AssemblyName System.IO.Compression
Add-Type -AssemblyName System.IO.Compression.FileSystem
$basePath = (Resolve-Path $source).Path
$fs = [System.IO.File]::Open($zip, [System.IO.FileMode]::Create)
try {
$archive = New-Object System.IO.Compression.ZipArchive($fs, [System.IO.Compression.ZipArchiveMode]::Create)
try {
Get-ChildItem -Path $basePath -Recurse -Directory | ForEach-Object {
$rel = $_.FullName.Substring($basePath.Length).TrimStart('\', '/')
$archive.CreateEntry("$topLevel/$($rel -replace '\\','/')/") | Out-Null
}
foreach ($file in $files) {
$rel = $file.FullName.Substring($basePath.Length).TrimStart('\', '/')
$entryName = "$topLevel/$($rel -replace '\\','/')"
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile(
$archive, $file.FullName, $entryName,
[System.IO.Compression.CompressionLevel]::Optimal
) | Out-Null
}
} finally { $archive.Dispose() }
} finally { $fs.Dispose() }
Write-Host "Created $zip"
- name: Zip Build (FourKit)
shell: pwsh
run: |
$source = "./build/windows64/Minecraft.Server.FourKit/Release"
$zip = "neoLegacyServerWindows64-FourKit.zip"
$topLevel = "neoLegacyServerWindows64-FourKit"
$files = Get-ChildItem -Path $source -Recurse -File |
Where-Object { $_.Extension -notin '.pch', '.zip', '.ipdb', '.iobj' }
Add-Type -AssemblyName System.IO.Compression
Add-Type -AssemblyName System.IO.Compression.FileSystem
$basePath = (Resolve-Path $source).Path
$fs = [System.IO.File]::Open($zip, [System.IO.FileMode]::Create)
try {
$archive = New-Object System.IO.Compression.ZipArchive($fs, [System.IO.Compression.ZipArchiveMode]::Create)
try {
Get-ChildItem -Path $basePath -Recurse -Directory | ForEach-Object {
$rel = $_.FullName.Substring($basePath.Length).TrimStart('\', '/')
$archive.CreateEntry("$topLevel/$($rel -replace '\\','/')/") | Out-Null
}
foreach ($file in $files) {
$rel = $file.FullName.Substring($basePath.Length).TrimStart('\', '/')
$entryName = "$topLevel/$($rel -replace '\\','/')"
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile(
$archive, $file.FullName, $entryName,
[System.IO.Compression.CompressionLevel]::Optimal
) | Out-Null
}
} finally { $archive.Dispose() }
} finally { $fs.Dispose() }
Write-Host "Created $zip"
- name: Stage artifacts
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path staging
Copy-Item neoLegacyServerWindows64.zip staging/
Copy-Item neoLegacyServerWindows64-FourKit.zip staging/
- name: Upload Artifacts
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path upload
Get-ChildItem staging | ForEach-Object {
Write-Host "Uploading $($_.FullName)..."
$url = curl.exe -s `
-F "reqtype=fileupload" `
-F "time=1h" `
-F "fileToUpload=@$($_.FullName)" `
https://litterbox.catbox.moe/resources/internals/api.php
"$($_.Name)=$url" | Tee-Object -Append upload/server.txt
}
- name: Upload links
uses: christopherhx/gitea-upload-artifact@v4
with:
name: server-release
path: upload/server.txt
release-client-and-server:
name: Release Downloads
needs: build-client-and-server
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download build artifacts
uses: christopherhx/gitea-download-artifact@v4
with:
name: server-release
path: artifacts
- name: Download release files
shell: bash
run: |
sed -i 's/\r$//' artifacts/server.txt
while IFS='=' read -r filename url; do
echo "Downloading $filename..."
curl -L "$url" -o "artifacts/$filename"
done < artifacts/server.txt
rm artifacts/server.txt
- name: Attest artifacts
uses: actions/attest-build-provenance@v2
with:
subject-path: |
artifacts/neoLegacyServerWindows64.zip
artifacts/neoLegacyServerWindows64-FourKit.zip
- name: Fetch information
id: vars
run: |
VERSION="$(tr -d '\r\n' < BUMP)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
{
echo "description<<EOF"
cat NOTES.md
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Publish stable server release
uses: akkuman/gitea-release-action@v1
with:
name: v${{ steps.vars.outputs.version }} Server
direction: upload
server_url: ${{ gitea.server_url }}
repository: ${{ gitea.repository }}
token: ${{ gitea.token }}
tag_name: v${{ steps.vars.outputs.version }}-Dedicated-Server
prerelease: false
# override: true
verbose: true
files: artifacts/neoLegacyServerWindows64*.zip
body: |
Dedicated Server runtime for Windows64.
Two flavours are attached:
- \`neoLegacyServerWindows64.zip\`: vanilla server, no plugin support, smallest download.
- \`neoLegacyServerWindows64-FourKit.zip\`: server with the FourKit plugin host, bundled .NET 10 runtime, and an empty \`plugins/\` folder ready for plugin authors to drop DLLs into.
Pick the flavour you want and extract it to a folder where you'd like to keep the server runtime.
- name: Download build artifacts
uses: christopherhx/gitea-download-artifact@v4
with:
name: client-release
path: artifacts
- name: Download release files
shell: bash
run: |
sed -i 's/\r$//' artifacts/client.txt
while IFS='=' read -r filename url; do
echo "Downloading $filename..."
curl -L "$url" -o "artifacts/$filename"
done < artifacts/client.txt
rm artifacts/client.txt
- name: Attest artifacts
uses: actions/attest-build-provenance@v2
with:
subject-path: |
artifacts/neoLegacyWindows64.zip
- name: Fetch information
id: vars
run: |
VERSION="$(tr -d '\r\n' < BUMP)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
{
echo "description<<EOF"
cat NOTES.md
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Publish stable client release
uses: akkuman/gitea-release-action@v1
with:
name: v${{ steps.vars.outputs.version }}
direction: upload
server_url: ${{ gitea.server_url }}
repository: ${{ gitea.repository }}
token: ${{ gitea.token }}
tag_name: v${{ steps.vars.outputs.version }}
prerelease: false
# override: true
verbose: true
files: artifacts/neoLegacyWindows64.zip
body: ${{ steps.vars.outputs.description }}
cleanup:
needs: [release-client-and-server]
if: always()
runs-on: ubuntu-latest
steps:
- name: Cleanup artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: |
client-release
server-release