Skip to content

Commit 711a34e

Browse files
committed
Fix CICD
1 parent 1361a85 commit 711a34e

File tree

2 files changed

+209
-223
lines changed

2 files changed

+209
-223
lines changed

.github/workflows/preview.yml

Lines changed: 107 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
name: Deploy preview modpack
1+
name: Deploy Preview Modpack
22

33
permissions:
4-
contents: write
4+
contents: read
55
deployments: write
66

77
on:
88
workflow_dispatch:
99
inputs:
10+
target_branch:
11+
description: 'Target branch for the preview'
12+
type: string
13+
required: true
1014
version:
1115
description: 'Modpack version'
1216
required: true
@@ -15,137 +19,139 @@ on:
1519
required: true
1620

1721
env:
22+
NAME: "GTExpert2"
1823
VERSION_NORMAL: "v${{ github.event.inputs.version }}-pr-${{ github.event.inputs.preview_version }}"
1924
VERSION_LWJGL3: "v${{ github.event.inputs.version }}-lwjgl3-${{ github.event.inputs.preview_version }}"
20-
NAME: "GTExpert2"
2125

2226
jobs:
23-
deploy:
27+
build:
2428
runs-on: ubuntu-latest
2529
strategy:
2630
matrix:
27-
version: [ "NORMAL", "LWJGL3" ]
31+
buildType: [standard, lwjgl3]
2832

2933
steps:
30-
- name: Checkout
34+
- name: Checkout repository
3135
uses: actions/checkout@v4
36+
with:
37+
ref: ${{ github.event.inputs.target_branch || github.ref }}
38+
fetch-depth: 0
3239

33-
- name: Setup Build
34-
uses: ./.github/actions/build_setup
40+
- name: Cache dependencies
41+
uses: actions/cache@v3
42+
with:
43+
path: |
44+
~/.m2/repository
45+
~/.cache/pip
46+
key: ${{ runner.os }}-deps-${{ matrix.buildType }}-${{ hashFiles('**/pom.xml') }}
3547

