This commit is contained in:
ZekerZhayard authored and GitHub committed 2026-05-21 11:31:52 +08:00
1 parent faebfc9bb1
commit 8b5d440ed7
287 files changed
+6431 -6792

No files matched your search

+3 -3
View File
@@ -2,7 +2,7 @@ blank_issues_enabled: false
contact_links:
- name: Telegram
url: https://t.me/customskinloader
about: Gugugu
- name: QQ
about: Community chat for CustomSkinLoader users.
- name: QQ Group
url: https://jq.qq.com/?_wv=1027&k=vF16R5tg
about: Gugugu
about: Chinese community chat for CustomSkinLoader users.
+15
View File
@@ -0,0 +1,15 @@
param(
[string] $GradleCommand = "./gradlew.bat"
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$ScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepositoryRoot = (Resolve-Path -LiteralPath (Join-Path $ScriptRoot "../..")).Path
Set-Location -LiteralPath $RepositoryRoot
& $GradleCommand clean build --stacktrace
if ($LASTEXITCODE -ne 0) {
throw "Gradle build failed with exit code $LASTEXITCODE."
}
+51
View File
@@ -0,0 +1,51 @@
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$RunnerTemp = if ([string]::IsNullOrWhiteSpace($env:RUNNER_TEMP)) {
[System.IO.Path]::GetTempPath()
} else {
$env:RUNNER_TEMP
}
function Add-ActionPath {
param([Parameter(Mandatory = $true)][string] $Path)
$env:Path = "$Path;$env:Path"
if (-not [string]::IsNullOrWhiteSpace($env:GITHUB_PATH)) {
Add-Content -LiteralPath $env:GITHUB_PATH -Value $Path
}
}
if (-not (Get-Command aws -ErrorAction SilentlyContinue)) {
$installer = Join-Path $RunnerTemp "AWSCLIV2.msi"
Invoke-WebRequest -Uri "https://awscli.amazonaws.com/AWSCLIV2.msi" -OutFile $installer
$install = Start-Process msiexec.exe -Wait -PassThru -ArgumentList "/i `"$installer`" /qn"
if ($install.ExitCode -ne 0) {
throw "AWS CLI installer failed with exit code $($install.ExitCode)."
}
$awsCliDir = Join-Path $env:ProgramFiles "Amazon/AWSCLIV2"
$machinePath = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
$env:Path = "$awsCliDir;$machinePath;$userPath;$env:Path"
if (-not [string]::IsNullOrWhiteSpace($env:GITHUB_PATH)) {
Add-Content -LiteralPath $env:GITHUB_PATH -Value $awsCliDir
}
}
if (-not (Get-Command coscli -ErrorAction SilentlyContinue)) {
$coscliDir = Join-Path $RunnerTemp "coscli"
New-Item -ItemType Directory -Force -Path $coscliDir | Out-Null
Invoke-WebRequest -Uri "https://github.com/tencentyun/coscli/releases/download/v1.0.8/coscli-v1.0.8-windows-amd64.exe" -OutFile (Join-Path $coscliDir "coscli.exe")
Add-ActionPath $coscliDir
}
if (-not (Get-Command tccli -ErrorAction SilentlyContinue)) {
python -m pip install --user tccli
if ($LASTEXITCODE -ne 0) {
throw "tccli install failed with exit code $LASTEXITCODE."
}
$pythonUserScripts = Join-Path (python -m site --user-base) "Scripts"
Add-ActionPath $pythonUserScripts
}
@@ -0,0 +1,35 @@
param(
[string] $SourcePath = "Bootstrap/build/libs",
[string] $DestinationPath = "build/publish"
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$ScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepositoryRoot = (Resolve-Path -LiteralPath (Join-Path $ScriptRoot "../..")).Path
Set-Location -LiteralPath $RepositoryRoot
function Resolve-RepoPath {
param([Parameter(Mandatory = $true)][string] $Path)
if ([System.IO.Path]::IsPathRooted($Path)) {
return [System.IO.Path]::GetFullPath($Path)
}
return [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($RepositoryRoot, $Path))
}
$source = Resolve-RepoPath $SourcePath
$destination = Resolve-RepoPath $DestinationPath
New-Item -ItemType Directory -Force -Path $destination | Out-Null
$jars = Get-ChildItem -LiteralPath $source -Filter "CustomSkinLoader_Universal-*.jar" -File |
Where-Object { $_.Name -notlike "*-sources.jar" }
if (-not $jars) {
throw "No Universal jar found under $SourcePath."
}
$jars | Copy-Item -Destination $destination -Force
@@ -0,0 +1,25 @@
param(
[string] $Channel = $env:PUBLISH_CHANNEL,
[string] $LatestJsonName = $env:LATEST_JSON_NAME,
[string] $DetailJsonName = $env:DETAIL_JSON_NAME
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
if ([string]::IsNullOrWhiteSpace($Channel)) {
$Channel = "Beta"
}
$publishScript = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) "publish-artifacts.ps1"
$arguments = @("-Channel", $Channel)
if (-not [string]::IsNullOrWhiteSpace($LatestJsonName)) {
$arguments += @("-LatestJsonName", $LatestJsonName)
}
if (-not [string]::IsNullOrWhiteSpace($DetailJsonName)) {
$arguments += @("-DetailJsonName", $DetailJsonName)
}
& $publishScript @arguments
+427
View File
@@ -0,0 +1,427 @@
param(
[ValidateSet("Beta", "Release")]
[string] $Channel = "Beta",
[string] $LatestJsonName,
[string] $DetailJsonName,
[string] $ArtifactsRoot = "build/publish",
[switch] $SkipObjectStorage
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$ScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepositoryRoot = (Resolve-Path -LiteralPath (Join-Path $ScriptRoot "..\..")).Path
Set-Location -LiteralPath $RepositoryRoot
function Resolve-RepoPath {
param([Parameter(Mandatory = $true)][string] $Path)
if ([System.IO.Path]::IsPathRooted($Path)) {
return [System.IO.Path]::GetFullPath($Path)
}
return [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($RepositoryRoot, $Path))
}
function ConvertTo-ShortVersion {
param([Parameter(Mandatory = $true)][string] $Version)
return $Version.Replace("SNAPSHOT-", "s")
}
function Read-BuildProperties {
$properties = [ordered] @{}
foreach ($line in Get-Content -LiteralPath (Resolve-RepoPath "build.properties")) {
$trimmedLine = $line.Trim()
if ([string]::IsNullOrWhiteSpace($trimmedLine) -or $trimmedLine.StartsWith("#")) {
continue
}
$separatorIndex = $trimmedLine.IndexOf("=")
if ($separatorIndex -lt 1) {
continue
}
$name = $trimmedLine.Substring(0, $separatorIndex).Trim()
$value = $trimmedLine.Substring($separatorIndex + 1).Trim()
$properties[$name] = $value
}
return $properties
}
function Get-RequiredProperty {
param(
[Parameter(Mandatory = $true)][System.Collections.IDictionary] $Properties,
[Parameter(Mandatory = $true)][string] $Name
)
$value = $Properties[$Name]
if ([string]::IsNullOrWhiteSpace($value)) {
throw "Missing $Name in build.properties"
}
return $value
}
function Get-PropertyList {
param(
[Parameter(Mandatory = $true)][System.Collections.IDictionary] $Properties,
[Parameter(Mandatory = $true)][string] $Name
)
return (Get-RequiredProperty $Properties $Name) -split "," |
ForEach-Object { $_.Trim() } |
Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
}
function Get-PropertyListByNames {
param(
[Parameter(Mandatory = $true)][System.Collections.IDictionary] $Properties,
[Parameter(Mandatory = $true)][string[]] $Names
)
foreach ($name in $Names) {
if (-not [string]::IsNullOrWhiteSpace($Properties[$name])) {
return Get-PropertyList $Properties $name
}
}
throw "Missing one of these properties in build.properties: $($Names -join ', ')"
}
function Test-VersionAtLeast {
param(
[Parameter(Mandatory = $true)][string] $Version,
[Parameter(Mandatory = $true)][string] $MinimumVersion
)
return [version] $Version -ge [version] $MinimumVersion
}
function Get-VersionFromJarName {
param([Parameter(Mandatory = $true)][string] $FileName)
$prefix = "CustomSkinLoader_Universal-"
$suffix = ".jar"
if (-not $FileName.StartsWith($prefix) -or -not $FileName.EndsWith($suffix)) {
throw "Unexpected Universal jar name: $FileName"
}
return $FileName.Substring($prefix.Length, $FileName.Length - $prefix.Length - $suffix.Length)
}
function New-Directory {
param([Parameter(Mandatory = $true)][string] $Path)
[System.IO.Directory]::CreateDirectory((Resolve-RepoPath $Path)) | Out-Null
}
function Copy-PublishArtifacts {
param([Parameter(Mandatory = $true)][string] $Destination)
New-Directory $Destination
$destinationPath = Resolve-RepoPath $Destination
Get-ChildItem -LiteralPath $destinationPath -File -ErrorAction SilentlyContinue | Remove-Item -Force
$jar = Get-ChildItem -LiteralPath (Resolve-RepoPath "Bootstrap/build/libs") -Filter "CustomSkinLoader_Universal-*.jar" -File -ErrorAction Stop |
Where-Object { $_.Name -notlike "*-sources.jar" } |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
if (-not $jar) {
throw "No Universal jar found under Bootstrap/build/libs."
}
Copy-Item -LiteralPath $jar.FullName -Destination (Join-Path $destinationPath $jar.Name) -Force
return Get-Item -LiteralPath (Join-Path $destinationPath $jar.Name)
}
function ConvertTo-JsonFile {
param(
[Parameter(Mandatory = $true)] $InputObject,
[Parameter(Mandatory = $true)][string] $Path
)
$json = $InputObject | ConvertTo-Json -Depth 10
$absolutePath = Resolve-RepoPath $Path
[System.IO.Directory]::CreateDirectory([System.IO.Path]::GetDirectoryName($absolutePath)) | Out-Null
[System.IO.File]::WriteAllText($absolutePath, $json + [System.Environment]::NewLine, [System.Text.UTF8Encoding]::new($false))
}
function New-Metadata {
param(
[Parameter(Mandatory = $true)][string] $Version,
[Parameter(Mandatory = $true)][string] $OutputDirectory,
[Parameter(Mandatory = $true)][string] $LatestName,
[Parameter(Mandatory = $true)][string] $DetailName,
[Parameter(Mandatory = $true)][System.Collections.IDictionary] $BuildProperties
)
$publicBaseUrl = if ([string]::IsNullOrWhiteSpace($env:CLOUDFLARE_CDN_ROOT)) { "https://csl.3-3.dev/" } else { $env:CLOUDFLARE_CDN_ROOT.Trim() }
if (-not $publicBaseUrl.EndsWith("/")) {
$publicBaseUrl += "/"
}
$outputPath = Resolve-RepoPath $OutputDirectory
$jars = Get-ChildItem -LiteralPath $outputPath -Filter "CustomSkinLoader_Universal-*.jar" -File |
Sort-Object Name
if (-not $jars) {
throw "No publish jars found in $OutputDirectory."
}
$latest = [ordered] @{
version = ConvertTo-ShortVersion $Version
downloads = [ordered] @{}
launchermeta = [ordered] @{}
}
foreach ($jar in $jars) {
$latest.downloads["Universal"] = "$publicBaseUrl`mods/$($jar.Name)"
}
$minecraftMajorVersions = Get-PropertyList $BuildProperties "minecraft_major_versions"
$detailMap = [ordered] @{}
foreach ($minecraftVersion in $minecraftMajorVersions) {
$loaderMap = [ordered] @{}
$loaderMap["Forge"] = $latest.downloads["Universal"]
if (Test-VersionAtLeast $minecraftVersion "1.14") {
$loaderMap["Fabric"] = $latest.downloads["Universal"]
$loaderMap["Quilt"] = $latest.downloads["Universal"]
}
if (Test-VersionAtLeast $minecraftVersion "1.20") {
$loaderMap["NeoForge"] = $latest.downloads["Universal"]
}
$detailMap[$minecraftVersion] = $loaderMap
}
$detail = [ordered] @{
version = $latest.version
timestamp = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
details = $detailMap
}
ConvertTo-JsonFile $latest (Join-Path $outputPath $LatestName)
ConvertTo-JsonFile $detail (Join-Path $outputPath $DetailName)
}
function Write-GitHubOutputValue {
param(
[Parameter(Mandatory = $true)][string] $Name,
[Parameter(Mandatory = $true)][string] $Value
)
if ([string]::IsNullOrWhiteSpace($env:GITHUB_OUTPUT)) {
return
}
$delimiter = "EOF_$([guid]::NewGuid().ToString('N'))"
$content = "$Name<<$delimiter" + [System.Environment]::NewLine +
$Value + [System.Environment]::NewLine +
$delimiter + [System.Environment]::NewLine
[System.IO.File]::AppendAllText($env:GITHUB_OUTPUT, $content, [System.Text.UTF8Encoding]::new($false))
}
function Write-PublishOutputs {
param(
[Parameter(Mandatory = $true)][string] $Version,
[Parameter(Mandatory = $true)][System.Collections.IDictionary] $BuildProperties
)
$shortVersion = ConvertTo-ShortVersion $Version
$edition = Get-RequiredProperty $BuildProperties "edition"
Write-GitHubOutputValue "edition" $edition
Write-GitHubOutputValue "version" $shortVersion
Write-GitHubOutputValue "mc_publish_name" "CustomSkinLoader_$edition`_$shortVersion"
Write-GitHubOutputValue "mc_publish_version" "$shortVersion-$edition"
Write-GitHubOutputValue "loaders" ((Get-PropertyListByNames $BuildProperties @("loaders", "mod_loaders")) -join [System.Environment]::NewLine)
Write-GitHubOutputValue "game_versions" ((Get-PropertyListByNames $BuildProperties @("game-versions", "minecraft_major_versions")) -join [System.Environment]::NewLine)
Write-GitHubOutputValue "java_versions" ((Get-PropertyListByNames $BuildProperties @("java", "java_full_versions")) -join [System.Environment]::NewLine)
}
function Invoke-AwsCliUpload {
param(
[Parameter(Mandatory = $true)][string] $EndpointUrl,
[Parameter(Mandatory = $true)][string] $Bucket,
[Parameter(Mandatory = $true)][string] $AccessKeyId,
[Parameter(Mandatory = $true)][string] $SecretAccessKey,
[Parameter(Mandatory = $true)][string] $Directory
)
$aws = Get-Command aws -ErrorAction SilentlyContinue
if (-not $aws) {
Write-Warning "AWS CLI was not found. Skip S3-compatible upload."
return
}
$oldAccessKey = $env:AWS_ACCESS_KEY_ID
$oldSecretKey = $env:AWS_SECRET_ACCESS_KEY
$oldRegion = $env:AWS_DEFAULT_REGION
try {
$env:AWS_ACCESS_KEY_ID = $AccessKeyId
$env:AWS_SECRET_ACCESS_KEY = $SecretAccessKey
$env:AWS_DEFAULT_REGION = "auto"
foreach ($file in Get-ChildItem -LiteralPath $Directory -File) {
$key = if ($file.Extension -eq ".jar") { "mods/$($file.Name)" } else { $file.Name }
& aws --endpoint-url $EndpointUrl s3 cp $file.FullName "s3://$Bucket/$key" --only-show-errors
}
} finally {
$env:AWS_ACCESS_KEY_ID = $oldAccessKey
$env:AWS_SECRET_ACCESS_KEY = $oldSecretKey
$env:AWS_DEFAULT_REGION = $oldRegion
}
}
function Invoke-CosCliUpload {
param(
[Parameter(Mandatory = $true)][string] $Bucket,
[Parameter(Mandatory = $true)][string] $SecretId,
[Parameter(Mandatory = $true)][string] $SecretKey,
[Parameter(Mandatory = $true)][string] $Directory
)
$coscli = Get-Command coscli -ErrorAction SilentlyContinue
if (-not $coscli) {
Write-Warning "coscli was not found. Skip Tencent COS upload."
return
}
$configPath = Join-Path $env:RUNNER_TEMP "coscli-customskinloader.yaml"
$cosRegion = if ([string]::IsNullOrWhiteSpace($env:COS_REGION)) { "ap-shanghai" } else { $env:COS_REGION.Trim() }
@"
cos:
base:
secretid: $SecretId
secretkey: $SecretKey
sessiontoken: ""
protocol: https
buckets:
- name: $Bucket
alias: $Bucket
region: $cosRegion
endpoint: cos.$cosRegion.myqcloud.com
ofs: false
"@ | Set-Content -LiteralPath $configPath -Encoding UTF8
foreach ($file in Get-ChildItem -LiteralPath $Directory -File) {
$key = if ($file.Extension -eq ".jar") { "mods/$($file.Name)" } else { $file.Name }
& coscli -c $configPath cp $file.FullName "cos://$Bucket/$key"
}
}
function Get-PublishObjectKeys {
param([Parameter(Mandatory = $true)][string] $Directory)
return Get-ChildItem -LiteralPath $Directory -File |
ForEach-Object {
if ($_.Extension -eq ".jar") {
"mods/$($_.Name)"
} else {
$_.Name
}
}
}
function Invoke-TencentCdnRefresh {
param([Parameter(Mandatory = $true)][string[]] $Keys)
$cdnRoot = if ([string]::IsNullOrWhiteSpace($env:TENCENT_CDN_ROOT)) { "https://csl.littleservice.cn/" } else { $env:TENCENT_CDN_ROOT.Trim() }
if (-not $cdnRoot.EndsWith("/")) {
$cdnRoot += "/"
}
if ([string]::IsNullOrWhiteSpace($env:COS_SECRET_ID) -or [string]::IsNullOrWhiteSpace($env:COS_SECRET_KEY)) {
Write-Host "Tencent CDN credentials are incomplete. Skip CDN refresh."
return
}
$tccli = Get-Command tccli -ErrorAction SilentlyContinue
if (-not $tccli) {
Write-Warning "tccli was not found. Skip Tencent CDN refresh."
return
}
$oldSecretId = $env:TENCENTCLOUD_SECRET_ID
$oldSecretKey = $env:TENCENTCLOUD_SECRET_KEY
try {
$env:TENCENTCLOUD_SECRET_ID = $env:COS_SECRET_ID
$env:TENCENTCLOUD_SECRET_KEY = $env:COS_SECRET_KEY
$urlsJson = ConvertTo-Json -Compress -InputObject @($Keys | ForEach-Object { "$cdnRoot$_" })
& tccli cdn PurgeUrlsCache --Urls $urlsJson
if ($LASTEXITCODE -ne 0) {
throw "Tencent CDN purge failed."
}
& tccli cdn PushUrlsCache --Urls $urlsJson
if ($LASTEXITCODE -ne 0) {
throw "Tencent CDN push failed."
}
} finally {
$env:TENCENTCLOUD_SECRET_ID = $oldSecretId
$env:TENCENTCLOUD_SECRET_KEY = $oldSecretKey
}
}
if ([string]::IsNullOrWhiteSpace($LatestJsonName)) {
$LatestJsonName = switch ($Channel) {
"Beta" { "latest-beta.json" }
"Canary" { "latest-canary.json" }
"Release" { "latest.json" }
}
}
if ([string]::IsNullOrWhiteSpace($DetailJsonName)) {
$DetailJsonName = switch ($Channel) {
"Beta" { "detail-beta.json" }
"Canary" { "detail-canary.json" }
"Release" { "detail.json" }
}
}
New-Directory $ArtifactsRoot
$buildProperties = Read-BuildProperties
$artifacts = Copy-PublishArtifacts $ArtifactsRoot
$ArtifactsRoot = Resolve-RepoPath $ArtifactsRoot
$fullVersion = Get-VersionFromJarName $artifacts[0].Name
New-Metadata -Version $fullVersion -OutputDirectory $ArtifactsRoot -LatestName $LatestJsonName -DetailName $DetailJsonName -BuildProperties $buildProperties
Write-PublishOutputs -Version $fullVersion -BuildProperties $buildProperties
Write-Host "Prepared publish artifacts:"
Get-ChildItem -LiteralPath $ArtifactsRoot -File | ForEach-Object { Write-Host " - $($_.Name)" }
if ($SkipObjectStorage) {
Write-Host "SkipObjectStorage was set. Metadata generated locally only."
exit 0
}
if (-not [string]::IsNullOrWhiteSpace($env:R2_BASE_URL) -and
-not [string]::IsNullOrWhiteSpace($env:R2_BUCKET) -and
-not [string]::IsNullOrWhiteSpace($env:R2_SECRET_ID) -and
-not [string]::IsNullOrWhiteSpace($env:R2_SECRET_KEY)) {
Invoke-AwsCliUpload -EndpointUrl $env:R2_BASE_URL -Bucket $env:R2_BUCKET -AccessKeyId $env:R2_SECRET_ID -SecretAccessKey $env:R2_SECRET_KEY -Directory $ArtifactsRoot
} else {
Write-Host "R2 secrets are incomplete. Skip R2 upload."
}
if (-not [string]::IsNullOrWhiteSpace($env:COS_BUCKET) -and
-not [string]::IsNullOrWhiteSpace($env:COS_SECRET_ID) -and
-not [string]::IsNullOrWhiteSpace($env:COS_SECRET_KEY)) {
Invoke-CosCliUpload -Bucket $env:COS_BUCKET -SecretId $env:COS_SECRET_ID -SecretKey $env:COS_SECRET_KEY -Directory $ArtifactsRoot
} else {
Write-Host "COS secrets are incomplete. Skip COS upload."
}
Invoke-TencentCdnRefresh -Keys @(Get-PublishObjectKeys $ArtifactsRoot)
+37
View File
@@ -0,0 +1,37 @@
param(
[string] $BranchName = $env:GITHUB_REF_NAME,
[string] $BuildType = $env:BUILD_TYPE,
[string] $OutputPath = "build/publish/release-notes.md",
[string] $TimeZoneId = "China Standard Time"
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$ScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepositoryRoot = (Resolve-Path -LiteralPath (Join-Path $ScriptRoot "../..")).Path
Set-Location -LiteralPath $RepositoryRoot
if ([string]::IsNullOrWhiteSpace($BranchName)) {
throw "BranchName is required."
}
if ([string]::IsNullOrWhiteSpace($BuildType)) {
throw "BuildType is required."
}
$absoluteOutputPath = if ([System.IO.Path]::IsPathRooted($OutputPath)) {
[System.IO.Path]::GetFullPath($OutputPath)
} else {
[System.IO.Path]::GetFullPath([System.IO.Path]::Combine($RepositoryRoot, $OutputPath))
}
[System.IO.Directory]::CreateDirectory([System.IO.Path]::GetDirectoryName($absoluteOutputPath)) | Out-Null
$buildTime = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId([DateTime]::UtcNow, $TimeZoneId).ToString("yyyy.MM.dd HH:mm")
@"
Build Time / 构建时间: $buildTime
Synchronize $BranchName branch code updates, keeping only the latest $BuildType build.
自动同步 $BranchName 分支构建产物,仅保留最新 $BuildType 版本。
"@ | Set-Content -LiteralPath $absoluteOutputPath -Encoding UTF8
+10 -3
View File
@@ -1,8 +1,10 @@
name: Beta
on:
push:
branches:
- '14-develop'
- 15-develop
workflow_dispatch:
jobs:
build-beta:
@@ -10,5 +12,10 @@ jobs:
uses: ./.github/workflows/common.yml
with:
type: Beta
publish-task: uploadBeta
secrets: inherit
publish: true
prerelease-tag: Beta-Build
prerelease-name: CustomSkinLoader Beta Build
latest-json: latest-beta.json
detail-json: detail-beta.json
is-snapshot: true
secrets: inherit
-14
View File
@@ -1,14 +0,0 @@
name: Canary
on:
push:
branches:
- '15-develop'
jobs:
build-canary:
name: Build Canary
uses: ./.github/workflows/common.yml
with:
type: Canary
publish-task: uploadCanary
secrets: inherit
+128 -193
View File
@@ -1,215 +1,149 @@
name: Common
on:
workflow_call:
inputs:
type:
required: true
type: string
publish-task:
publish:
required: false
type: boolean
default: false
release:
required: false
type: boolean
default: false
prerelease-tag:
required: false
type: string
default: ""
prerelease-name:
required: false
type: string
default: ""
latest-json:
required: false
type: string
default: latest-beta.json
detail-json:
required: false
type: string
default: detail-beta.json
is-snapshot:
required: false
type: boolean
default: true
jobs:
build-common:
name: Build
runs-on: ubuntu-latest
environment: Build
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'gradle'
-
name: Build
env:
KEY_PASS: ${{ secrets.KEY_PASS }}
IS_SNAPSHOT: ${{ inputs.is-snapshot }}
run: |
echo Snapshot: $IS_SNAPSHOT
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $GITHUB_SHA)
./gradlew clean build --stacktrace
-
uses: actions/upload-artifact@v4
name: Publish to Github Artifact
with:
name: CustomSkinLoader-${{ inputs.type }}-${{ github.run_number }}
path: build/libs
permissions:
contents: write
Upload:
if: inputs.publish-task
needs: build-common
continue-on-error: true
environment: Build
strategy:
matrix:
website: [CurseForge_Modrinth]
modtype: [Fabric,ForgeV1,ForgeV2,ForgeV3]
include:
-
website: ObjectStorage
modtype: All
# -
# website: GitHub-Release
# modtype: All
-
website: GitHub-PreRelease
modtype: All
name: ${{ matrix.website }} (${{ matrix.modtype}})
runs-on: ubuntu-latest
jobs:
build:
name: Build
runs-on: windows-latest
defaults:
run:
shell: powershell
steps:
-
name: Checkout Git Repository
- name: Checkout
uses: actions/checkout@v4
-
uses: actions/download-artifact@v4
name: Download Artifact Zips
with:
path: build
-
name: Preparation Folder
run: |
rsync -avz "build/$(ls build|grep "CustomSkinLoader")/" build/libs/
ls -lh build
-
if: ${{ matrix.modtype != 'All' }}
name: Checking and setting the environment
id: cslenv
run: |
output="$(ls build/libs | grep -v "sources")"
case "${{ matrix.modtype }}" in
"ForgeV1")
modloader="Forge"
path=`echo "${{ matrix.modtype }}" | sed 's#V#/V#'`
;;
"ForgeV2" | "ForgeV3")
modloader=$(cat <<EOF
Forge
NeoForge
EOF
)
path=`echo "${{ matrix.modtype }}" | sed 's#V#/V#'`
;;
"Fabric")
modloader=$(cat <<EOF
Fabric
Quilt
EOF
)
path="${{ matrix.modtype }}"
;;
*)
echo "Unsupported modtype: ${{ matrix.modtype }}"
exit 1
;;
esac
echo "path=$path" >> $GITHUB_OUTPUT
echo "modloader="$modloader"" >> $GITHUB_OUTPUT
echo "filename=$(echo "$output"|grep $(echo ${{ matrix.modtype }}|sed "s#-##") )" >> $GITHUB_OUTPUT
echo "version=$(grep "version=" build.properties | grep -v "#" | sed "s/version=//")" >> $GITHUB_OUTPUT
echo "edition=$(echo ${{ matrix.modtype }} | sed "s/-//")" >> $GITHUB_OUTPUT
echo "minecraft_vers<<EOF" >> $GITHUB_OUTPUT
grep "dependencies=" "$path"/build.properties | grep -v "#" | awk -F '|' '{print $2}' | sed 's#\;\\##' | sed "s/,/\n/g" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "java_vers<<EOF" >> $GITHUB_OUTPUT
grep "java_full_versions=" "$path"/build.properties | grep -v "#" | sed "s/java_full_versions=//" | sed "s/,/\n/g" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
-
if: startsWith(matrix.website, 'GitHub-')
name: Settings more strings to Environment
id: cslenv-github
run: |
#展开
echo "buildtime=$(TZ=Asia/Shanghai date "+%Y.%m.%d %H:%M")" >> $GITHUB_OUTPUT
echo "pathlist="$(find build/libs -type f|grep -v "sources"|grep -v "json")"" >> $GITHUB_OUTPUT
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: "[GitHub Pre-Release] Delete"
uses: 8Mi-Tech/delete-release-assets-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: CI-Build
deleteOnlyFromDrafts: false
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: 【GitHub Pre-Release】 Set CI-Build Text
run: |
cat > build/ci-build.md << 'EOF'
Build Time / 构建时间 : ${{ steps.cslenv-github.outputs.buildtime }}
自动同步分支 ${{ github.ref_name }} 的代码,以保持最新
Synchronize ${{ github.ref_name }} branch code updates, keeping only the latest version
<br>
[如何使用 / How to uses?](https://github.com/xfl03/MCCustomSkinLoader/wiki/How-to-Use)
EOF
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: "[GitHub Pre-Release] Upload Tag"
uses: richardsimko/update-tag@v1
with:
tag_name: CI-Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
if: ${{ matrix.website == 'GitHub-PreRelease' && startsWith(github.ref, 'refs/heads') }}
name: "[GitHub Pre-Release] Publish"
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: CustomSkinLoader CI-Build
tag_name: CI-Build
prerelease: true
body_path: build/ci-build.md
files: build/libs/*
#files: "${{ steps.cslenv-github.outputs.pathlist }}"
-
if: ${{ matrix.website == 'GitHub-Release' && inputs.type == 'Release' }}
uses: softprops/action-gh-release@v1
name: "[GitHub Release] Publish"
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: CustomSkinLoader ${{ github.ref }}
tag_name: ${{ github.ref }}
#generate_release_notes: true
files: ${{ steps.cslenv-github.outputs.pathlist }}
-
if: ${{ matrix.website == 'ObjectStorage' }}
name: "[ObjectStorage] Force JDK 8"
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'gradle'
-
if: ${{ matrix.website == 'ObjectStorage' }}
name: "[ObjectStorage] Publish"
distribution: liberica
java-version: "25"
cache: gradle
- name: Build
env:
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
IS_SNAPSHOT: ${{ inputs['is-snapshot'] }}
run: ./.github/scripts/build.ps1
- name: Install publish CLIs
if: ${{ inputs.publish || inputs.release }}
run: ./.github/scripts/install-publish-clis.ps1
- name: Prepare publish artifacts
id: publish-artifacts
if: ${{ inputs.publish || inputs.release }}
env:
IS_SNAPSHOT: ${{ inputs['is-snapshot'] }}
PUBLISH_CHANNEL: ${{ inputs.type }}
LATEST_JSON_NAME: ${{ inputs['latest-json'] }}
DETAIL_JSON_NAME: ${{ inputs['detail-json'] }}
R2_BASE_URL: ${{ secrets.R2_BASE_URL }}
R2_BUCKET: ${{ secrets.R2_BUCKET }}
R2_SECRET_ID: ${{ secrets.R2_SECRET_ID }}
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
IS_SNAPSHOT: ${{ inputs.is-snapshot }}
run: |
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $GITHUB_SHA)
./gradlew ${{ inputs.publish-task }} --info --stacktrace
# ./gradlew publishGprPublicationToGitHubPackagesRepository
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_REGION: ${{ secrets.COS_REGION }}
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
TENCENT_CDN_ROOT: ${{ secrets.TENCENT_CDN_ROOT }}
CLOUDFLARE_CDN_ROOT: ${{ secrets.CLOUDFLARE_CDN_ROOT }}
run: ./.github/scripts/prepare-publish-artifacts.ps1
-
if: ${{ matrix.website == 'CurseForge_Modrinth' && inputs.type == 'Release' }}
name: "[CurseForge & Modrinth] Publish"
- name: Prepare build artifacts
if: ${{ !(inputs.publish || inputs.release) }}
run: ./.github/scripts/prepare-build-artifacts.ps1
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: CustomSkinLoader-${{ inputs.type }}-${{ github.run_number }}
path: build/publish/*
- name: Write pre-release body
if: ${{ inputs.publish && inputs['prerelease-tag'] != '' }}
env:
BUILD_TYPE: ${{ inputs.type }}
run: ./.github/scripts/write-prerelease-body.ps1
- name: Delete previous pre-release assets
if: ${{ inputs.publish && inputs['prerelease-tag'] != '' }}
uses: 8Mi-Tech/delete-release-assets-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ inputs['prerelease-tag'] }}
deleteOnlyFromDrafts: false
- name: Move pre-release tag
if: ${{ inputs.publish && inputs['prerelease-tag'] != '' }}
uses: richardsimko/update-tag@v1
with:
tag_name: ${{ inputs['prerelease-tag'] }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish GitHub pre-release
if: ${{ inputs.publish && inputs['prerelease-tag'] != '' }}
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ inputs['prerelease-name'] }}
tag_name: ${{ inputs['prerelease-tag'] }}
prerelease: true
make_latest: false
body_path: build/publish/release-notes.md
overwrite_files: true
files: |
build/publish/*.jar
build/publish/*.json
- name: Publish GitHub release assets
if: ${{ inputs.release }}
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
overwrite_files: true
files: |
build/publish/*.jar
build/publish/*.json
- name: Publish to CurseForge and Modrinth
if: ${{ inputs.release }}
uses: Kir-Antipov/[email protected]
with:
modrinth-id: idMHQ4n2
@@ -220,19 +154,20 @@ jobs:
curseforge-id: 286924
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}
name: CustomSkinLoader_${{ steps.cslenv.outputs.edition }}_${{ steps.cslenv.outputs.version }}
version: ${{ steps.cslenv.outputs.version }}-${{ steps.cslenv.outputs.edition }}
name: ${{ steps.publish-artifacts.outputs.mc_publish_name }}
version: ${{ steps.publish-artifacts.outputs.mc_publish_version }}
version-type: release
loaders: ${{ steps.cslenv.outputs.modloader }}
loaders: |
${{ steps.publish-artifacts.outputs.loaders }}
game-versions: |
${{ steps.cslenv.outputs.minecraft_vers }}
${{ steps.publish-artifacts.outputs.game_versions }}
game-version-filter: releases
java: |
${{ steps.cslenv.outputs.java_vers }}
${{ steps.publish-artifacts.outputs.java_versions }}
retry-attempts: 2
retry-delay: 10000
fail-mode: fail
files: |
build/libs/${{ steps.cslenv.outputs.filename }}
build/publish/*.jar
+5 -4
View File
@@ -1,17 +1,18 @@
name: Pull Request
on:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- '14-develop'
- '15-develop'
jobs:
build-pull-request:
name: Build Pull Request
uses: ./.github/workflows/common.yml
with:
type: PullRequest
type: PullRequest
publish: false
release: false
is-snapshot: true
+5 -2
View File
@@ -1,4 +1,5 @@
name: Release
on:
release:
types: [released]
@@ -9,6 +10,8 @@ jobs:
uses: ./.github/workflows/common.yml
with:
type: Release
publish-task: upload
release: true
latest-json: latest.json
detail-json: detail.json
is-snapshot: false
secrets: inherit
secrets: inherit