Skip to content

Update packsquash.yml #151

Update packsquash.yml

Update packsquash.yml #151

Workflow file for this run

name: Optimize resource pack
on: [push]
jobs:
packsquash:
name: Optimize resource pack
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # A non-shallow repository clone is required
- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Check for changes in core directory
id: core_changes
run: |
git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep -q '^core/' && echo "CORE_CHANGED=true" >> $GITHUB_ENV || echo "CORE_CHANGED=false" >> $GITHUB_ENV
- name: Setup Stripzip
run: |
git clone https://github.com/KittyHawkCorp/stripzip.git szp && cd szp
make
mv stripzip ..
- name: Conditionally Run PackSquash
if: env.CORE_CHANGED == 'true'
uses: ComunidadAylas/PackSquash-action@v4
with:
packsquash_version: latest
options: |
pack_directory = 'core'
recompress_compressed_files = true
zip_compression_iterations = 30
zip_spec_conformance_level = 'balanced'
skip_pack_icon = false
output_file_path = 'core.zip'
['**/*?.png']
image_data_compression_iterations = 15
['**/{LICENSE,README.txt}']
force_include = true
- name: ZIP Hud
run: cd hud && zip -r ../hud.zip . && cd ..
- name: ZIP Soundscapes
run: cd soundscapes && zip -r ../soundscapes.zip . && cd ..
- name: Clean ZIP Metadata
run: |
if [ -f core.zip ]; then ./stripzip core.zip; fi
./stripzip hud.zip
./stripzip soundscapes.zip
- uses: actions/upload-artifact@v4
with:
name: packs
path: |
core.zip
hud.zip
soundscapes.zip
- name: Hash files
run: |
if [ -f core.zip ]; then
calculatedCoreSha=($(sha1sum core.zip))
echo "CORE_SHA=$calculatedCoreSha" >> $GITHUB_ENV
else
echo "CORE_SHA=SKIPPED" >> $GITHUB_ENV
fi
calculatedHudSha=($(sha1sum hud.zip))
echo "HUD_SHA=$calculatedHudSha" >> $GITHUB_ENV
calculatedSoundscapesSha=($(sha1sum soundscapes.zip))
echo "SOUNDSCAPES_SHA=$calculatedSoundscapesSha" >> $GITHUB_ENV
- name: Upload core to release
if: env.CORE_CHANGED == 'true'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: core.zip
asset_name: core.zip
tag: refs/tags/latest
overwrite: true
- name: Upload hud to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: hud.zip
asset_name: hud.zip
tag: refs/tags/latest
overwrite: true
- name: Upload soundscapes to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: soundscapes.zip
asset_name: soundscapes.zip
tag: refs/tags/latest
overwrite: true
body: |
core: ${{ env.CORE_SHA }}
hud: ${{ env.HUD_SHA }}
soundscapes: ${{ env.SOUNDSCAPES_SHA }}