chore(ci): improve publisher

This commit is contained in:
omo50
2026-04-19 13:22:47 -06:00
parent fb40790886
commit fae1b2ee34
2 changed files with 92 additions and 60 deletions

View File

@@ -18,37 +18,46 @@ jobs:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-depth: 2
filter: blob:none
sparse-checkout: |
modpacks
datapacks
- name: Install jq
run: |
if ! command -v jq &> /dev/null; then
apt-get update && apt-get install -y jq
fi
- name: Find changed manifests
id: find
run: |
set -eu
MANIFESTS=$(git diff-tree --no-commit-id --name-only -r HEAD \
| grep -E '^(modpacks|datapacks)/.*/manifest\.json$' || true)
if [ -z "$MANIFESTS" ]; then
echo "has_manifests=false" >> $GITHUB_OUTPUT
echo "manifests=[]" >> $GITHUB_OUTPUT
echo "has_manifests=false" >> "$GITHUB_OUTPUT"
echo "manifests=[]" >> "$GITHUB_OUTPUT"
echo "no changed manifests."
else
JSON=$(echo "$MANIFESTS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "has_manifests=true" >> $GITHUB_OUTPUT
echo "manifests=$JSON" >> $GITHUB_OUTPUT
echo "manifests to publish: $JSON"
exit 0
fi
JSON="["
first=1
while IFS= read -r line; do
[ -z "$line" ] && continue
if [ "$first" -eq 1 ]; then
first=0
else
JSON="${JSON},"
fi
JSON="${JSON}\"${line}\""
done <<< "$MANIFESTS"
JSON="${JSON}]"
echo "has_manifests=true" >> "$GITHUB_OUTPUT"
echo "manifests=${JSON}" >> "$GITHUB_OUTPUT"
echo "manifests to publish: ${JSON}"
publish:
needs: detect
if: always()
if: needs.detect.outputs.has_manifests == 'true'
runs-on: technocality
strategy:
fail-fast: false
@@ -73,12 +82,7 @@ jobs:
- name: Generate Changelog
id: changelog
run: |
git config user.name "Forgejo Action"
git config user.email "actions@noreply.forgejo"
git add .
git commit -m "internal: prepare changelog" --allow-empty
npx tsx tools/changelog/generate-changelog.ts "${{ matrix.manifest }}"
run: npx tsx tools/changelog/generate-changelog.ts "${{ matrix.manifest }}"
- name: Cache Publisher Binary
id: cache-publisher
@@ -87,16 +91,16 @@ jobs:
path: ./publisher-bin
key: publisher-v1-${{ runner.os }}-${{ hashFiles('src/actions/publish/**/*.rs', 'src/actions/publish/Cargo.toml', 'src/actions/publish/Cargo.lock') }}
- name: Install Rust
if: steps.cache-publisher.outputs.cache-hit != 'true'
uses: https://github.com/dtolnay/rust-toolchain@stable
- name: Rust Cache
if: steps.cache-publisher.outputs.cache-hit != 'true'
uses: https://github.com/Swatinem/rust-cache@v2
with:
workspaces: "src/actions/publish -> target"
- name: Install Rust
if: steps.cache-publisher.outputs.cache-hit != 'true'
uses: https://github.com/dtolnay/rust-toolchain@stable
- name: Build Publisher
if: steps.cache-publisher.outputs.cache-hit != 'true'
run: |
@@ -113,7 +117,7 @@ jobs:
- name: Setup Go
if: steps.cache-go.outputs.cache-hit != 'true'
uses: actions/setup-go@v5
uses: https://github.com/actions/setup-go@v5
with:
go-version: 'stable'
cache: true
@@ -125,6 +129,14 @@ jobs:
- name: Add Go bin to PATH
run: echo "$HOME/go/bin" >> $GITHUB_PATH
- name: Cache Packwiz Downloads
uses: actions/cache@v4
with:
path: ~/.cache/packwiz
key: packwiz-cache-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
packwiz-cache-${{ runner.os }}-
- name: Run Publisher
id: meta
run: |
@@ -145,4 +157,4 @@ jobs:
version: "${{ steps.meta.outputs.ver }}"
changelog: "${{ steps.changelog.outputs.notes }}"
loaders: ${{ steps.meta.outputs.type == 'modpack' && steps.meta.outputs.loader || 'minecraft' }}
game-versions: "${{ steps.meta.outputs.mc }}"
game-versions: "${{ steps.meta.outputs.mc }}"