|
| 1 | +# On release published: |
| 2 | +# - if no built extension.zip asset attached to release, does that |
| 3 | +# - builds and attaches signed crx asset to release |
| 4 | +# - builds and attaches signed xpi asset to release |
| 5 | +name: Build release assets |
| 6 | + |
| 7 | +on: |
| 8 | + release: |
| 9 | + # Creating draft releases will not trigger it |
| 10 | + types: [published] |
| 11 | +jobs: |
| 12 | + # Find out asset id of existing extension.zip asset in a release or |
| 13 | + # build and attach it to the release and use its asset id |
| 14 | + ensure-zip: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + zipAssetId: | |
| 18 | + ${{ steps.getZipAssetId.outputs.result || |
| 19 | + steps.uploadZipAsset.outputs.id }} |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - uses: cardinalby/export-env-action@66657b34899a2d695434ed060d9f2215db9b4035 |
| 24 | + with: |
| 25 | + envFile: './.github/workflows/constants.env' |
| 26 | + expand: true |
| 27 | + |
| 28 | + - name: Find out "extension.zip" asset id from the release |
| 29 | + id: getZipAssetId |
| 30 | + uses: cardinalby/js-eval-action@b34865f1d9cfdf35356013627474857cfe0d5091 |
| 31 | + env: |
| 32 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + ASSETS_URL: ${{ github.event.release.assets_url }} |
| 34 | + ASSET_NAME: ${{ env.ZIP_FILE_NAME }} |
| 35 | + with: |
| 36 | + expression: | |
| 37 | + (await octokit.request("GET " + env.ASSETS_URL)).data |
| 38 | + .find(asset => asset.name == env.ASSET_NAME)?.id || '' |
| 39 | +
|
| 40 | + - name: Build, test and pack |
| 41 | + if: '!steps.getZipAssetId.outputs.result' |
| 42 | + id: buildPack |
| 43 | + uses: ./.github/workflows/actions/build-test-pack |
| 44 | + |
| 45 | + - name: Upload "extension.zip" asset to the release |
| 46 | + id: uploadZipAsset |
| 47 | + if: '!steps.getZipAssetId.outputs.result' |
| 48 | + uses: actions/upload-release-asset@v1 |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + with: |
| 52 | + upload_url: ${{ github.event.release.upload_url }} |
| 53 | + asset_path: ${{ env.ZIP_FILE_PATH }} |
| 54 | + asset_name: ${{ env.ZIP_FILE_NAME }} |
| 55 | + asset_content_type: application/zip |
| 56 | + |
| 57 | + build-signed-crx-asset: |
| 58 | + needs: ensure-zip |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - uses: cardinalby/export-env-action@66657b34899a2d695434ed060d9f2215db9b4035 |
| 64 | + with: |
| 65 | + envFile: './.github/workflows/constants.env' |
| 66 | + expand: true |
| 67 | + |
| 68 | + - name: Download zip release asset |
| 69 | + uses: cardinalby/download-release-asset-action@8fe4ec3a876fe25b72086c8de1faddfaeb6512ff |
| 70 | + with: |
| 71 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + assetId: ${{ needs.ensure-zip.outputs.zipAssetId }} |
| 73 | + targetPath: ${{ env.ZIP_FILE_PATH }} |
| 74 | + |
| 75 | + - name: Build offline crx |
| 76 | + id: buildOfflineCrx |
| 77 | + uses: cardinalby/webext-buildtools-chrome-crx-action@200e7173cbdb5acb91d381cf9f7a30080b025047 |
| 78 | + with: |
| 79 | + zipFilePath: ${{ env.ZIP_FILE_PATH }} |
| 80 | + crxFilePath: ${{ env.OFFLINE_CRX_FILE_PATH }} |
| 81 | + privateKey: ${{ secrets.CHROME_CRX_PRIVATE_KEY }} |
| 82 | + |
| 83 | + - name: Upload offline crx release asset |
| 84 | + uses: actions/upload-release-asset@v1 |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + with: |
| 88 | + upload_url: ${{ github.event.release.upload_url }} |
| 89 | + asset_path: ${{ env.OFFLINE_CRX_FILE_PATH }} |
| 90 | + asset_name: ${{ env.OFFLINE_CRX_FILE_NAME }} |
| 91 | + asset_content_type: application/x-chrome-extension |
0 commit comments