mirror of
https://github.com/Nostalgica-Reverie/Content-Monorepo.git
synced 2026-05-09 00:24:15 +00:00
init(actions): attempt to make auto publish script
This commit is contained in:
273
.forgejo/workflows/publish-rc.yml
Normal file
273
.forgejo/workflows/publish-rc.yml
Normal file
@@ -0,0 +1,273 @@
|
||||
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: technocality
|
||||
outputs:
|
||||
should_run: ${{ steps.check.outputs.should_run }}
|
||||
version: ${{ steps.extract.outputs.version }}
|
||||
is_alpha: ${{ steps.extract.outputs.is_alpha }}
|
||||
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
|
||||
id: check
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "release" ]; then
|
||||
tag="${{ github.event.release.tag_name }}"
|
||||
if [[ "$tag" =~ ^RC-[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'. Skipping workflow."
|
||||
fi
|
||||
else
|
||||
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 }}"
|
||||
version=$(echo "$tag" | sed 's/^RC-//')
|
||||
echo "version=$version" >> $GITHUB_OUTPUT
|
||||
|
||||
if [[ "$version" == *"-alpha"* ]]; then
|
||||
echo "is_alpha=true" >> $GITHUB_OUTPUT
|
||||
echo "Alpha release detected - will only publish to Forgejo"
|
||||
else
|
||||
echo "is_alpha=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
else
|
||||
echo "is_alpha=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
echo "pack_name=Re-Console+" >> $GITHUB_OUTPUT
|
||||
echo "source_path=re-console-plus" >> $GITHUB_OUTPUT
|
||||
echo "modrinth_id=legacy-minecraft" >> $GITHUB_OUTPUT
|
||||
echo "curseforge_id=re-console" >> $GITHUB_OUTPUT
|
||||
|
||||
build:
|
||||
needs: check-tag
|
||||
if: needs.check-tag.outputs.should_run == 'true'
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- { version: "1.21.10", loader: "fabric", platform: "modrinth", file_ext: "mrpack" }
|
||||
- { version: "1.21.10", loader: "fabric", platform: "curseforge", file_ext: "zip" }
|
||||
|
||||
runs-on: technocality
|
||||
env:
|
||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||
PACK_NAME: ${{ needs.check-tag.outputs.pack_name }}
|
||||
SOURCE_PATH: ${{ needs.check-tag.outputs.source_path }}
|
||||
OUTPUT: artifacts
|
||||
ARTIFACT_DIR: /tmp/rc-build-${{ github.sha }}
|
||||
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
commit-sha: ${{ steps.version.outputs.commit-sha }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Check Packwiz
|
||||
id: check-packwiz
|
||||
run: |
|
||||
if [ -f "$HOME/go/bin/packwiz" ]; then
|
||||
echo "exists=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "exists=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Set up Go
|
||||
if: steps.check-packwiz.outputs.exists != 'true'
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 'stable'
|
||||
cache: false
|
||||
|
||||
- name: Install Packwiz
|
||||
if: steps.check-packwiz.outputs.exists != 'true'
|
||||
run: go install github.com/packwiz/packwiz@latest
|
||||
|
||||
- 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
|
||||
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: |
|
||||
temp_dir="RC-${{ matrix.platform }}-${{ matrix.loader }}-${{ matrix.version }}-temp"
|
||||
|
||||
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: Save artifacts to runner temp
|
||||
run: |
|
||||
mkdir -p ${{ env.ARTIFACT_DIR }}
|
||||
cp ${{ env.OUTPUT }}/* ${{ env.ARTIFACT_DIR }}/
|
||||
|
||||
publish-modrinth:
|
||||
needs: [check-tag, build]
|
||||
if: needs.check-tag.outputs.should_run == 'true' && needs.check-tag.outputs.is_alpha == 'false'
|
||||
runs-on: technocality
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- { version: "1.21.10", loader: "fabric" }
|
||||
max-parallel: 1
|
||||
env:
|
||||
PACK_NAME: ${{ needs.check-tag.outputs.pack_name }}
|
||||
VERSION: ${{ needs.build.outputs.version }}
|
||||
COMMIT_SHORT_SHA: ${{ needs.build.outputs.commit-sha }}
|
||||
ARTIFACT_DIR: /tmp/rc-build-${{ github.sha }}
|
||||
|
||||
steps:
|
||||
- name: Copy artifacts for this matrix entry
|
||||
run: |
|
||||
mkdir -p artifacts
|
||||
cp ${{ env.ARTIFACT_DIR }}/${{ env.PACK_NAME }}-${{ matrix.version }}-${{ matrix.loader }}-${{ env.VERSION }}-modrinth.mrpack artifacts/
|
||||
|
||||
- name: Publish to Modrinth
|
||||
uses: https://github.com/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: "RC Plus ${{ env.VERSION }} (${{ matrix.loader == 'fabric' && 'Fabric' }})"
|
||||
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 }}
|
||||
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: technocality
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- { version: "1.21.10", loader: "fabric" }
|
||||
max-parallel: 1
|
||||
env:
|
||||
PACK_NAME: ${{ needs.check-tag.outputs.pack_name }}
|
||||
VERSION: ${{ needs.build.outputs.version }}
|
||||
COMMIT_SHORT_SHA: ${{ needs.build.outputs.commit-sha }}
|
||||
ARTIFACT_DIR: /tmp/rc-build-${{ github.sha }}
|
||||
|
||||
steps:
|
||||
- name: Copy artifacts for this matrix entry
|
||||
run: |
|
||||
mkdir -p artifacts
|
||||
cp ${{ env.ARTIFACT_DIR }}/${{ env.PACK_NAME }}-${{ matrix.version }}-${{ matrix.loader }}-${{ env.VERSION }}-curseforge.zip artifacts/
|
||||
|
||||
- name: Publish to CurseForge
|
||||
uses: https://github.com/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: "RC Plus ${{ env.VERSION }} (${{ matrix.loader == 'fabric' && 'Fabric' }})"
|
||||
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 }}
|
||||
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-forgejo:
|
||||
needs: [check-tag, build]
|
||||
if: needs.check-tag.outputs.should_run == 'true' && github.event_name == 'release'
|
||||
runs-on: technocality
|
||||
env:
|
||||
PACK_NAME: ${{ needs.check-tag.outputs.pack_name }}
|
||||
VERSION: ${{ needs.build.outputs.version }}
|
||||
ARTIFACT_DIR: /tmp/rc-build-${{ github.sha }}
|
||||
|
||||
steps:
|
||||
- name: Create combined release zip and upload to Forgejo release
|
||||
run: |
|
||||
mkdir combined-release
|
||||
find ${{ env.ARTIFACT_DIR }} -name "*.zip" -exec cp {} combined-release/ \;
|
||||
find ${{ env.ARTIFACT_DIR }} -name "*.mrpack" -exec cp {} combined-release/ \;
|
||||
|
||||
zip_name="RC-plus-${{ env.VERSION }}-All.zip"
|
||||
cd combined-release
|
||||
zip -r "../$zip_name" .
|
||||
cd ..
|
||||
|
||||
# Get the release ID from Forgejo API by tag name
|
||||
release_id=$(curl -s \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/${{ github.event.release.tag_name }}" \
|
||||
| jq -r '.id')
|
||||
|
||||
echo "Uploading $zip_name to release $release_id"
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @"$zip_name" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${release_id}/assets?name=$zip_name"
|
||||
|
||||
cleanup:
|
||||
needs: [publish-modrinth, publish-curseforge, publish-forgejo]
|
||||
if: always()
|
||||
runs-on: technocality
|
||||
steps:
|
||||
- name: Remove runner temp artifacts
|
||||
run: rm -rf /tmp/rc-build-${{ github.sha }}
|
||||
Reference in New Issue
Block a user