name: Publish LCE Panorama Collection on: push: tags: - 'LPC-*' 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 }} modrinth_id: ${{ steps.extract.outputs.modrinth_id }} curseforge_id: ${{ steps.extract.outputs.curseforge_id }} steps: - name: Check if tag matches LPC id: check run: | if [ "${{ github.event_name }}" = "release" ]; then tag="${{ github.event.release.tag_name }}" if [[ "$tag" =~ ^LPC-[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 'LPC-X.Y.Z'. Skipping workflow." fi else echo "should_run=true" >> $GITHUB_OUTPUT fi - name: Extract 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/^LPC-//') 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 echo "version=dev" >> $GITHUB_OUTPUT fi echo "modrinth_id=lce-panorama-collection" >> $GITHUB_OUTPUT echo "curseforge_id=lce-panorama-collection" >> $GITHUB_OUTPUT build-and-publish: needs: check-tag if: needs.check-tag.outputs.should_run == 'true' runs-on: technocality strategy: matrix: include: - subfolder: "build0016" display_suffix: "(Build 0016)" - subfolder: "build0054" display_suffix: "(Build 0054)" - subfolder: "tu5" display_suffix: "(TU5)" - subfolder: "tu7" display_suffix: "(TU7)" - subfolder: "tu12" display_suffix: "(TU12)" - subfolder: "tu20" display_suffix: "(TU20)" - subfolder: "tu31" display_suffix: "(TU31)" - subfolder: "tu46" display_suffix: "(TU46)" - subfolder: "tu69" display_suffix: "(TU69)" env: PACK_FOLDER: lce-panorama-collection OUTPUT: built-resourcepacks steps: - uses: actions/checkout@v5 with: fetch-depth: 1 - name: Set version 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: Cache PackSquash id: cache-packsquash uses: actions/cache@v3 with: path: ~/.cargo/bin/packsquash key: packsquash-${{ runner.os }} - name: Install PackSquash if: steps.cache-packsquash.outputs.cache-hit != 'true' run: | apt-get update && apt-get install -y cmake curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly $HOME/.cargo/bin/cargo +nightly install --git https://github.com/ComunidadAylas/PackSquash --bin packsquash - name: Add Cargo to Path run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH - name: Build run: | mkdir -p ${{ env.OUTPUT }} dir="./resourcepacks/external/${{ env.PACK_FOLDER }}/${{ matrix.subfolder }}" output="$(pwd)/${{ env.OUTPUT }}/${{ env.PACK_FOLDER }}-${{ matrix.subfolder }}-${{ steps.version.outputs.version }}.zip" cat > /tmp/options.toml << EOF pack_directory = '$dir' output_file_path = '$output' EOF packsquash /tmp/options.toml - name: Publish to Modrinth if: needs.check-tag.outputs.is_alpha == 'false' uses: https://github.com/Kir-Antipov/mc-publish@v3.3 with: modrinth-id: ${{ needs.check-tag.outputs.modrinth_id }} modrinth-token: ${{ secrets.MR }} files: ${{ env.OUTPUT }}/${{ env.PACK_FOLDER }}-${{ matrix.subfolder }}-${{ steps.version.outputs.version }}.zip name: "LCE Panorama Collection ${{ steps.version.outputs.version }} ${{ matrix.display_suffix }}" version: "${{ steps.version.outputs.version }}-${{ matrix.subfolder }}" 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: | minecraft 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 changelog: ${{ github.event.release.body || format('Development build - {0}', steps.version.outputs.commit-sha) }} retry-attempts: 3 retry-delay: 10000 fail-mode: warn - name: Publish to CurseForge if: needs.check-tag.outputs.is_alpha == 'false' uses: https://github.com/Kir-Antipov/mc-publish@v3.3 with: curseforge-id: ${{ needs.check-tag.outputs.curseforge_id }} curseforge-token: ${{ secrets.CF }} files: ${{ env.OUTPUT }}/${{ env.PACK_FOLDER }}-${{ matrix.subfolder }}-${{ steps.version.outputs.version }}.zip name: "LCE Panorama Collection ${{ steps.version.outputs.version }} ${{ matrix.display_suffix }}" version: "${{ steps.version.outputs.version }}-${{ matrix.subfolder }}" 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: | minecraft 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 changelog: ${{ github.event.release.body || format('Development build - {0}', steps.version.outputs.commit-sha) }} retry-attempts: 3 retry-delay: 10000 fail-mode: warn - name: Upload to Forgejo if: github.event_name == 'release' run: | file=$(ls ${{ env.OUTPUT }}/${{ env.PACK_FOLDER }}-${{ matrix.subfolder }}-*) 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 }}" \ | grep -o '"id":[0-9]*' | head -1 | sed 's/"id"://') echo "Uploading $(basename $file) to release $release_id" curl -s -X POST \ -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \ -H "Content-Type: application/octet-stream" \ --data-binary @"$file" \ "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${release_id}/assets?name=$(basename $file)"