diff --git a/.github/actions/publish/action.yml b/.github/actions/publish/action.yml new file mode 100644 index 0000000..d923918 --- /dev/null +++ b/.github/actions/publish/action.yml @@ -0,0 +1,54 @@ +# Composite action: upload jars to R2/COS, generate and upload JSON metadata +name: Publish +description: Upload built artifacts to object storage and publish JSON metadata + +inputs: + artifact-dir: + description: Directory containing built artifacts (relative to workspace) + required: true + type: + description: Release type - 'beta' or 'release' + required: true + +runs: + using: composite + steps: + - uses: actions/checkout@v4 + with: + clean: false # preserve artifact files already downloaded before this action + + # Upload jars to R2 (S3-compatible, mods/ prefix) + - uses: michaelliao/sync-s3-compatible-action@v1 + with: + SYNC_DIR: ${{ inputs.artifact-dir }} + BUCKET_URL: ${{ env.R2_BASE_URL }} + BUCKET_NAME: ${{ env.R2_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ env.R2_SECRET_ID }} + AWS_SECRET_ACCESS_KEY: ${{ env.R2_SECRET_KEY }} + TARGET_PATH: mods/ + + # Upload jars to COS (qcloud mode, mods/ prefix) + - uses: michaelliao/sync-s3-compatible-action@v1 + with: + SYNC_TYPE: qcloud + SYNC_DIR: ${{ inputs.artifact-dir }} + BUCKET_NAME: ${{ env.COS_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ env.COS_SECRET_ID }} + AWS_SECRET_ACCESS_KEY: ${{ env.COS_SECRET_KEY }} + BUCKET_REGION: ap-shanghai + TARGET_PATH: mods/ + + # Generate JSON metadata, upload to R2/COS root, and output CDN URLs + - name: Generate and upload JSON metadata + id: publish-json + shell: pwsh + run: .github/scripts/Publish-Json.ps1 -ArtifactDir '${{ inputs.artifact-dir }}' -Type '${{ inputs.type }}' + + # Refresh Tencent Cloud CDN cache for the JSON files + - name: Refresh CDN + uses: tencentcloud/cdn-refresh-action@v1 + with: + urls: ${{ steps.publish-json.outputs.cdn-urls }} + secret-id: ${{ env.COS_SECRET_ID }} + secret-key: ${{ env.COS_SECRET_KEY }} + continue-on-error: true diff --git a/.github/scripts/Get-PublishInfo.ps1 b/.github/scripts/Get-PublishInfo.ps1 new file mode 100644 index 0000000..a798dae --- /dev/null +++ b/.github/scripts/Get-PublishInfo.ps1 @@ -0,0 +1,29 @@ +param() + +$ErrorActionPreference = "Stop" + +$props = Get-Content "gradle.properties" + +function Get-Prop($key) { + ($props | Select-String "^$key=") -replace "^.*=", "" | ForEach-Object { $_.Trim() } +} + +function Set-MultilineOutput($name, $value) { + "$name< 15.0-s33 +# mod_version=15.0, IS_SNAPSHOT=false -> 15.0 +$version = ((Get-Content "gradle.properties" | Select-String "^mod_version=") -replace "^mod_version=", "").Trim() +$isSnapshot = if ($env:IS_SNAPSHOT) { $env:IS_SNAPSHOT -ne "false" } else { $true } +if ($isSnapshot) { + $shortVersion = "$version-s$env:GITHUB_RUN_NUMBER" +} else { + $shortVersion = "$version" +} + +# ---- Read MC major versions from gradle.properties ---- +$mcVersions = ((Get-Content "gradle.properties" | Select-String "^minecraft_major_versions=") -replace "^.*=", "").Trim() +$mcVersionList = $mcVersions -split "," | ForEach-Object { $_.Trim() } + +$baseUrl = $env:R2_BASE_URL.TrimEnd('/') + +# ---- Generate latest(-beta).json ---- +$latestJson = @{ + version = $shortVersion + downloads = @{ Universal = "$baseUrl/$jarKey" } + launchermeta = @{} +} | ConvertTo-Json -Depth 10 +Set-Content -Path "$ArtifactDir/latest$suffix.json" -Value $latestJson -NoNewline + +# ---- Generate detail(-beta).json ---- +$details = [ordered]@{} +foreach ($mcVer in $mcVersionList) { + $details[$mcVer] = @{ Universal = "$baseUrl/$jarKey" } +} +$detailJson = @{ + version = $shortVersion + timestamp = [System.DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() + details = $details +} | ConvertTo-Json -Depth 10 +Set-Content -Path "$ArtifactDir/detail$suffix.json" -Value $detailJson -NoNewline + +# ---- Upload JSON files to R2 ---- +$env:AWS_ACCESS_KEY_ID = $env:R2_SECRET_ID +$env:AWS_SECRET_ACCESS_KEY = $env:R2_SECRET_KEY +$env:AWS_DEFAULT_REGION = "auto" + +aws s3 cp "$ArtifactDir/latest$suffix.json" "s3://$env:R2_BUCKET/latest$suffix.json" --endpoint-url $($env:R2_BASE_URL.TrimEnd('/')) +aws s3 cp "$ArtifactDir/detail$suffix.json" "s3://$env:R2_BUCKET/detail$suffix.json" --endpoint-url $($env:R2_BASE_URL.TrimEnd('/')) + +# ---- Upload JSON files to COS ---- +try { + pip install coscmd -q --disable-pip-version-check + coscmd config -a $env:COS_SECRET_ID -s $env:COS_SECRET_KEY -b $env:COS_BUCKET -r ap-shanghai + coscmd upload "$ArtifactDir/latest$suffix.json" "latest$suffix.json" + coscmd upload "$ArtifactDir/detail$suffix.json" "detail$suffix.json" +} catch { + Write-Warning "COS JSON upload failed: $_" +} + +# ---- Output CDN URLs for subsequent refresh step ---- +$cdnBase = "https://csl.littleservice.cn" +"cdn-urls< - def propertyValue = buildProperties.getProperty(propertyName)?.trim() + def propertyValue = rootProject.findProperty(propertyName)?.toString()?.trim() if (!propertyValue) { - throw new GradleException("Missing ${propertyName} in ${buildPropertiesFile}") + throw new GradleException("Missing ${propertyName} in gradle.properties") } propertyValue } @@ -26,9 +17,9 @@ def isTruthy = { String value -> value.trim().toLowerCase(Locale.ROOT) == 'true' } -def releaseName = requireBuildProperty('name') -def releaseGroup = requireBuildProperty('group') -def releaseVersion = requireBuildProperty('version') +def releaseName = requireBuildProperty('mod_name') +def releaseGroup = requireBuildProperty('mod_group') +def releaseVersion = requireBuildProperty('mod_version') def releaseBuildNumber = System.getenv('GITHUB_RUN_NUMBER')?.trim() ?: '0' def releaseIsSnapshot = isTruthy(System.getenv('IS_SNAPSHOT')) def releaseFullVersion = (releaseIsSnapshot ? "${releaseVersion}-SNAPSHOT-${releaseBuildNumber}" : releaseVersion).toString() @@ -71,7 +62,7 @@ subprojects { manifestLibraries { // Share Bootstrap's dependency set with all packaged child modules. - add 'https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.minecraft/26.1.2.json' + add "https://raw.githubusercontent.com/PrismLauncher/meta-launcher/refs/heads/master/net.minecraft/${minecraft_version}.json" } repositories { diff --git a/build.properties b/gradle.properties similarity index 63% rename from build.properties rename to gradle.properties index 562521e..634c145 100644 --- a/build.properties +++ b/gradle.properties @@ -1,9 +1,16 @@ -name=CustomSkinLoader -group=customskinloader -version=15.0 +mod_name=CustomSkinLoader +mod_group=customskinloader +mod_version=15.0 edition=Universal minecraft_major_versions=1.8,1.9,1.10,1.11,1.12,1.13,1.14,1.15,1.16,1.17,1.18,1.19,1.20,1.21,26.1 +minecraft_version=26.1.2 +fabric_v1_version=0.19.2 +forge_v1_version=14.23.5.2864 +forge_v2_version=36.2.42 +neoforge_v1_version=20.6.13-beta +neoforge_v2_version=26.1.2.59-beta + loaders=fabric,forge,neoforge,quilt -game-versions=1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2,1.13.2,1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8,1.21.9,1.21.10,1.21.11,26.1,26.1.1,26.1.2 +game_versions=1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2,1.13.2,1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8,1.21.9,1.21.10,1.21.11,26.1,26.1.1,26.1.2 java=8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,25 diff --git a/settings.gradle b/settings.gradle index 61481fe..3d3ceaf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -rootProject.name = 'CustomSkinLoader-Universal' +rootProject.name = 'MCCustomSkinLoader' include( 'Bootstrap',