Skip to content

[📦]: Project Build #50 #50

[📦]: Project Build #50

[📦]: Project Build #50 #50

Workflow file for this run

name: "Project Build"
run-name: "[📦]: Project Build #${{ github.run_number }}"
on:
push:
branches:
- dev
paths:
- 'shaders/**'
- 'project.json'
- 'CHANGELOG.md'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
info:
name: "[🖥️] Project Info"
runs-on: ubuntu-latest
if: ${{ !github.event.repository.fork }}
outputs:
name: ${{ steps.check.outputs.name }}
version: ${{ steps.check.outputs.version }}
version_type: ${{ steps.check.outputs.version_type }}
full_name: ${{ steps.check.outputs.name }}-${{ steps.check.outputs.version }}
loaders: ${{ steps.check.outputs.loaders }}
game_versions: ${{ steps.check.outputs.game_versions }}
changelog: ${{ steps.changelog.outputs.description }}
included: ${{ steps.check.outputs.included }}
make_release: ${{ steps.check.outputs.make_release }}
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: "project.json, LICENSE, README.md, shaders"
- name: "[📥] Get Project Info"
id: project_info
uses: Xikaro/action-read-json@v1.1.1
with:
file_path: "project.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 }}"
PROJECT_NAME="${{ steps.project_info.outputs.name }}"
# Preparation
RAW_INCLUDED="${{ steps.project_info.outputs.included }}"
INCLUDED=$(echo "$RAW_INCLUDED" | tr -d '[]"' | tr ',' ' ' | xargs)
RAW_LOADERS="${{ steps.project_info.outputs.targets_loaders }}"
LOADERS=$(echo "$RAW_LOADERS" | tr ' ' ',')
RAW_GAME_VERSIONS="${{ steps.project_info.outputs.targets_game_versions }}"
GAME_VERSIONS=$(echo "$RAW_GAME_VERSIONS" | tr ' ' ',')
IS_RELEASE_CANDIDATE="false"
if [[ "$TAG_EXISTS" == "false" && -n "$CHANGELOG_VER" && "$CHANGELOG_VER" != "Unreleased" ]]; then
IS_RELEASE_CANDIDATE="true"
fi
if [[ "$IS_RELEASE_CANDIDATE" == "true" ]]; then
PROJECT_VERSION="$CHANGELOG_VER"
PROJECT_VERSION_TYPE="${{ steps.project_info.outputs.version_type }}"
else
PROJECT_VERSION="${{ steps.project_info.outputs.version }}-build-${{ github.run_number }}"
PROJECT_VERSION_TYPE="Unreleased"
fi
# Save values for next steps
echo "game_versions=$GAME_VERSIONS" >> $GITHUB_OUTPUT
echo "loaders=$LOADERS" >> $GITHUB_OUTPUT
echo "name=$PROJECT_NAME" >> $GITHUB_OUTPUT
echo "version=$PROJECT_VERSION" >> $GITHUB_OUTPUT
echo "version_type=$PROJECT_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_versions }}` |
| 📃 **Loaders** | `${{ steps.check.outputs.loaders }}` |
### Build Decision
| Parameter | Value |
|-----------|-------|
| 📃 **Tag Exists** | `${{ steps.check.outputs.exists }}` |
| 📃 **Make Release** | `${{ steps.check.outputs.make_release }}` |
build:
name: "[📦] Build Project"
needs: [info]
runs-on: ubuntu-latest
steps:
- name: "[📦] Checkout"
uses: actions/checkout@v6
- name: "[🔄] Replace"
shell: bash
run: |
set +e
VERSION=${{ needs.info.outputs.version }}
sed -i -e "s/DEV/${VERSION}/g" project.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
release:
name: "[🚀] Release"
needs: [info, build]
runs-on: ubuntu-latest
if: ${{ needs.info.outputs.make_release }}
steps:
- name: "[📦] Download artifact"
uses: actions/download-artifact@v8
- name: "[🔒] Verify"
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"
if [ -z "${{ secrets.CURSEFORGE_TOKEN }}" ]; then
echo "::error::CURSEFORGE_TOKEN not found"
exit 1
fi
echo "✅ CURSEFORGE_TOKEN: OK"
echo ""
echo "=== ID Verification ==="
if [ -z "${{ vars.MODRINTH_ID }}" ]; then
echo "::error::MODRINTH_ID not found"
exit 1
fi
echo "✅ MODRINTH_ID: OK"
if [ -z "${{ vars.CURSEFORGE_ID }}" ]; then
echo "::error::CURSEFORGE_ID not found"
exit 1
fi
echo "✅ CURSEFORGE_ID: OK"
echo ""
echo "=== Artifact Verification ==="
if [ ! -f "${{ needs.info.outputs.full_name }}.zip" ]; then
echo "::error::Artifact not found"
ls -la
exit 1
fi
echo "✅ Artifact: OK"
echo ""
- name: "[🚀] Release"
if: ${{ vars.ACTIONS_STEP_DEBUG != 'true' }}
uses: Xikaro/game-publish@3.3.3
with:
modrinth-id: ${{ vars.MODRINTH_ID }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-id: ${{ vars.CURSEFORGE_ID }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
github-name: ${{ needs.info.outputs.version }}
github-tag: ${{ needs.info.outputs.version }}
github-generate-changelog: true
github-draft: false
github-prerelease: ${{ needs.info.outputs.version_type != 'release' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
files: ${{ needs.info.outputs.full_name }}.zip
name: ${{ needs.info.outputs.full_name }}
version: ${{ needs.info.outputs.version }}
version-type: ${{ needs.info.outputs.version_type }}
changelog: ${{ needs.info.outputs.changelog }}
loaders: ${{ needs.info.outputs.loaders }}
game-versions: ${{ needs.info.outputs.game_versions }}
game-version-filter: none
retry-attempts: 2
retry-delay: 10000
fail-mode: fail