Skip to content

[📦]: Project Build #28 #28

[📦]: Project Build #28

[📦]: Project Build #28 #28

Workflow file for this run

name: "Project Build"
run-name: "[📦]: Project Build #${{ github.run_number }}"
on:
push:
branches:
- dev
- feature/workflows
# paths:
# - 'shaders/**'
# - 'CHANGELOG.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
info:
name: "[🖥️] Project Info"
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'TerraFirmaGreg-Team' }}
outputs:
name: ${{ steps.check.outputs.name }}
version: ${{ steps.check.outputs.version }}
version_type: ${{ steps.check.outputs.version_type }}
loaders: ${{ steps.check.outputs.loaders }}
game_versions: ${{ steps.check.outputs.game_versions }}
changelog: ${{ steps.changelog.outputs.description }}
make_release: ${{ steps.check.outputs.make_release }}
included: ${{ steps.check.outputs.included }}
steps:
- name: "[📦] Checkout"
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: "[🔍] Check required files and folders"
uses: andstor/file-existence-action@v3.0.0
with:
fail: true
ignore_case: true
files: "pack.json, LICENSE, README.md, shaders"
- name: "[📥] Get Pack Info"
id: pack_info
uses: Xikaro/action-read-json@v1.1.1
with:
file_path: "pack.json"
flat_arrays: true
- name: "[📖] Parse Changelog"
id: changelog
uses: coditory/changelog-parser@v1.0.2
continue-on-error: true
with:
path: "CHANGELOG.md"
- name: "[🔍] Check if tag exists"
id: tag_check
uses: mukunku/tag-exists-action@v1.7.0
with:
tag: ${{ steps.changelog.outputs.version }}
- name: "[🔍] Check"
id: check
shell: bash
run: |
# Get data from previous steps
CHANGELOG_VER="${{ steps.changelog.outputs.version }}"
TAG_EXISTS="${{ steps.tag_check.outputs.exists }}"
PACK_NAME="${{ steps.pack_info.outputs.name }}"
PACK_VERSION_TYPE="${{ steps.pack_info.outputs.version_type }}"
GAME_VERSIONS="${{ steps.pack_info.outputs.targets_game_versions }}"
LOADERS="${{ steps.pack_info.outputs.targets_loaders }}"
# Clean included array (remove JSON brackets and quotes)
RAW_INCLUDED="${{ steps.pack_info.outputs.included }}"
INCLUDED=$(echo "$RAW_INCLUDED" | tr -d '[]"' | tr ',' ' ' | xargs)
# Determine if this is a release candidate
IS_RELEASE_CANDIDATE="false"
if [[ "$TAG_EXISTS" == "false" && -n "$CHANGELOG_VER" && "$CHANGELOG_VER" != "Unreleased" ]]; then
IS_RELEASE_CANDIDATE="true"
fi
# Use changelog version for releases, fallback to pack.json version with build number
if [[ "$IS_RELEASE_CANDIDATE" == "true" ]]; then
PACK_VERSION="$CHANGELOG_VER"
else
PACK_VERSION="${{ steps.pack_info.outputs.version }}-build-${{ github.run_number }}"
fi
# Save values for next steps
echo "game_version=$GAME_VERSIONS" >> $GITHUB_OUTPUT
echo "loader=$LOADERS" >> $GITHUB_OUTPUT
echo "name=$PACK_NAME" >> $GITHUB_OUTPUT
echo "version=$PACK_VERSION" >> $GITHUB_OUTPUT
echo "version_type=$PACK_VERSION_TYPE" >> $GITHUB_OUTPUT
echo "exists=$TAG_EXISTS" >> $GITHUB_OUTPUT
echo "make_release=$IS_RELEASE_CANDIDATE" >> $GITHUB_OUTPUT
echo "included=$INCLUDED" >> $GITHUB_OUTPUT
- name: "[📝] Generate Build Summary"
uses: WcAServices/markdown-template-action@v1.1.1
with:
template: |
## 📊 Build Information
### Project Info
| Parameter | Value |
|-----------|-------|
| 📃 **Name** | ${{ steps.check.outputs.name }} |
| 📃 **Version** | `${{ steps.check.outputs.version }}` |
| 📃 **Release Type** | `${{ steps.check.outputs.version_type }}` |
| 📃 **Game Versions** | `${{ steps.check.outputs.game_version }}` |
| 📃 **Loader Type** | `${{ steps.check.outputs.loader }}` |
### Build Decision
| Parameter | Value |
|-----------|-------|
| 📃 **Tag Exists** | `${{ steps.check.outputs.exists }}` |
| 📃 **Make Release** | `${{ steps.check.outputs.make_release }}` |
build-project:
name: "[📦] Build Project"
needs: [info]
runs-on: ubuntu-latest
steps:
- name: "[📦] Checkout"
uses: actions/checkout@v6
- name: "[🔄] Replace strings"
shell: bash
run: |
set +e
VERSION=${{ needs.info.outputs.version }}
sed -i -e "s/DEV/${VERSION}/g" pack.json
- name: "[📁] Prepare artifact"
uses: vimtor/action-zip@v1.3
with:
files: ${{ needs.info.outputs.included }}
dest: "${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}.zip"
recursive: false
- name: "[🚀] Upload artifact"
uses: actions/upload-artifact@v7
with:
name: "${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}"
path: "${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}.zip"
if-no-files-found: error
retention-days: 30
release-github:
name: "[🏷️] Release to GitHub"
needs: [info, build-project]
runs-on: ubuntu-latest
if: ${{ needs.info.outputs.make_release == 'true' && github.ref_name == 'dev' }}
steps:
- name: "[📦] Download artifact"
uses: actions/download-artifact@v8
- name: "[🔍] Verify artifact"
id: check_artifact
shell: bash
run: |
ARTIFACT_NAME="${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}.zip"
echo "=== Artifact Verification ==="
echo "Expected file: $ARTIFACT_NAME"
echo ""
if [ ! -f "$ARTIFACT_NAME" ]; then
echo "::error::Artifact not found: $ARTIFACT_NAME"
ls -la
exit 1
fi
echo "✅ Artifacts found"
ls -lh "$ARTIFACT_NAME"
- name: "[🚀] Create GitHub Release"
id: release
uses: softprops/action-gh-release@v2
with:
name: "${{ needs.info.outputs.version }}"
tag_name: "${{ needs.info.outputs.version }}"
target_commitish: "${{ github.ref_name }}"
body: |
${{ needs.info.outputs.changelog }}
files: |
${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}.zip
prerelease: ${{ needs.info.outputs.version_type != 'release' }}
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}
release-curseforge:
name: "[🚀] Release to CurseForge"
needs: [info, build-project, release-github]
runs-on: ubuntu-latest
if: ${{ needs.info.outputs.make_release == 'true' && github.ref_name == 'dev' }}
steps:
- name: "[🔒] Verify tokens"
shell: bash
run: |
echo "=== Token Verification ==="
if [ -z "${{ secrets.CURSEFORGE_TOKEN }}" ]; then
echo "::error::CURSEFORGE_TOKEN not found"
exit 1
fi
echo "✅ CURSEFORGE_TOKEN: OK"
echo ""
- name: "[📦] Download artifact"
uses: actions/download-artifact@v8
with:
merge-multiple: true
- name: "[🔍] Verify artifact"
id: check_artifact
shell: bash
run: |
ARTIFACT_NAME="${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}.zip"
if [ ! -f "$ARTIFACT_NAME" ]; then
echo "::error::Artifact not found: $ARTIFACT_NAME"
exit 1
fi
echo "✅ Artifact is ready for upload"
- name: "[🚀] Upload to platforms"
uses: Kir-Antipov/mc-publish@v3.3.0
with:
curseforge-id: "${{ vars.CURSEFORGE_ID }}"
curseforge-token: "${{ secrets.CURSEFORGE_TOKEN }}"
loaders: "${{ needs.info.outputs.loaders }}"
game-versions: "${{ needs.info.outputs.game_versions }}"
files: "${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}.zip"
name: "${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}"
version: "${{ needs.info.outputs.version }}"
version-type: "${{ needs.info.outputs.version_type }}"
changelog: ${{ needs.info.outputs.changelog }}
game-version-filter: none
retry-attempts: 2
retry-delay: 10000
fail-mode: fail
release-modrinth:
name: "[🚀] Release to Modrinth"
needs: [info, build-project, release-github]
runs-on: ubuntu-latest
if: ${{ needs.info.outputs.make_release == 'true' && github.ref_name == 'dev' }}
steps:
- name: "[🔒] Verify tokens"
shell: bash
run: |
echo "=== Token Verification ==="
if [ -z "${{ secrets.MODRINTH_TOKEN }}" ]; then
echo "::error::MODRINTH_TOKEN not found"
exit 1
fi
echo "✅ MODRINTH_TOKEN: OK"
echo ""
- name: "[📦] Download artifact"
uses: actions/download-artifact@v8
with:
merge-multiple: true
- name: "[🔍] Verify artifact"
id: check_artifact
shell: bash
run: |
ARTIFACT_NAME="${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}.zip"
if [ ! -f "$ARTIFACT_NAME" ]; then
echo "::error::Artifact not found: $ARTIFACT_NAME"
exit 1
fi
echo "✅ Artifact is ready for upload"
- name: "[🚀] Upload to platforms"
uses: Kir-Antipov/mc-publish@v3.3.0
with:
modrinth-id: "${{ vars.MODRINTH_ID }}"
modrinth-token: "${{ secrets.MODRINTH_TOKEN }}"
loaders: "${{ needs.info.outputs.loaders }}"
game-versions: "${{ needs.info.outputs.game_versions }}"
files: "${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}.zip"
name: "${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}"
version: "${{ needs.info.outputs.version }}"
version-type: "${{ needs.info.outputs.version_type }}"
changelog: ${{ needs.info.outputs.changelog }}
game-version-filter: none
retry-attempts: 2
retry-delay: 10000
fail-mode: fail