Skip to content

Commit 055cd71

Browse files
committed
Move actions/checkout from composite actions to workflow level
1 parent 0212d4d commit 055cd71

6 files changed

Lines changed: 39 additions & 51 deletions

File tree

.github/actions/build/action.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Composite action: checkout, setup JDK, build with Gradle, upload artifact
1+
# Composite action: setup JDK, build with Gradle, upload artifact
22
name: Build
33
description: Build project with Gradle and upload artifact
44

@@ -14,9 +14,7 @@ inputs:
1414
runs:
1515
using: composite
1616
steps:
17-
- uses: actions/checkout@v4
18-
19-
- uses: actions/setup-java@v4
17+
- uses: actions/setup-java@v5
2018
with:
2119
distribution: temurin
2220
java-version: '25'
@@ -28,7 +26,7 @@ runs:
2826
IS_SNAPSHOT: ${{ inputs.is-snapshot }}
2927
run: ./gradlew clean build --info --stacktrace
3028

31-
- uses: actions/upload-artifact@v4
29+
- uses: actions/upload-artifact@v7
3230
with:
3331
name: ${{ inputs.artifact-name }}
3432
path: Bootstrap/build/libs/

.github/actions/publish/action.yml

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,18 @@ inputs:
1313
runs:
1414
using: composite
1515
steps:
16-
- uses: actions/checkout@v4
17-
with:
18-
clean: false # preserve artifact files already downloaded before this action
19-
20-
# Upload jars to R2 (S3-compatible, mods/ prefix)
21-
- uses: michaelliao/sync-s3-compatible-action@v1
22-
with:
23-
SYNC_DIR: ${{ inputs.artifact-dir }}
24-
BUCKET_URL: ${{ env.R2_BASE_URL }}
25-
BUCKET_NAME: ${{ env.R2_BUCKET }}
26-
AWS_ACCESS_KEY_ID: ${{ env.R2_SECRET_ID }}
27-
AWS_SECRET_ACCESS_KEY: ${{ env.R2_SECRET_KEY }}
28-
TARGET_PATH: mods/
29-
30-
# Upload jars to COS (qcloud mode, mods/ prefix)
31-
- uses: michaelliao/sync-s3-compatible-action@v1
32-
with:
33-
SYNC_TYPE: qcloud
34-
SYNC_DIR: ${{ inputs.artifact-dir }}
35-
BUCKET_NAME: ${{ env.COS_BUCKET }}
36-
AWS_ACCESS_KEY_ID: ${{ env.COS_SECRET_ID }}
37-
AWS_SECRET_ACCESS_KEY: ${{ env.COS_SECRET_KEY }}
38-
BUCKET_REGION: ap-shanghai
39-
TARGET_PATH: mods/
40-
4116
# Generate JSON metadata, upload to R2/COS root, and output CDN URLs
4217
- name: Generate and upload JSON metadata
43-
id: publish-json
18+
id: publish-files
4419
shell: pwsh
45-
run: .github/scripts/Publish-Json.ps1 -ArtifactDir '${{ inputs.artifact-dir }}' -Type '${{ inputs.type }}'
20+
run: ./.github/scripts/Publish-Files.ps1 -ArtifactDir '${{ inputs.artifact-dir }}' -Type '${{ inputs.type }}'
4621

