From 95228bf8d62cff9fb41e4a4340b9ff5c752b2472 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Wed, 10 Sep 2025 12:51:03 -0400 Subject: [PATCH] chore: refine PR plugin script and workflow for improved tarball handling - Updated `generate-pr-plugin.sh` to clarify usage instructions and rename parameters for local and remote tarball handling. - Enhanced the GitHub Actions workflow to define local and remote tarball filenames, ensuring consistent naming and preventing SHA conflicts. - Adjusted the script to use the correct tarball names during SHA256 calculation and plugin file generation, improving accuracy and reliability. --- .github/scripts/generate-pr-plugin.sh | 28 +++++++++++++----------- .github/workflows/pr-plugin-build.yml | 31 ++++++++++++++++++--------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/.github/scripts/generate-pr-plugin.sh b/.github/scripts/generate-pr-plugin.sh index dbf0c3b57..bc220ea9b 100755 --- a/.github/scripts/generate-pr-plugin.sh +++ b/.github/scripts/generate-pr-plugin.sh @@ -3,17 +3,18 @@ set -euo pipefail IFS=$'\n\t' # Generate PR plugin file for Unraid -# Usage: ./generate-pr-plugin.sh [plugin_url] +# Usage: ./generate-pr-plugin.sh [plugin_url] VERSION=$1 PR_NUMBER=$2 COMMIT_SHA=$3 -TARBALL_NAME=$4 -TXZ_URL=$5 -PLUGIN_URL=${6:-""} # Optional plugin URL for updates +LOCAL_TARBALL=$4 # Local file for SHA calculation +REMOTE_TARBALL=$5 # Remote filename for download +TXZ_URL=$6 +PLUGIN_URL=${7:-""} # Optional plugin URL for updates -if [ -z "$VERSION" ] || [ -z "$PR_NUMBER" ] || [ -z "$COMMIT_SHA" ] || [ -z "$TARBALL_NAME" ] || [ -z "$TXZ_URL" ]; then - echo "Usage: $0 [plugin_url]" +if [ -z "$VERSION" ] || [ -z "$PR_NUMBER" ] || [ -z "$COMMIT_SHA" ] || [ -z "$LOCAL_TARBALL" ] || [ -z "$REMOTE_TARBALL" ] || [ -z "$TXZ_URL" ]; then + echo "Usage: $0 [plugin_url]" exit 1 fi @@ -25,7 +26,7 @@ fi # Use consistent filename (no version in filename, version is inside the plugin) PLUGIN_NAME="webgui-pr-${PR_NUMBER}.plg" -TARBALL_SHA256=$(sha256sum "$TARBALL_NAME" | awk '{print $1}') +TARBALL_SHA256=$(sha256sum "$LOCAL_TARBALL" | awk '{print $1}') echo "Generating plugin: $PLUGIN_NAME" echo "Tarball SHA256: $TARBALL_SHA256" @@ -37,10 +38,11 @@ cat > "$PLUGIN_NAME" << 'EOF' - + + ]> "$PLUGIN_NAME" << 'EOF' pluginURL="&pluginURL;" min="6.12.0" icon="wrench" - support="&pluginURL;/pull/≺"> + support="&github;/pull/≺"> ##&version; @@ -80,7 +82,7 @@ echo "Created plugin directories" - + TXZ_URL_PLACEHOLDER &sha256; @@ -90,7 +92,7 @@ echo "Created plugin directories" > $GITHUB_OUTPUT echo "pr_version=$PR_VERSION" >> $GITHUB_OUTPUT + echo "local_txz=$LOCAL_TXZ_NAME" >> $GITHUB_OUTPUT + echo "remote_txz=$REMOTE_TXZ_NAME" >> $GITHUB_OUTPUT + echo "plugin_name=$PLUGIN_NAME" >> $GITHUB_OUTPUT echo "txz_url=$TXZ_URL" >> $GITHUB_OUTPUT echo "plugin_url=$PLUGIN_URL" >> $GITHUB_OUTPUT echo "txz_key=$TXZ_KEY" >> $GITHUB_OUTPUT @@ -86,7 +95,7 @@ jobs: cd build echo "Creating tarball with contents:" find usr/ -type f - tar -czf ../webgui-pr-${{ github.event.pull_request.number }}.tar.gz usr/ + tar -czf ../${{ steps.version.outputs.local_txz }} usr/ cd .. # Generate file list for plugin @@ -96,7 +105,7 @@ jobs: # Verify tarball contents echo "Tarball contents:" - tar -tzf webgui-pr-${{ github.event.pull_request.number }}.tar.gz + tar -tzf ${{ steps.version.outputs.local_txz }} - name: Configure AWS CLI for R2 if: steps.changed-files.outputs.has_changes == 'true' @@ -110,7 +119,7 @@ jobs: id: upload-txz run: | # Upload to R2 with versioned filename to prevent SHA conflicts - aws s3 cp "webgui-pr-${{ github.event.pull_request.number }}.tar.gz" \ + aws s3 cp "${{ steps.version.outputs.local_txz }}" \ "s3://${{ secrets.CLOUDFLARE_PREVIEW_BUCKET_NAME }}/${{ steps.version.outputs.txz_key }}" \ --endpoint-url "${{ secrets.CLOUDFLARE_S3_URL }}" \ --acl public-read @@ -120,12 +129,14 @@ jobs: - name: Generate plugin file with R2 URL if: steps.changed-files.outputs.has_changes == 'true' run: | - # Pass versioned filename to match the URL + # Local file is non-versioned, but remote URL is versioned + # Pass local filename for SHA calculation and remote filename for download bash .github/scripts/generate-pr-plugin.sh \ "${{ steps.version.outputs.version }}" \ "${{ github.event.pull_request.number }}" \ "$(git rev-parse --short HEAD)" \ - "webgui-pr-${{ github.event.pull_request.number }}-${{ steps.version.outputs.version }}.tar.gz" \ + "${{ steps.version.outputs.local_txz }}" \ + "${{ steps.version.outputs.remote_txz }}" \ "${{ steps.version.outputs.txz_url }}" \ "${{ steps.version.outputs.plugin_url }}" @@ -134,7 +145,7 @@ jobs: id: upload-plg run: | # Upload PLG - overwrite existing for updates (consistent filename) - aws s3 cp "webgui-pr-${{ github.event.pull_request.number }}.plg" \ + aws s3 cp "${{ steps.version.outputs.plugin_name }}" \ "s3://${{ secrets.CLOUDFLARE_PREVIEW_BUCKET_NAME }}/${{ steps.version.outputs.plugin_key }}" \ --endpoint-url "${{ secrets.CLOUDFLARE_S3_URL }}" \ --acl public-read