fix(ci): update build.yml

This commit is contained in:
omo50
2026-04-14 21:13:41 -06:00
parent 5715e607a5
commit 0d9c1bd0f3

View File

@@ -7,7 +7,6 @@ on:
- 'modpacks/**' - 'modpacks/**'
- 'resourcepacks/**' - 'resourcepacks/**'
- 'datapacks/**' - 'datapacks/**'
- 'packsquash.toml'
pull_request: pull_request:
branches: [ "main" ] branches: [ "main" ]
workflow_dispatch: workflow_dispatch:
@@ -25,20 +24,18 @@ jobs:
modpacks modpacks
resourcepacks resourcepacks
datapacks datapacks
.actions src/actions
- name: Meta - name: Meta
id: meta id: meta
run: | run: |
CHANGED_FILE=$(git diff-tree --no-commit-id --name-only -r HEAD | grep -E '^(modpacks|resourcepacks|datapacks)/' | head -n 1) MANIFEST=$(git diff-tree --no-commit-id --name-only -r HEAD | grep 'manifest.json' | head -n 1)
if [ -z "$CHANGED_FILE" ]; then CHANGED_FILE="modpacks/simply-legacy/"; fi
if [ -z "$MANIFEST" ]; then MANIFEST="modpacks/simply-legacy/manifest.json"; fi
PACK_ID=$(echo "$CHANGED_FILE" | cut -d'/' -f2)
SHORT_SHA=$(git rev-parse --short HEAD) SHORT_SHA=$(git rev-parse --short HEAD)
CLEAN_NAME=$(echo "$PACK_ID" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1') echo "manifest=$MANIFEST" >> $GITHUB_OUTPUT
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
echo "pack_name=$CLEAN_NAME" >> $GITHUB_OUTPUT
- name: Cache Go Binaries - name: Cache Go Binaries
id: cache-go id: cache-go
@@ -54,37 +51,43 @@ jobs:
cache: true cache: true
- name: Install Packwiz - name: Install Packwiz
if: steps.cache-go.outputs.cache-hit != 'true'
run: | run: |
if [ ! -f "$HOME/go/bin/packwiz" ]; then go install github.com/packwiz/packwiz@latest
go install github.com/packwiz/packwiz@latest
fi - name: Add Path
echo "$HOME/go/bin" >> $GITHUB_PATH run: echo "$HOME/go/bin" >> $GITHUB_PATH
- name: Cache Builder - name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Builder Binary
id: cache-builder id: cache-builder
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: ./builder path: ./builder-bin
key: builder-v26.4.0-${{ runner.os }}-${{ hashFiles('.actions/builder/src/**') }} key: builder-v1-${{ runner.os }}-${{ hashFiles('src/actions/publish.rs') }}
- name: Setup Builder - name: Rust Cache (Compiler Internals)
if: steps.cache-builder.outputs.cache-hit != 'true'
uses: Swatinem/rust-cache@v2
with:
workspaces: "src/actions -> target"
- name: Build Builder
if: steps.cache-builder.outputs.cache-hit != 'true' if: steps.cache-builder.outputs.cache-hit != 'true'
run: | run: |
if ! command -v cargo &> /dev/null; then cargo build --release --manifest-path src/actions/Cargo.toml --bin publish
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y mkdir -p ./builder-bin
source $HOME/.cargo/env cp src/actions/target/release/publish ./builder-bin/builder
fi
cd .actions/builder
cargo build --release
cp target/release/builder ../../builder
- name: Run Build - name: Run Build
run: | run: |
chmod +x ./builder chmod +x ./builder-bin/builder
./builder ${{ steps.meta.outputs.short_sha }} ./builder-bin/builder "${{ steps.meta.outputs.manifest }}"
- name: Upload - name: Upload
uses: https://code.forgejo.org/actions/upload-artifact@v3 uses: https://code.forgejo.org/actions/upload-artifact@v3
with: with:
name: "${{ steps.meta.outputs.pack_name }}-${{ steps.meta.outputs.short_sha }}" name: "build-${{ steps.meta.outputs.short_sha }}"
path: artifacts/ path: "**/artifacts/"