From 8bc161c829d6189187acefc28a7e0fadaf1628b2 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 7 May 2025 10:05:48 -0700 Subject: [PATCH 1/4] fix: upload assets release job --- .github/workflows/asset-release.yml | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/asset-release.yml b/.github/workflows/asset-release.yml index bc4b2bf8d..cbaf4dda7 100644 --- a/.github/workflows/asset-release.yml +++ b/.github/workflows/asset-release.yml @@ -3,7 +3,11 @@ name: Add Release Assets on: release: types: [published] - + workflow_dispatch: + inputs: + tag: + description: 'Tag to generate documentation for' + required: false jobs: asset: runs-on: ${{ matrix.operating-system }} @@ -18,12 +22,6 @@ jobs: name: Get Tag run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} - - name: Get release - id: get_release - uses: bruceadams/get-release@v1.2.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout uses: actions/checkout@v2 @@ -50,14 +48,11 @@ jobs: zip -d ${fileName} "tests*" || true && zip -d ${fileName} "examples*" || true env: - fileName: google-api-php-client-${{ steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip + fileName: google-api-php-client-${{ inputs.tag || steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip - name: Upload Release Archive - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + uses: softprops/action-gh-release@v2 + if: github.ref_type == 'tag' with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./google-api-php-client-${{ steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip - asset_name: google-api-php-client-${{ steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip - asset_content_type: application/zip + files: | + ./google-api-php-client-${{ inputs.tag || steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip From 9a3a0a765cd4af897a9310b669c21476c0548e85 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 7 May 2025 10:54:18 -0700 Subject: [PATCH 2/4] allow workflow_trigger to push assets --- .github/workflows/asset-release.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/asset-release.yml b/.github/workflows/asset-release.yml index cbaf4dda7..d87f917b9 100644 --- a/.github/workflows/asset-release.yml +++ b/.github/workflows/asset-release.yml @@ -7,7 +7,11 @@ on: inputs: tag: description: 'Tag to generate documentation for' + required: true + dry-run: + description: 'does not push the assets when true' required: false + default: "true" jobs: asset: runs-on: ${{ matrix.operating-system }} @@ -52,7 +56,7 @@ jobs: - name: Upload Release Archive uses: softprops/action-gh-release@v2 - if: github.ref_type == 'tag' + if: github.ref_type == 'tag' || inputs.dry-run != 'true' with: files: | ./google-api-php-client-${{ inputs.tag || steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip From c83a72c70b55465f1532a6ab7cfdff3cd70e4885 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 7 May 2025 10:58:26 -0700 Subject: [PATCH 3/4] set tag_name when using workflow dispatch --- .github/workflows/asset-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/asset-release.yml b/.github/workflows/asset-release.yml index d87f917b9..158cfbdf4 100644 --- a/.github/workflows/asset-release.yml +++ b/.github/workflows/asset-release.yml @@ -58,5 +58,6 @@ jobs: uses: softprops/action-gh-release@v2 if: github.ref_type == 'tag' || inputs.dry-run != 'true' with: + tag_name: ${{ inputs.tag || steps.tagName.outputs.tag }} files: | ./google-api-php-client-${{ inputs.tag || steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip From 8c4b94d1b5c3129bd9a2f16477c3e172504a142f Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 7 May 2025 11:11:48 -0700 Subject: [PATCH 4/4] add permissions --- .github/workflows/asset-release.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/asset-release.yml b/.github/workflows/asset-release.yml index 158cfbdf4..42006a281 100644 --- a/.github/workflows/asset-release.yml +++ b/.github/workflows/asset-release.yml @@ -1,5 +1,8 @@ name: Add Release Assets +permissions: + contents: write + on: release: types: [published] @@ -8,10 +11,10 @@ on: tag: description: 'Tag to generate documentation for' required: true - dry-run: - description: 'does not push the assets when true' + upload-on-workflow-dispatch: + description: 'Upload assets?' required: false - default: "true" + default: "false" jobs: asset: runs-on: ${{ matrix.operating-system }} @@ -56,7 +59,7 @@ jobs: - name: Upload Release Archive uses: softprops/action-gh-release@v2 - if: github.ref_type == 'tag' || inputs.dry-run != 'true' + if: github.ref_type == 'tag' || inputs.upload-on-workflow-dispatch == 'true' with: tag_name: ${{ inputs.tag || steps.tagName.outputs.tag }} files: |