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