mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-12-04 15:09:44 +01:00
350 lines
13 KiB
YAML
350 lines
13 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 Windows SDK environment
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
|
|
- name: Setup LLVM 23
|
|
uses: KyleMayes/install-llvm-action@v2
|
|
with:
|
|
version: '23.1.0'
|
|
|
|
- name: Setup CMake
|
|
uses: lukka/get-cmake@latest
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '10.0.x'
|
|
|
|
- name: Configure Clang and LLD
|
|
run: >-
|
|
cmake --preset windows64
|
|
-DCMAKE_C_COMPILER=clang-cl
|
|
-DCMAKE_CXX_COMPILER=clang-cl
|
|
-DCMAKE_LINKER=lld-link
|
|
-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld
|
|
-DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld
|
|
-DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=lld
|
|
|
|
- name: Build Client
|
|
run: cmake --build --preset windows64-release --target Minecraft.Client
|
|
|
|
- name: Build Server
|
|
run: >-
|
|
cmake --build --preset windows64-release
|
|
--target Minecraft.Server
|
|
--target Minecraft.Server.FourKit
|
|
|
|
- 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', '.exp', '.iobj', '.ipdb', '.lib' }
|
|
|
|
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: 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: |
|
|
Remove-Item -Recurse -Force staging -ErrorAction SilentlyContinue
|
|
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: windows-10
|
|
|
|
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: pwsh
|
|
run: |
|
|
foreach ($line in Get-Content artifacts/server.txt) {
|
|
$filename, $url = $line -split '=', 2
|
|
Write-Host "Downloading $filename..."
|
|
Invoke-WebRequest -Uri $url -OutFile "artifacts/$filename"
|
|
}
|
|
Remove-Item artifacts/server.txt
|
|
|
|
- name: Fetch information
|
|
id: vars
|
|
shell: pwsh
|
|
run: |
|
|
$version = (Get-Content BUMP -Raw).Trim()
|
|
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
|
"description<<EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
|
(Get-Content NOTES.md -Raw).TrimEnd() | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
|
"EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
|
|
|
- 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: pwsh
|
|
run: |
|
|
foreach ($line in Get-Content artifacts/client.txt) {
|
|
$filename, $url = $line -split '=', 2
|
|
Write-Host "Downloading $filename..."
|
|
Invoke-WebRequest -Uri $url -OutFile "artifacts/$filename"
|
|
}
|
|
Remove-Item artifacts/client.txt
|
|
|
|
- name: Fetch information
|
|
id: vars
|
|
shell: pwsh
|
|
run: |
|
|
$version = (Get-Content BUMP -Raw).Trim()
|
|
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
|
"description<<EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
|
(Get-Content NOTES.md -Raw).TrimEnd() | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
|
"EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
|
|
|
- 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: windows-10
|
|
steps:
|
|
- name: Delete build artifacts
|
|
shell: pwsh
|
|
env:
|
|
FORGE_TOKEN: ${{ gitea.token }}
|
|
REPO: ${{ gitea.repository }}
|
|
API: ${{ gitea.server_url }}/api/v1
|
|
run: |
|
|
$headers = @{ Authorization = "token $env:FORGE_TOKEN" }
|
|
$artifacts = Invoke-RestMethod `
|
|
-Uri "$env:API/repos/$env:REPO/actions/artifacts?name=build-windows64" `
|
|
-Headers $headers
|
|
foreach ($artifact in $artifacts.artifacts) {
|
|
if ($artifact.id) {
|
|
Invoke-RestMethod -Method Delete `
|
|
-Uri "$env:API/repos/$env:REPO/actions/artifacts/$($artifact.id)" `
|
|
-Headers $headers | Out-Null
|
|
}
|
|
}
|