4722
# Refresh Tencent Cloud CDN cache for the JSON files
4823
- name: Refresh CDN
49-
uses: tencentcloud/cdn-refresh-action@v1
24+
uses: linrongda/tencent-cdn-action@v2
5025
with:
51-
urls: ${{ steps.publish-json.outputs.cdn-urls }}
5226
secret-id: ${{ env.COS_SECRET_ID }}
5327
secret-key: ${{ env.COS_SECRET_KEY }}
28+
action: purgeUrls
29+
paths: ${{ steps.publish-files.outputs.cdn-urls }}
5430
continue-on-error: true
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ param(
55

66
$ErrorActionPreference = "Stop"
77

8-
# ---- Validate required env vars ----
9-
foreach ($var in @('R2_SECRET_ID', 'R2_SECRET_KEY', 'R2_BUCKET', 'R2_BASE_URL')) {
10-
if (-not $env:$var) { throw "Missing required env: $var" }
11-
}
12-
138
$suffix = if ($Type -eq "beta") { "-beta" } else { "" }
149

1510
# ---- Find the built jar ----
@@ -34,48 +29,57 @@ if ($isSnapshot) {
3429
$mcVersions = ((Get-Content "gradle.properties" | Select-String "^minecraft_major_versions=") -replace "^.*=", "").Trim()
3530
$mcVersionList = $mcVersions -split "," | ForEach-Object { $_.Trim() }
3631

37-
$baseUrl = $env:R2_BASE_URL.TrimEnd('/')
32+
$baseUrl = "_BASE_URL_"
3833

3934
# ---- Generate latest(-beta).json ----
4035
$latestJson = @{
4136
version = $shortVersion
4237
downloads = @{ Universal = "$baseUrl/$jarKey" }
4338
launchermeta = @{}
4439
} | ConvertTo-Json -Depth 10
45-
Set-Content -Path "$ArtifactDir/latest$suffix.json" -Value $latestJson -NoNewline
4640

4741
# ---- Generate detail(-beta).json ----
4842
$details = [ordered]@{}
4943
foreach ($mcVer in $mcVersionList) {
50-
$details[$mcVer] = @{ Universal = "$baseUrl/$jarKey" }
44+
$details[$mcVer] = @{
45+
Fabric = "$baseUrl/$jarKey"
46+
Forge = "$baseUrl/$jarKey"
47+
NeoForge = "$baseUrl/$jarKey"
48+
Quilt = "$baseUrl/$jarKey"
49+
}
5150
}
5251
$detailJson = @{
5352
version = $shortVersion
5453
timestamp = [System.DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
5554
details = $details
5655
} | ConvertTo-Json -Depth 10
57-
Set-Content -Path "$ArtifactDir/detail$suffix.json" -Value $detailJson -NoNewline
5856

59-
# ---- Upload JSON files to R2 ----
57+
# ---- Upload files to R2 ----
6058
$env:AWS_ACCESS_KEY_ID = $env:R2_SECRET_ID
6159
$env:AWS_SECRET_ACCESS_KEY = $env:R2_SECRET_KEY
6260
$env:AWS_DEFAULT_REGION = "auto"
6361

62+
aws s3 cp "$ArtifactDir/$jarFilename" "s3://$env:R2_BUCKET/$jarKey" --endpoint-url $($env:R2_BASE_URL.TrimEnd('/'))
63+
$latestJson -replace $baseUrl, "https://csl.3-3.dev" | Set-Content -Path "$ArtifactDir/latest$suffix.json" -NoNewline
64+
$detailJson -replace $baseUrl, "https://csl.3-3.dev" | Set-Content -Path "$ArtifactDir/detail$suffix.json" -NoNewline
6465
aws s3 cp "$ArtifactDir/latest$suffix.json" "s3://$env:R2_BUCKET/latest$suffix.json" --endpoint-url $($env:R2_BASE_URL.TrimEnd('/'))
6566
aws s3 cp "$ArtifactDir/detail$suffix.json" "s3://$env:R2_BUCKET/detail$suffix.json" --endpoint-url $($env:R2_BASE_URL.TrimEnd('/'))
6667

67-
# ---- Upload JSON files to COS ----
68+
# ---- Upload files to COS ----
69+
$cdnBase = "https://csl.littleservice.cn"
6870
try {
6971
pip install coscmd -q --disable-pip-version-check
7072
coscmd config -a $env:COS_SECRET_ID -s $env:COS_SECRET_KEY -b $env:COS_BUCKET -r ap-shanghai
73+
coscmd upload "$ArtifactDir/$jarFilename" "$jarKey"
74+
$latestJson -replace $baseUrl, $cdnBase | Set-Content -Path "$ArtifactDir/latest$suffix.json" -NoNewline
75+
$detailJson -replace $baseUrl, $cdnBase | Set-Content -Path "$ArtifactDir/detail$suffix.json" -NoNewline
7176
coscmd upload "$ArtifactDir/latest$suffix.json" "latest$suffix.json"
7277
coscmd upload "$ArtifactDir/detail$suffix.json" "detail$suffix.json"
7378
} catch {
7479
Write-Warning "COS JSON upload failed: $_"
7580
}
7681

7782
# ---- Output CDN URLs for subsequent refresh step ----
78-
$cdnBase = "https://csl.littleservice.cn"
7983
"cdn-urls<<EOF" | Out-File $env:GITHUB_OUTPUT -Append
8084
"${cdnBase}/latest${suffix}.json" | Out-File $env:GITHUB_OUTPUT -Append
8185
"${cdnBase}/detail${suffix}.json" | Out-File $env:GITHUB_OUTPUT -Append

.github/workflows/beta.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
name: Build
1212
runs-on: windows-latest
1313
steps:
14+
- uses: actions/checkout@v6
15+
1416
- uses: ./.github/actions/build
1517
with:
1618
artifact-name: CustomSkinLoader-Beta-${{ github.run_number }}
@@ -30,7 +32,9 @@ jobs:
3032
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
3133
COS_BUCKET: ${{ secrets.COS_BUCKET }}
3234
steps:
33-
- uses: actions/download-artifact@v4
35+
- uses: actions/checkout@v6
36+
37+
- uses: actions/download-artifact@v8
3438
with:
3539
name: CustomSkinLoader-Beta-${{ github.run_number }}
3640
path: artifact
@@ -58,7 +62,7 @@ jobs:
5862
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5963

6064
- name: GitHub PreRelease
61-
uses: softprops/action-gh-release@v2
65+
uses: softprops/action-gh-release@v3
6266
with:
6367
tag_name: CI-Build
6468
name: CustomSkinLoader CI-Build

.github/workflows/pull-request.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ jobs:
99
name: Build
1010
runs-on: windows-latest
1111
steps:
12+
- uses: actions/checkout@v6
13+
1214
- uses: ./.github/actions/build
1315
with:
1416
artifact-name: CustomSkinLoader-PR-${{ github.run_number }}

.github/workflows/release.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
name: Build
1212
runs-on: windows-latest
1313
steps:
14+
- uses: actions/checkout@v6
15+
1416
- uses: ./.github/actions/build
1517
with:
1618
is-snapshot: 'false'
@@ -31,7 +33,9 @@ jobs:
3133
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
3234
COS_BUCKET: ${{ secrets.COS_BUCKET }}
3335
steps:
34-
- uses: actions/download-artifact@v4
36+
- uses: actions/checkout@v6
37+
38+
- uses: actions/download-artifact@v8
3539
with:
3640
name: CustomSkinLoader-Release-${{ github.run_number }}
3741
path: artifact
@@ -44,7 +48,7 @@ jobs:
4448
- name: Get publish info from gradle.properties
4549
id: info
4650
shell: pwsh
47-
run: .github/scripts/Get-PublishInfo.ps1
51+
run: ./.github/scripts/Get-PublishInfo.ps1
4852

4953
- uses: Kir-Antipov/mc-publish@v3.3
5054
with:
@@ -71,7 +75,7 @@ jobs:
7175
artifact/*.jar
7276
7377
- name: GitHub Release
74-
uses: softprops/action-gh-release@v2
78+
uses: softprops/action-gh-release@v3
7579
with:
7680
files: artifact/*.jar
7781
env:

0 commit comments

Comments
 (0)