Files
Content-Monorepo/.github/workflows/publish.yml
2025-11-11 19:02:05 -06:00

515 lines
18 KiB
YAML

name: Publish Re-Console
on:
release:
types: [published]
workflow_dispatch:
inputs:
version_override:
description: 'Override version number'
required: false
type: string
jobs:
check-tag:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check.outputs.should_run }}
version: ${{ steps.extract.outputs.version }}
is_alpha: ${{ steps.extract.outputs.is_alpha }}
is_lite: ${{ steps.extract.outputs.is_lite }}
pack_name: ${{ steps.extract.outputs.pack_name }}
source_path: ${{ steps.extract.outputs.source_path }}
modrinth_id: ${{ steps.extract.outputs.modrinth_id }}
curseforge_id: ${{ steps.extract.outputs.curseforge_id }}
steps:
- name: Check if tag starts with RC or Lite
id: check
run: |
if [ "${{ github.event_name }}" = "release" ]; then
tag="${{ github.event.release.tag_name }}"
if [[ "$tag" =~ ^(RC|Lite)-[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
echo "should_run=true" >> $GITHUB_OUTPUT
else
echo "should_run=false" >> $GITHUB_OUTPUT
echo "Tag '$tag' does not match pattern 'RC-X.Y.Z' or 'Lite-X.Y.Z'. Skipping workflow."
fi
else
# Always run for workflow_dispatch
echo "should_run=true" >> $GITHUB_OUTPUT
fi
- name: Extract version and type from tag
id: extract
if: steps.check.outputs.should_run == 'true'
run: |
if [ "${{ github.event_name }}" = "release" ]; then
tag="${{ github.event.release.tag_name }}"
# Check if it's a Lite release
if [[ "$tag" =~ ^Lite- ]]; then
echo "is_lite=true" >> $GITHUB_OUTPUT
echo "pack_name=Re-Console-Lite" >> $GITHUB_OUTPUT
echo "source_path=re-console-lite" >> $GITHUB_OUTPUT
echo "modrinth_id=legacy-minecraft-lite" >> $GITHUB_OUTPUT
echo "curseforge_id=re-console-lite" >> $GITHUB_OUTPUT
# Extract version after "Lite-"
version=$(echo "$tag" | sed 's/^Lite-//')
else
echo "is_lite=false" >> $GITHUB_OUTPUT
echo "pack_name=Re-Console" >> $GITHUB_OUTPUT
echo "source_path=re-console" >> $GITHUB_OUTPUT
echo "modrinth_id=legacy-minecraft" >> $GITHUB_OUTPUT
echo "curseforge_id=re-console" >> $GITHUB_OUTPUT
# Extract version after "RC-"
version=$(echo "$tag" | sed 's/^RC-//')
fi
echo "version=$version" >> $GITHUB_OUTPUT
# Check if it's an alpha release
if [[ "$version" == *"-alpha"* ]]; then
echo "is_alpha=true" >> $GITHUB_OUTPUT
echo "Alpha release detected - will only publish to GitHub"
else
echo "is_alpha=false" >> $GITHUB_OUTPUT
fi
else
# Default values for workflow_dispatch
echo "is_lite=false" >> $GITHUB_OUTPUT
echo "is_alpha=false" >> $GITHUB_OUTPUT
echo "pack_name=Re-Console" >> $GITHUB_OUTPUT
echo "source_path=re-console" >> $GITHUB_OUTPUT
echo "modrinth_id=legacy-minecraft" >> $GITHUB_OUTPUT
echo "curseforge_id=re-console" >> $GITHUB_OUTPUT
fi
build:
needs: check-tag
if: needs.check-tag.outputs.should_run == 'true'
strategy:
matrix:
include:
# modrinth fabric
- version: "1.20.1"
loader: "fabric"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.20.4"
loader: "fabric"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.1"
loader: "fabric"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.3"
loader: "fabric"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.4"
loader: "fabric"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.5"
loader: "fabric"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.8"
loader: "fabric"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.10"
loader: "fabric"
platform: "modrinth"
file_ext: "mrpack"
# modrinth quilt
- version: "1.20.1"
loader: "quilt"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.20.4"
loader: "quilt"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.1"
loader: "quilt"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.3"
loader: "quilt"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.4"
loader: "quilt"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.5"
loader: "quilt"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.8"
loader: "quilt"
platform: "modrinth"
file_ext: "mrpack"
- version: "1.21.10"
loader: "quilt"
platform: "modrinth"
file_ext: "mrpack"
# modrinth forge
- version: "1.20.1"
loader: "forge"
platform: "modrinth"
file_ext: "mrpack"
# modrinth neoforge
- version: "1.21.1"
loader: "neoforge"
platform: "modrinth"
file_ext: "mrpack"
# curseforge fabric
- version: "1.20.1"
loader: "fabric"
platform: "curseforge"
file_ext: "zip"
- version: "1.20.4"
loader: "fabric"
platform: "curseforge"
file_ext: "zip"
- version: "1.21.1"
loader: "fabric"
platform: "curseforge"
file_ext: "zip"
- version: "1.21.3"
loader: "fabric"
platform: "curseforge"
file_ext: "zip"
- version: "1.21.4"
loader: "fabric"
platform: "curseforge"
file_ext: "zip"
- version: "1.21.5"
loader: "fabric"
platform: "curseforge"
file_ext: "zip"
- version: "1.21.8"
loader: "fabric"
platform: "curseforge"
file_ext: "zip"
# curseforge quilt
- version: "1.20.1"
loader: "quilt"
platform: "curseforge"
file_ext: "zip"
- version: "1.20.4"
loader: "quilt"
platform: "curseforge"
file_ext: "zip"
- version: "1.21.1"
loader: "quilt"
platform: "curseforge"
file_ext: "zip"
- version: "1.21.3"
loader: "quilt"
platform: "curseforge"
file_ext: "zip"
- version: "1.21.4"
loader: "quilt"
platform: "curseforge"
file_ext: "zip"
- version: "1.21.5"
loader: "quilt"
platform: "curseforge"
file_ext: "zip"
- version: "1.21.8"
loader: "quilt"
platform: "curseforge"
file_ext: "zip"
# curseforge neoforge
- version: "1.21.1"
loader: "neoforge"
platform: "curseforge"
file_ext: "zip"
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACK_NAME: ${{ needs.check-tag.outputs.pack_name }}
SOURCE_PATH: ${{ needs.check-tag.outputs.source_path }}
OUTPUT: artifacts
outputs:
version: ${{ steps.version.outputs.version }}
commit-sha: ${{ steps.version.outputs.commit-sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
# Cache Packwiz binary to avoid Go setup and compilation
- name: Cache Packwiz Binary
uses: actions/cache@v4
id: cache-packwiz
with:
path: ~/go/bin/packwiz
key: packwiz-binary-${{ runner.os }}-v1
restore-keys: |
packwiz-binary-${{ runner.os }}-
# Only set up Go and install Packwiz if not cached
- name: Set up Go
if: steps.cache-packwiz.outputs.cache-hit != 'true'
uses: actions/setup-go@v5
with:
go-version: 'stable'
cache: false
- name: Install Packwiz
if: steps.cache-packwiz.outputs.cache-hit != 'true'
run: go install github.com/packwiz/packwiz@latest
# Add Packwiz to PATH (whether cached or freshly installed)
- name: Add Packwiz to PATH
run: echo "$HOME/go/bin" >> $GITHUB_PATH
- name: Set version and commit SHA
id: version
run: |
shortSha=$(git rev-parse --short ${{ github.sha }})
echo "commit-sha=$shortSha" >> $GITHUB_OUTPUT
if [ -n "${{ github.event.inputs.version_override }}" ]; then
version="${{ github.event.inputs.version_override }}"
elif [ "${{ github.event_name }}" = "release" ]; then
# Use the extracted version from the tag
version="${{ needs.check-tag.outputs.version }}"
else
version="dev-$(date +%Y%m%d-%H%M%S)"
fi
echo "version=$version" >> $GITHUB_OUTPUT
- name: Build modpack
run: |
# Create temp directory with appropriate prefix
if [ "${{ needs.check-tag.outputs.is_lite }}" = "true" ]; then
temp_dir="RC-Lite-${{ matrix.platform }}-${{ matrix.loader }}-${{ matrix.version }}-temp"
else
temp_dir="RC-${{ matrix.platform }}-${{ matrix.loader }}-${{ matrix.version }}-temp"
fi
mkdir $temp_dir
cp -r ./versions/vanilla/src/${{ env.SOURCE_PATH }}/${{ matrix.platform }}/${{ matrix.loader }}/${{ matrix.version }}/* ./$temp_dir/
cp ./LICENSE ./$temp_dir/
cp ./README.md ./$temp_dir/
cd ./$temp_dir/
packwiz refresh
mkdir -p ../$OUTPUT
packwiz ${{ matrix.platform }} export --output ../${OUTPUT}/${PACK_NAME}-${{ matrix.version }}-${{ matrix.loader }}-${{ steps.version.outputs.version }}-${{ matrix.platform }}.${{ matrix.file_ext }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-${{ matrix.loader }}-${{ matrix.version }}
path: ${{ env.OUTPUT }}/*
retention-days: 1
publish-modrinth:
needs: [check-tag, build]
if: needs.check-tag.outputs.should_run == 'true' && needs.check-tag.outputs.is_alpha == 'false'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- version: "1.20.1"
loader: "forge"
- version: "1.20.1"
loader: "quilt"
- version: "1.20.1"
loader: "fabric"
- version: "1.20.4"
loader: "quilt"
- version: "1.20.4"
loader: "fabric"
- version: "1.21.1"
loader: "neoforge"
- version: "1.21.1"
loader: "quilt"
- version: "1.21.1"
loader: "fabric"
- version: "1.21.3"
loader: "quilt"
- version: "1.21.3"
loader: "fabric"
- version: "1.21.4"
loader: "quilt"
- version: "1.21.4"
loader: "fabric"
- version: "1.21.5"
loader: "quilt"
- version: "1.21.5"
loader: "fabric"
- version: "1.21.8"
loader: "quilt"
- version: "1.21.8"
loader: "fabric"
- version: "1.21.10"
loader: "quilt"
- version: "1.21.10"
loader: "fabric"
max-parallel: 1 # Ensures sequential uploads
env:
PACK_NAME: ${{ needs.check-tag.outputs.pack_name }}
VERSION: ${{ needs.build.outputs.version }}
COMMIT_SHORT_SHA: ${{ needs.build.outputs.commit-sha }}
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: modrinth-${{ matrix.loader }}-${{ matrix.version }}
path: artifacts
- name: Publish to Modrinth
uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: ${{ needs.check-tag.outputs.modrinth_id }}
modrinth-token: ${{ secrets.MR }}
files: |
artifacts/${{ env.PACK_NAME }}-${{ matrix.version }}-${{ matrix.loader }}-${{ env.VERSION }}-modrinth.mrpack
name: "${{ needs.check-tag.outputs.is_lite == 'true' && 'RC-Lite' || 'RC' }} ${{ env.VERSION }} (${{ matrix.loader == 'neoforged' && 'NeoForge' || 'Fabric' }} ${{ matrix.version }})"
version: "${{ env.VERSION }}-${{ matrix.loader }}-${{ matrix.version }}"
version-type: ${{ github.event_name == 'release' && (contains(github.event.release.tag_name, 'alpha') && 'alpha' || contains(github.event.release.tag_name, 'beta') && 'beta' || 'release') || 'alpha' }}
loaders: ${{ matrix.loader == 'neoforged' && 'neoforge' || matrix.loader }}
game-versions: ${{ matrix.version }}
changelog: ${{ github.event.release.body || format('Development build - {0}', env.COMMIT_SHORT_SHA) }}
retry-attempts: 3
retry-delay: 10000
fail-mode: warn
publish-curseforge:
needs: [check-tag, build]
if: needs.check-tag.outputs.should_run == 'true' && needs.check-tag.outputs.is_alpha == 'false'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- version: "1.20.1"
loader: "quilt"
- version: "1.20.1"
loader: "fabric"
- version: "1.20.4"
loader: "quilt"
- version: "1.20.4"
loader: "fabric"
- version: "1.21.1"
loader: "quilt"
- version: "1.21.1"
loader: "fabric"
- version: "1.21.3"
loader: "quilt"
- version: "1.21.3"
loader: "fabric"
- version: "1.21.4"
loader: "quilt"
- version: "1.21.4"
loader: "fabric"
- version: "1.21.5"
loader: "quilt"
- version: "1.21.5"
loader: "fabric"
- version: "1.21.8"
loader: "quilt"
- version: "1.21.8"
loader: "fabric"
max-parallel: 1 # Ensures sequential uploads
env:
PACK_NAME: ${{ needs.check-tag.outputs.pack_name }}
VERSION: ${{ needs.build.outputs.version }}
COMMIT_SHORT_SHA: ${{ needs.build.outputs.commit-sha }}
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: curseforge-${{ matrix.loader }}-${{ matrix.version }}
path: artifacts
- name: Publish to CurseForge
uses: Kir-Antipov/mc-publish@v3.3
with:
curseforge-id: ${{ needs.check-tag.outputs.curseforge_id }}
curseforge-token: ${{ secrets.CF }}
files: |
artifacts/${{ env.PACK_NAME }}-${{ matrix.version }}-${{ matrix.loader }}-${{ env.VERSION }}-curseforge.zip
name: "${{ needs.check-tag.outputs.is_lite == 'true' && 'RC-Lite' || 'RC' }} ${{ env.VERSION }} (${{ matrix.loader == 'neoforged' && 'NeoForge' || 'Fabric' }} ${{ matrix.version }})"
version: "${{ env.VERSION }}-${{ matrix.loader }}-${{ matrix.version }}"
version-type: ${{ github.event_name == 'release' && (contains(github.event.release.tag_name, 'alpha') && 'alpha' || contains(github.event.release.tag_name, 'beta') && 'beta' || 'release') || 'alpha' }}
loaders: ${{ matrix.loader == 'neoforged' && 'neoforge' || matrix.loader }}
game-versions: ${{ matrix.version }}
changelog: ${{ github.event.release.body || format('Development build - {0}', env.COMMIT_SHORT_SHA) }}
retry-attempts: 3
retry-delay: 10000
fail-mode: warn
publish-github:
needs: [check-tag, build]
if: needs.check-tag.outputs.should_run == 'true' && github.event_name == 'release'
runs-on: ubuntu-latest
env:
PACK_NAME: ${{ needs.check-tag.outputs.pack_name }}
VERSION: ${{ needs.build.outputs.version }}
COMMIT_SHORT_SHA: ${{ needs.build.outputs.commit-sha }}
steps:
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts
- name: Create combined release package
run: |
mkdir combined-release
find all-artifacts -name "*.zip" -exec cp {} combined-release/ \;
find all-artifacts -name "*.mrpack" -exec cp {} combined-release/ \;
cd combined-release
zip_name="${{ needs.check-tag.outputs.is_lite == 'true' && 'RC-Lite' || 'RC' }}-${{ env.VERSION }}-All.zip"
zip -r "../$zip_name" .
- name: Upload to GitHub Release
uses: Kir-Antipov/mc-publish@v3.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: |
${{ needs.check-tag.outputs.is_lite == 'true' && 'RC-Lite' || 'RC' }}-${{ env.VERSION }}-All.zip
name: "${{ needs.check-tag.outputs.is_lite == 'true' && 'RC-Lite' || 'RC' }} ${{ env.VERSION }} - All"
version: "${{ env.VERSION }}"
loaders: |
fabric
quilt
forge
neoforge
game-versions: |
1.20.1
1.20.4
1.21.1
1.21.3
1.21.4
1.21.5
1.21.8
1.21.10