@@ -2,109 +2,121 @@ name: Bundle From Latest Releases
22
33on :
44 workflow_dispatch :
5+ schedule :
6+ - cron : " 0 3 * * *"
57
68permissions :
79 contents : write
810
911jobs :
1012 bundle-latest-releases :
11- runs-on : windows -latest
13+ runs-on : ubuntu -latest
1214
1315 steps :
1416 - name : Checkout Repo
1517 uses : actions/checkout@v4
1618
17- - name : Create Directory Structure
19+ - name : Resolve Latest Release Tags
20+ env :
21+ GH_TOKEN : ${{ secrets.GH_PAT }}
1822 run : |
19- New-Item -ItemType Directory -Force -Path "Build\Admin\Mods"
20- New-Item -ItemType Directory -Force -Path "tmp"
23+ set -euo pipefail
2124
22- - name : Download Latest Releases
25+ veTag=$(gh release view -R BF3RM/VEManager --json tagName -q ".tagName")
26+ bpTag=$(gh release view -R BF3RM/BlueprintManager --json tagName -q ".tagName")
27+ rmTag=$(gh release view -R BF3RM/RealityMod --json tagName -q ".tagName")
28+ llTag=$(gh release view -R BF3RM/RMLevelLoaderGen --json tagName -q ".tagName")
29+
30+ combo="$veTag|$bpTag|$rmTag|$llTag"
31+ sha=$(printf "%s" "$combo" | sha256sum | cut -d" " -f1)
32+ tag="latest-release-bundle-${sha:0:12}"
33+
34+ echo "UPSTREAM_VE_TAG=$veTag" >> "$GITHUB_ENV"
35+ echo "UPSTREAM_BP_TAG=$bpTag" >> "$GITHUB_ENV"
36+ echo "UPSTREAM_RM_TAG=$rmTag" >> "$GITHUB_ENV"
37+ echo "UPSTREAM_LL_TAG=$llTag" >> "$GITHUB_ENV"
38+ echo "RELEASE_TAG=$tag" >> "$GITHUB_ENV"
39+
40+ - name : Skip If Bundle Already Exists
2341 env :
2442 GH_TOKEN : ${{ secrets.GH_PAT }}
2543 run : |
26- $ErrorActionPreference = "Stop"
44+ set -euo pipefail
45+ if gh release view "$RELEASE_TAG" -R ${{ github.repository }} >/dev/null 2>&1; then
46+ echo "Release $RELEASE_TAG already exists. Skipping."
47+ exit 0
48+ fi
2749
28- # VEManager (Source Code zip)
29- New-Item -ItemType Directory -Force -Path "tmp\VEManager"
30- gh release download -R BF3RM/VEManager --archive=zip -D "tmp\VEManager"
50+ - name : Create Directory Structure
51+ run : |
52+ set -euo pipefail
53+ mkdir -p Build/Admin/Mods tmp
3154
32- # BlueprintManager (Source Code zip)
33- New-Item -ItemType Directory -Force -Path "tmp\BlueprintManager"
34- gh release download -R BF3RM/BlueprintManager --archive=zip -D "tmp\BlueprintManager"
55+ - name : Download Latest Releases
56+ env :
57+ GH_TOKEN : ${{ secrets.GH_PAT }}
58+ run : |
59+ set -euo pipefail
3560
36- # RealityMod (release.zip)
37- New-Item -ItemType Directory -Force -Path "tmp\RealityMod"
38- gh release download -R BF3RM/RealityMod -p "release.zip" -D "tmp\RealityMod"
61+ mkdir -p tmp/VEManager tmp/BlueprintManager tmp/RealityMod tmp/RMLevelLoader
3962
40- # RMLevelLoader (rm-levelloader.zip)
41- New-Item -ItemType Directory -Force -Path "tmp\RMLevelLoader"
42- gh release download -R BF3RM/RMLevelLoaderGen -p "rm-levelloader.zip" -D "tmp\RMLevelLoader"
63+ gh release download -R BF3RM/VEManager --archive=zip -D tmp/VEManager
64+ gh release download -R BF3RM/BlueprintManager --archive=zip -D tmp/BlueprintManager
65+ gh release download -R BF3RM/RealityMod -p "release.zip" -D tmp/RealityMod
66+ gh release download -R BF3RM/RMLevelLoaderGen -p "rm-levelloader.zip" -D tmp/RMLevelLoader
4367
4468 - name : Extract And Assemble
4569 run : |
46- $ErrorActionPreference = "Stop"
47-
48- function Expand-ZipToFolder {
49- param(
50- [string]$ZipPath,
51- [string]$Destination
52- )
70+ set -euo pipefail
71+
72+ expand_zip_flatten() {
73+ local zip_path="$1"
74+ local dest="$2"
75+
76+ rm -rf "$dest"
77+ mkdir -p "$dest"
78+ unzip -q "$zip_path" -d "$dest"
79+
80+ local count
81+ count=$(find "$dest" -mindepth 1 -maxdepth 1 | wc -l | tr -d ' ')
82+ if [ "$count" -eq 1 ] && [ -d "$(find "$dest" -mindepth 1 -maxdepth 1)" ]; then
83+ local inner
84+ inner=$(find "$dest" -mindepth 1 -maxdepth 1 -type d)
85+ shopt -s dotglob
86+ mv "$inner"/* "$dest"/
87+ shopt -u dotglob
88+ rm -rf "$inner"
89+ fi
90+ }
5391
54- $temp = Join-Path (Split-Path $ZipPath -Parent) ([IO.Path]::GetFileNameWithoutExtension($ZipPath) + "_unzipped")
55- Expand-Archive -Path $ZipPath -DestinationPath $temp -Force
92+ veZip=$(ls tmp/VEManager/*.zip 2>/dev/null | head -n 1)
93+ [ -n "$veZip" ] || { echo "VEManager source zip not found"; exit 1; }
94+ expand_zip_flatten "$veZip" "Build/Admin/Mods/VEManager"
5695
57- $root = Get-ChildItem -Path $temp | Select-Object -First 1
58- if ($null -ne $root -and $root.PSIsContainer) {
59- Copy-Item -Path (Join-Path $root.FullName "*") -Destination $Destination -Recurse -Force
60- } else {
61- Copy-Item -Path (Join-Path $temp "*") -Destination $Destination -Recurse -Force
62- }
96+ bpZip=$(ls tmp/BlueprintManager/*.zip 2>/dev/null | head -n 1)
97+ [ -n "$bpZip" ] || { echo "BlueprintManager source zip not found"; exit 1; }
98+ expand_zip_flatten "$bpZip" "Build/Admin/Mods/BlueprintManager"
6399
64- Remove-Item $temp -Recurse -Force
65- }
100+ rmZip="tmp/RealityMod/release.zip"
101+ [ -f "$rmZip" ] || { echo "RealityMod release.zip not found"; exit 1; }
102+ expand_zip_flatten "$rmZip" "Build/Admin/Mods/RealityMod"
66103
67- # VEManager
68- $veZip = Get-ChildItem -Path "tmp\VEManager" -Filter "*.zip" | Select-Object -First 1
69- if (-not $veZip) { Write-Error "VEManager source zip not found"; exit 1 }
70- New-Item -ItemType Directory -Force -Path "Build\Admin\Mods\VEManager"
71- Expand-ZipToFolder -ZipPath $veZip.FullName -Destination "Build\Admin\Mods\VEManager"
72-
73- # BlueprintManager
74- $bpZip = Get-ChildItem -Path "tmp\BlueprintManager" -Filter "*.zip" | Select-Object -First 1
75- if (-not $bpZip) { Write-Error "BlueprintManager source zip not found"; exit 1 }
76- New-Item -ItemType Directory -Force -Path "Build\Admin\Mods\BlueprintManager"
77- Expand-ZipToFolder -ZipPath $bpZip.FullName -Destination "Build\Admin\Mods\BlueprintManager"
78-
79- # RealityMod (release.zip)
80- $rmZip = Get-ChildItem -Path "tmp\RealityMod" -Filter "release.zip" | Select-Object -First 1
81- if (-not $rmZip) { Write-Error "RealityMod release.zip not found"; exit 1 }
82- New-Item -ItemType Directory -Force -Path "Build\Admin\Mods\RealityMod"
83- Expand-ZipToFolder -ZipPath $rmZip.FullName -Destination "Build\Admin\Mods\RealityMod"
84-
85- # RMLevelLoader (rm-levelloader.zip)
86- $llZip = Get-ChildItem -Path "tmp\RMLevelLoader" -Filter "rm-levelloader.zip" | Select-Object -First 1
87- if (-not $llZip) { Write-Error "rm-levelloader.zip not found"; exit 1 }
88- New-Item -ItemType Directory -Force -Path "Build\Admin\Mods\rm-levelloader"
89- Expand-ZipToFolder -ZipPath $llZip.FullName -Destination "Build\Admin\Mods\rm-levelloader"
104+ llZip="tmp/RMLevelLoader/rm-levelloader.zip"
105+ [ -f "$llZip" ] || { echo "rm-levelloader.zip not found"; exit 1; }
106+ expand_zip_flatten "$llZip" "Build/Admin/Mods/rm-levelloader"
90107
91108 - name : Create Zip Packages
92109 run : |
93- $ErrorActionPreference = "Stop"
110+ set -euo pipefail
94111
95112 pushd Build
96- Compress-Archive -Path * -DestinationPath ..\ Reality-Server-Full.zip -Force
113+ zip -r ../ Reality-Server-Full.zip .
97114 popd
98115
99- pushd Build\ Admin\ Mods
100- Compress-Archive -Path * -DestinationPath ..\..\..\ Reality-Mods-Only.zip -Force
116+ pushd Build/ Admin/ Mods
117+ zip -r ../../../ Reality-Mods-Only.zip .
101118 popd
102119
103- - name : Set Release Tag
104- run : |
105- $tag = "latest-release-bundle-" + (Get-Date -Format "yyyyMMdd-HHmm")
106- echo "RELEASE_TAG=$tag" >> $env:GITHUB_ENV
107-
108120 - name : Create Release
109121 uses : softprops/action-gh-release@v1
110122 with :
@@ -115,3 +127,39 @@ jobs:
115127 Reality-Mods-Only.zip
116128 body : |
117129 Automated bundle from latest upstream releases.
130+
131+ Upstream tags:
132+ - VEManager: ${{ env.UPSTREAM_VE_TAG }}
133+ - BlueprintManager: ${{ env.UPSTREAM_BP_TAG }}
134+ - RealityMod: ${{ env.UPSTREAM_RM_TAG }}
135+ - RMLevelLoader: ${{ env.UPSTREAM_LL_TAG }}
136+
137+ - name : Publish 'release' Tag
138+ env :
139+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
140+ run : |
141+ set -euo pipefail
142+
143+ cat > release_notes.md <<'EOF'
144+ Automated bundle from latest upstream releases.
145+
146+ Upstream tags:
147+ - VEManager: ${UPSTREAM_VE_TAG}
148+ - BlueprintManager: ${UPSTREAM_BP_TAG}
149+ - RealityMod: ${UPSTREAM_RM_TAG}
150+ - RMLevelLoader: ${UPSTREAM_LL_TAG}
151+ EOF
152+
153+ envsubst < release_notes.md > release_notes_rendered.md
154+
155+ gh release delete release --yes || echo "No previous release found"
156+
157+ git config user.name "GitHub Actions"
158+ git config user.email "actions@github.com"
159+ git tag -f release
160+ git push -f origin release
161+
162+ gh release create release \
163+ --title "Release Bundle (${RELEASE_TAG})" \
164+ --notes-file release_notes_rendered.md \
165+ Reality-Server-Full.zip Reality-Mods-Only.zip
0 commit comments