36-
- name: Download Resource Packs zip
37-
run: |
38-
GITHUB_RELEASE=$(curl -s https://api.github.com/repos/GTModpackTeam/GTE2-Translations/releases)
39-
ASSET_URL=$(echo $GITHUB_RELEASE | jq -r '.[]."assets"[]."browser_download_url"' | grep "resourcepack" | head -1)
40-
ASSET_NAME=$(echo $ASSET_URL | awk -F'/' '{print $NF}')
41-
wget -O ./overrides/resourcepacks/$ASSET_NAME $ASSET_URL
48+
- name: Download Resource Pack
49+
uses: actions/download-release@v4
50+
with:
51+
repository: GTModpackTeam/GTE2-Translations
52+
tag: latest
53+
asset: 'resourcepack*.zip'
54+
token: ${{ github.token }}
55+
path: overrides/resourcepacks
4256

43-
- if: matrix.version == 'LWJGL3'
44-
name: Set the version (LWJGL3)
45-
run: |
46-
echo "[CleanroomMMC] GregTech Expert 2 ${{ env.VERSION_LWJGL3 }}" > ./overrides/config/txloader/load/custommainmenu/version.txt
47-
sed -i -e "s/MODPACKVERSION/${{ env.VERSION_LWJGL3 }}/g" ./manifest.json
48-
sed -i -e "s/MODPACKVERSION/${{ env.VERSION_LWJGL3 }}/g" ./instance.cfg
49-
sed -i -e "s/MODPACKVERSION/${{ env.VERSION_LWJGL3 }}/g" ./overrides/config/craftpresence.json
57+
- name: Setup Build Environment
58+
uses: ./.github/actions/build_setup
5059

51-
- if: matrix.version == 'NORMAL'
52-
name: Set the version (NORMAL)
53-
run: |
54-
echo "GregTech Expert 2 ${{ env.VERSION_NORMAL }}" > ./overrides/config/txloader/load/custommainmenu/version.txt
55-
sed -i -e "s/MODPACKVERSION/${{ env.VERSION_NORMAL }}/g" ./manifest.json
56-
sed -i -e "s/MODPACKVERSION/${{ env.VERSION_NORMAL }}/g" ./instance.cfg
57-
sed -i -e "s/MODPACKVERSION/${{ env.VERSION_NORMAL }}/g" ./overrides/config/craftpresence.json
60+
- name: Create artifacts directory
61+
run: mkdir -p artifacts
5862

59-
- if: matrix.version == 'LWJGL3'
60-
name: Remove lwjgl3 not supported mods
63+
- name: Set modpack version
64+
run: |
65+
if [[ "${{ matrix.buildType }}" == "lwjgl3" ]]; then
66+
VER="${{ env.VERSION_LWJGL3 }}"
67+
else
68+
VER="${{ env.VERSION_NORMAL }}"
69+
fi
70+
echo "[CleanroomMMC] GregTech Expert 2 $VER" > overrides/config/txloader/load/custommainmenu/version.txt
71+
sed -i "s/MODPACKVERSION/$VER/g" manifest.json instance.cfg overrides/config/craftpresence.json
72+
73+
- name: Adjust for LWJGL3
74+
if: matrix.buildType == 'lwjgl3'
6175
run: |
6276
python buildtools/gen-lwjgl3-manifest.py
63-
cp -vf ./cmmc/manifest.json ./manifest.json
77+
cp -vf cmmc/manifest.json manifest.json
6478
65-
- name: Run Python
79+
- name: Install Mods
6680
env:
6781
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
6882
run: python buildtools/mod-install.py
6983

70-
- name: Remaove .gitkeep files
71-
run: find . -name ".gitkeep" -type f -delete
84+
- name: Clean up placeholder files
85+
run: find . -name ".gitkeep" -delete
7286

73-
- if: matrix.version == 'NORMAL'
74-
name: Archive Release CF (NORMAL)
75-
run: zip -r ./${{ env.NAME }}-${{ env.VERSION_NORMAL }}-cf.zip ./manifest.json ./modlist.html ./overrides/bansoukou/ ./overrides/config/ ./overrides/local/ ./overrides/resourcepacks/ ./overrides/scripts/
76-
77-
- if: matrix.version == 'LWJGL3'
78-
name: Archive Release MMC (LWJGL3)
79-
run: |
80-
sed -i -e "s/B:EnableCustomGameTitle=false/B:EnableCustomGameTitle=true/g" ./overrides/config/stellar_core.cfg
81-
cp -rvf ./cmmc/bansoukou/ ./overrides/
82-
rm -Rf ./cmmc/bansoukou/
83-
mv -vf ./overrides/ .minecraft/
84-
cp -vf ./icon.png .minecraft/
85-
cp -rvf ./cmmc/* ./
86-
zip -r ./${{ env.NAME }}-${{ env.VERSION_LWJGL3 }}-cmmc.zip ./libraries/ ./patches/ ./mmc-pack.json ./instance.cfg .minecraft/
87-
88-
- if: matrix.version == 'NORMAL'
89-
name: Archive Release MMC (NORMAL)
87+
- name: Package Artifacts
9088
run: |
91-
mv -vf ./overrides/ .minecraft/
92-
cp -vf ./icon.png .minecraft/
93-
zip -r ./${{ env.NAME }}-${{ env.VERSION_NORMAL }}-mmc.zip ./mmc-pack.json ./instance.cfg .minecraft/
89+
if [[ "${{ matrix.buildType }}" == "lwjgl3" ]]; then
90+
sed -i "s/B:EnableCustomGameTitle=false/B:EnableCustomGameTitle=true/" overrides/config/stellar_core.cfg
91+
cp -rvf cmmc/bansoukou/ overrides/
92+
mv overrides .minecraft
93+
cp icon.png .minecraft/
94+
cp -rvf cmmc/* ./
95+
zip -r artifacts/${{ env.NAME }}-${{ env.VERSION_LWJGL3 }}-cmmc.zip libraries/ patches/ mmc-pack.json instance.cfg .minecraft/
96+
else
97+
zip -r artifacts/${{ env.NAME }}-${{ env.VERSION_NORMAL }}-cf.zip manifest.json modlist.html overrides/
98+
mv overrides .minecraft
99+
cp icon.png .minecraft/
100+
zip -r artifacts/${{ env.NAME }}-${{ env.VERSION_NORMAL }}-mmc.zip mmc-pack.json instance.cfg .minecraft/
101+
mv serverfiles/* ./
102+
zip -r artifacts/${{ env.NAME }}-${{ env.VERSION_NORMAL }}-server.zip docker-compose.yml PleaseRead.txt log4j2_112-116.xml Install.* ServerStart.* settings.* TmuxServer.sh bansoukou/ config/ local/ mods/ resources/ scripts/
103+
fi
104+
105+
- name: Upload Artifacts
106+
uses: actions/upload-artifact@v3
107+
with:
108+
name: ${{ matrix.buildType }}-artifacts
109+
path: artifacts/
110+
retention-days: 1
94111

95-
- if: matrix.version == 'NORMAL'
96-
name: Move Server Files (NORMAL)
97-
run: |
98-
mv -vf ./serverfiles/* ./
112+
release:
113+
needs: build
114+
runs-on: ubuntu-latest
115+
permissions:
116+
contents: write
99117

100-
- name: Remove Client Only Mods
118+
steps:
119+
- name: Download All Artifacts
120+
uses: actions/download-artifact@v3
121+
with:
122+
path: downloads
123+
124+
- name: Aggregate Artifacts
101125
run: |
102-
rm -vf .minecraft/mods/!Red-Core-*
103-
rm -vf .minecraft/mods/Alfheim-*
104-
rm -vf .minecraft/mods/Valkyrie-*
105-
rm -vf .minecraft/mods/CraftPresence-*
106-
rm -vf .minecraft/mods/Controlling-*
107-
rm -vf .minecraft/mods/UniLib-*
108-
rm -vf .minecraft/mods/CustomMainMenu-*
109-
rm -vf .minecraft/mods/Fixeroo-*
110-
rm -vf .minecraft/mods/FpsReducer-*
111-
rm -vf .minecraft/mods/modernsplash-*
112-
rm -vf .minecraft/mods/RenderLib-*
113-
rm -vf .minecraft/mods/particleculling-*
114-
rm -vf .minecraft/mods/EntityCulling-*
115-
rm -vf .minecraft/mods/SmoothFont-*
116-
rm -vf .minecraft/mods/InGameInfoXML-*
117-
rm -vf .minecraft/mods/oauth-*
118-
rm -vf .minecraft/mods/UntranslatedItems-*
119-
rm -vf .minecraft/mods/vintagefix-*
120-
121-
- if: matrix.version == 'NORMAL'
122-
name: Archive Release Server (NORMAL)
126+
mkdir -p artifacts
127+
cp -r downloads/*/artifacts/* artifacts/
128+
129+
- name: Ensure Tag Exists
130+
if: "!startsWith(github.ref, 'refs/tags/')"
123131
run: |
124-
mv -vf .minecraft/* ./
125-
zip -r ./${{ env.NAME }}-${{ env.VERSION_NORMAL }}-server.zip ./docker-compose.yml ./PleaseRead.txt ./log4j2_112-116.xml ./Install.bat ./Install.sh ./ServerStart.bat ./ServerStart.sh ./settings.bat ./settings.sh ./TmuxServer.sh ./bansoukou/ ./config/ ./local/ ./mods/ ./resources/ ./scripts/
132+
git config --global user.name "github-actions"
133+
git config --global user.email "actions@github.com"
134+
git tag ${{ env.VERSION_NORMAL }}
135+
git push origin ${{ env.VERSION_NORMAL }}
126136
127-
- if: matrix.version == 'NORMAL'
128-
name: Create GitHub Release (NORMAL)
137+
- name: Create or Update GitHub Release
129138
uses: softprops/action-gh-release@v2
130139
with:
131140
tag_name: ${{ env.VERSION_NORMAL }}
132-
prerelease: true
133-
generate_release_notes: true
134-
files: |
135-
./${{ env.NAME }}-${{ env.VERSION_NORMAL }}-cf.zip
136-
./${{ env.NAME }}-${{ env.VERSION_NORMAL }}-mmc.zip
137-
./${{ env.NAME }}-${{ env.VERSION_NORMAL }}-server.zip
141+
name: "Preview ${{ env.VERSION_NORMAL }}"
142+
body: |
143+
## GregTech Expert 2 - Preview Release
138144
139-
- if: matrix.version == 'LWJGL3'
140-
name: Create GitHub Release (LWJGL3)
141-
uses: softprops/action-gh-release@v2
142-
with:
143-
tag_name: ${{ env.VERSION_LWJGL3 }}
145+
This preview includes:
146+
- **Standard** (CurseForge / MultiMC / PrismLauncher / Server)
147+
- **LWJGL3** (MultiMC / PrismLauncher only)
148+
149+
See installation guide for LWJGL3 [here](https://github.com/GTModpackTeam/GregTech-Expert-2/blob/main/cmmc/README.md).
144150
prerelease: true
145-
body: |
146-
Note - This is LWJGL3 build and only available for MMC / PrismLauncher.
147-
FOLLOW THE INSTALLATION GUIDE [HERE](https://github.com/GTModpackTeam/GregTech-Expert-2/blob/main/cmmc/README.md).
148-
---
149-
generate_release_notes: true
150151
files: |
151-
./${{ env.NAME }}-${{ env.VERSION_LWJGL3 }}-cmmc.zip
152+
artifacts/${{ env.NAME }}-${{ env.VERSION_NORMAL }}-cf.zip
153+
artifacts/${{ env.NAME }}-${{ env.VERSION_NORMAL }}-mmc.zip
154+
artifacts/${{ env.NAME }}-${{ env.VERSION_NORMAL }}-server.zip
155+
artifacts/${{ env.NAME }}-${{ env.VERSION_LWJGL3 }}-cmmc.zip
156+
env:
157+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)