From 4dcd6dd71c153d5ea20be462097da90abda73db0 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Thu, 25 Sep 2025 18:38:16 -0400 Subject: [PATCH 1/3] Support re-sign on regular commits --- action.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 064e2c4..6a8fd58 100644 --- a/action.yml +++ b/action.yml @@ -226,7 +226,7 @@ runs: shell: bash - name: Download and Unpack APK - if: ${{ env.ARTIFACT_URL && inputs.re-sign == 'true' && github.event_name == 'pull_request' }} + if: ${{ env.ARTIFACT_URL && inputs.re-sign == 'true' }} run: | DOWNLOAD_OUTPUT=$(npx rock remote-cache download --name ${{ env.ARTIFACT_NAME }} --json) || (echo "$DOWNLOAD_OUTPUT" && exit 1) APK_PATH=$(echo "$DOWNLOAD_OUTPUT" | jq -r '.path') @@ -234,13 +234,28 @@ runs: shell: bash - name: Re-sign APK - if: ${{ env.ARTIFACT_URL && inputs.re-sign == 'true' && github.event_name == 'pull_request' }} + if: ${{ env.ARTIFACT_URL && inputs.re-sign == 'true' }} run: | npx rock sign:android ${{ env.ARTIFACT_PATH }} \ --build-jsbundle shell: bash working-directory: ${{ inputs.working-directory }} + - name: Update Artifact Name for re-signed builds + if: ${{ env.ARTIFACT_URL && inputs.re-sign == 'true' }} + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + IDENTIFIER="${{ github.event.pull_request.number }}" + else + IDENTIFIER="${{ github.sha }}" + fi + ARTIFACT_TRAITS="${{ inputs.variant }},${IDENTIFIER}" + ARTIFACT_TRAITS_HYPHENATED=$(echo "$ARTIFACT_TRAITS" | tr ',' '-') + ARTIFACT_TRAITS_HYPHENATED_FINGERPRINT="${ARTIFACT_TRAITS_HYPHENATED}-${FINGERPRINT}" + echo "ARTIFACT_NAME=rock-android-${ARTIFACT_TRAITS_HYPHENATED_FINGERPRINT}" >> $GITHUB_ENV + echo "ARTIFACT_TRAITS=$ARTIFACT_TRAITS" >> $GITHUB_ENV + shell: bash + # Find artifact URL again before uploading, as other concurrent workflows could upload the same artifact - name: Find artifact URL again before uploading run: | @@ -255,7 +270,7 @@ runs: # Special case for GitHub, as it doesn't support uploading through the API - name: Upload Artifact to GitHub id: upload-artifact - if: ${{ env.PROVIDER_NAME == 'GitHub' && (!env.ARTIFACT_URL || (inputs.re-sign == 'true' && github.event_name == 'pull_request')) }} + if: ${{ env.PROVIDER_NAME == 'GitHub' && (!env.ARTIFACT_URL || inputs.re-sign == 'true') }} uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: ${{ env.ARTIFACT_NAME }} @@ -265,7 +280,7 @@ runs: # For re-signed builds, the ARTIFACT_NAME may contain PR-number, while Rock will save the artifact without PR trait in its cache. # We need to upload the artifact with the PR-number in the name, that's why we use --binary-path with appropriate ARTIFACT_PATH that accounts for it. - name: Upload Artifact to Remote Cache for re-signed builds - if: ${{ env.PROVIDER_NAME != 'GitHub' && (inputs.re-sign == 'true' && github.event_name == 'pull_request') }} + if: ${{ env.PROVIDER_NAME != 'GitHub' && inputs.re-sign == 'true' }} run: | OUTPUT=$(npx rock remote-cache upload --name ${{ env.ARTIFACT_NAME }} --binary-path ${{ env.ARTIFACT_PATH }} --json --verbose) || (echo "$OUTPUT" && exit 1) echo "ARTIFACT_URL=$(echo "$OUTPUT" | jq -r '.url')" >> $GITHUB_ENV From e5f8307b7a8913683f9668cf378e751875a7aba7 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Fri, 26 Sep 2025 10:52:47 -0400 Subject: [PATCH 2/3] Use short sha --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 6a8fd58..e19eef6 100644 --- a/action.yml +++ b/action.yml @@ -247,7 +247,7 @@ runs: if [ "${{ github.event_name }}" = "pull_request" ]; then IDENTIFIER="${{ github.event.pull_request.number }}" else - IDENTIFIER="${{ github.sha }}" + IDENTIFIER=$(echo "$GITHUB_SHA" | cut -c1-7) fi ARTIFACT_TRAITS="${{ inputs.variant }},${IDENTIFIER}" ARTIFACT_TRAITS_HYPHENATED=$(echo "$ARTIFACT_TRAITS" | tr ',' '-') From d626e8f4756e08ab185be3fb8c5545cd27b7afef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Fri, 26 Sep 2025 18:06:29 +0200 Subject: [PATCH 3/3] adjust second upload --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e19eef6..0049ad0 100644 --- a/action.yml +++ b/action.yml @@ -287,7 +287,7 @@ runs: shell: bash - name: Upload Artifact to Remote Cache for regular builds - if: ${{ env.PROVIDER_NAME != 'GitHub' && !env.ARTIFACT_URL }} + if: ${{ env.PROVIDER_NAME != 'GitHub' && inputs.re-sign != 'true' && !env.ARTIFACT_URL }} run: | OUTPUT=$(npx rock remote-cache upload --name ${{ env.ARTIFACT_NAME }} --json --verbose) || (echo "$OUTPUT" && exit 1) echo "ARTIFACT_URL=$(echo "$OUTPUT" | jq -r '.url')" >> $GITHUB_ENV