Deploy Preview Modpack #399
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Preview Modpack | |
permissions: | |
contents: read | |
deployments: write | |
on: | |
workflow_dispatch: | |
inputs: | |
target_branch: | |
description: 'Target branch for the preview' | |
type: string | |
required: true | |
version: | |
description: 'Modpack version' | |
required: true | |
preview_version: | |
description: 'Preview version' | |
required: true | |
env: | |
NAME: "GTExpert2" | |
VERSION_NORMAL: "v${{ github.event.inputs.version }}-pr-${{ github.event.inputs.preview_version }}" | |
VERSION_LWJGL3: "v${{ github.event.inputs.version }}-lwjgl3-${{ github.event.inputs.preview_version }}" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
buildType: [standard, lwjgl3] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.target_branch || github.ref }} | |
fetch-depth: 0 | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.m2/repository | |
~/.cache/pip | |
key: ${{ runner.os }}-deps-${{ matrix.buildType }}-${{ hashFiles('**/pom.xml') }} | |
- name: Download Resource Packs zip | |
run: | | |
GITHUB_RELEASE=$(curl -s https://api.github.com/repos/GTModpackTeam/GTE2-Translations/releases) | |
ASSET_URL=$(echo $GITHUB_RELEASE | jq -r '.[]."assets"[]."browser_download_url"' | grep "resourcepack" | head -1) | |
ASSET_NAME=$(echo $ASSET_URL | awk -F'/' '{print $NF}') | |
wget -O ./overrides/resourcepacks/$ASSET_NAME $ASSET_URL | |
- name: Setup Build Environment | |
uses: ./.github/actions/build_setup | |
- name: Create artifacts directory | |
run: mkdir -p artifacts | |
- name: Set Modpack Version | |
run: | | |
if [[ "${{ matrix.buildType }}" == "lwjgl3" ]]; then | |
VER="${{ env.VERSION_LWJGL3 }}" | |
else | |
VER="${{ env.VERSION_NORMAL }}" | |
fi | |
echo "[CleanroomMMC] GregTech Expert 2 $VER" > overrides/config/txloader/load/custommainmenu/version.txt | |
sed -i "s/MODPACKVERSION/$VER/g" manifest.json instance.cfg overrides/config/craftpresence.json | |
- name: Adjust for LWJGL3 | |
if: matrix.buildType == 'lwjgl3' | |
run: | | |
python buildtools/gen-lwjgl3-manifest.py | |
cp -vf cmmc/manifest.json manifest.json | |
- name: Install Mods | |
env: | |
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }} | |
run: python buildtools/mod-install.py | |
- name: Clean up placeholder files | |
run: find . -name ".gitkeep" -delete | |
- name: Package Artifacts | |
run: | | |
if [[ "${{ matrix.buildType }}" == "lwjgl3" ]]; then | |
sed -i "s/B:EnableCustomGameTitle=false/B:EnableCustomGameTitle=true/" overrides/config/stellar_core.cfg | |
cp -rvf cmmc/bansoukou/ overrides/ | |
mv overrides .minecraft | |
cp icon.png .minecraft/ | |
cp -rvf cmmc/* ./ | |
zip -r artifacts/${{ env.NAME }}-${{ env.VERSION_LWJGL3 }}-cmmc.zip libraries/ patches/ mmc-pack.json instance.cfg .minecraft/ | |
else | |
zip -r artifacts/${{ env.NAME }}-${{ env.VERSION_NORMAL }}-cf.zip manifest.json modlist.html overrides/ | |
mv overrides .minecraft | |
cp icon.png .minecraft/ | |
zip -r artifacts/${{ env.NAME }}-${{ env.VERSION_NORMAL }}-mmc.zip mmc-pack.json instance.cfg .minecraft/ | |
mv serverfiles/* ./ | |
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/ | |
fi | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.buildType }}-artifacts | |
path: artifacts/ | |
retention-days: 1 | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.target_branch || github.ref }} | |
fetch-depth: 0 | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: downloads | |
- name: Aggregate Artifacts | |
run: | | |
mkdir -p artifacts | |
for d in downloads/*; do | |
if [ -d "$d" ]; then | |
cp -r "$d"/* artifacts/ || true | |
fi | |
done | |
- name: Ensure Tag Exists | |
if: "!startsWith(github.ref, 'refs/tags/')" | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "actions@github.com" | |
git tag ${{ env.VERSION_NORMAL }} | |
git push origin ${{ env.VERSION_NORMAL }} | |
- name: Create or Update GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.VERSION_NORMAL }} | |
name: "Preview ${{ env.VERSION_NORMAL }}" | |
body: | | |
## GregTech Expert 2 - Preview Release | |
This preview includes: | |
- **Standard** (CurseForge / MultiMC / PrismLauncher / Server) | |
- **LWJGL3** (MultiMC / PrismLauncher only) | |
See installation guide for LWJGL3 [here](https://github.com/GTModpackTeam/GregTech-Expert-2/blob/main/cmmc/README.md). | |
prerelease: true | |
files: | | |
artifacts/${{ env.NAME }}-${{ env.VERSION_NORMAL }}-cf.zip | |
artifacts/${{ env.NAME }}-${{ env.VERSION_NORMAL }}-mmc.zip | |
artifacts/${{ env.NAME }}-${{ env.VERSION_NORMAL }}-server.zip | |
artifacts/${{ env.NAME }}-${{ env.VERSION_LWJGL3 }}-cmmc.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |