From b23ea3b62e2ee235d325f6b96a4e17b557085f3d Mon Sep 17 00:00:00 2001 From: Lexian-droid Date: Tue, 22 Oct 2024 18:31:22 +0200 Subject: [PATCH] Update .github/workflows/build-and-upload.yml --- .github/workflows/build-and-upload.yml | 59 +++++++++++++++++++++----- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-and-upload.yml b/.github/workflows/build-and-upload.yml index 85ff266..6d30c8d 100644 --- a/.github/workflows/build-and-upload.yml +++ b/.github/workflows/build-and-upload.yml @@ -13,31 +13,68 @@ jobs: build: runs-on: ubuntu-latest + env: + PACKSQUASH_REPO: ComunidadAylas/PackSquash + steps: # Step 1: Check out the repository - name: Checkout Repository uses: actions/checkout@v3 - # Step 2: Set up Node.js environment using the latest LTS version - - name: Setup Node.js - uses: actions/setup-node@v3 + # Step 2: Set up dependencies (e.g., jq for JSON parsing) + - name: Install Dependencies + run: sudo apt-get update && sudo apt-get install -y jq unzip + + # Step 3: Fetch the latest PackSquash release information + - name: Get Latest PackSquash Release + id: get_release + uses: actions/github-script@v6 with: - node-version: 'lts/*' # Dynamically uses the latest LTS version + script: | + const repo = process.env.PACKSQUASH_REPO; + const response = await github.rest.repos.getLatestRelease({ + owner: repo.split('/')[0], + repo: repo.split('/')[1], + }); + const assets = response.data.assets; + // Determine the OS and architecture + let assetName = ''; + if (process.platform === 'linux') { + assetName = assets.find(asset => asset.name.includes('linux') && asset.name.endsWith('.zip')).browser_download_url; + } else if (process.platform === 'win32') { + assetName = assets.find(asset => asset.name.includes('windows') && asset.name.endsWith('.zip')).browser_download_url; + } else if (process.platform === 'darwin') { + assetName = assets.find(asset => asset.name.includes('macos') && asset.name.endsWith('.zip')).browser_download_url; + } else { + throw new Error('Unsupported OS'); + } + return assetName; - # Step 3: Install PackSquash globally - - name: Install PackSquash - run: npm install -g packsquash + # Step 4: Download the latest PackSquash release + - name: Download PackSquash + run: | + echo "Downloading PackSquash from ${{ steps.get_release.outputs.result }}" + curl -L "${{ steps.get_release.outputs.result }}" -o pack_squash.zip - # Step 4: Optimize the resource pack using PackSquash + # Step 5: Extract PackSquash + - name: Extract PackSquash + run: unzip pack_squash.zip -d pack_squash + + # Step 6: Ensure PackSquash is executable + - name: Make PackSquash Executable + run: chmod +x ./pack_squash/pack_squash + + # Step 7: Optimize the resource pack using PackSquash - name: Optimize Resource Pack - run: packsquash optimize ./path-to-your-resource-pack ./optimized-resource-pack + run: | + ./pack_squash/pack_squash optimize ./path-to-your-resource-pack ./optimized-resource-pack - # Step 5: Zip the optimized resource pack + # Step 8: Zip the optimized resource pack - name: Zip Optimized Pack run: | zip -r optimized-resource-pack.zip ./optimized-resource-pack - # Step 6: Upload the zipped artifact + # Step 9: Upload the zipped artifact - name: Upload Optimized Pack Artifact uses: actions/upload-artifact@v3 with: