aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/publish-firefox-development.yml
blob: 234ef8b097987be99e952210203e0e1961d81e31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# For the Firefox development addon, people install it manually,
# and updates are distributed via the JSON file created in this
# action which is stored in the metadata branch of this repo.

name: publish-firefox-development
on:
  workflow_dispatch:
    inputs:
      upload_url:
        description: "The upload_url from the release created by create-prerelease-on-tag.yml"
        required: true
permissions:
  contents: read
jobs:
  build-signed-xpi-asset:
    runs-on: ubuntu-latest
    environment: cd
    permissions:
      contents: write
    steps:
      - uses: robinraju/release-downloader@efa4cd07bd0195e6cc65e9e30c251b49ce4d3e51 # pin@v1.8
        with:
          tag: ${{ github.ref_name }}
          fileName: "*"

      - name: Sign Firefox xpi for offline distribution
        id: ffSignXpi
        continue-on-error: true
        uses: cardinalby/webext-buildtools-firefox-sign-xpi-action@94a2e58141e33c4306a72a93f191e8540189df92 # pin@v1.0.6
        with:
          timeoutMs: 1200000
          extensionId: ${{ secrets.FF_OFFLINE_EXT_ID }}
          zipFilePath: yomitan-firefox-dev.zip
          xpiFilePath: yomitan-firefox-dev.xpi
          jwtIssuer: ${{ secrets.FF_JWT_ISSUER }}
          jwtSecret: ${{ secrets.FF_JWT_SECRET }}

      - name: Abort on sign error
        if: |
          steps.ffSignXpi.outcome == 'failure' &&
          steps.ffSignXpi.outputs.sameVersionAlreadyUploadedError != 'true'
        run: exit 1

      - name: Upload offline xpi release asset
        id: uploadReleaseAsset
        if: steps.ffSignXpi.outcome == 'success'
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ inputs.upload_url }}
          asset_path: yomitan-firefox-dev.xpi
          asset_name: yomitan-firefox-dev.xpi
          asset_content_type: application/x-xpinstall

      # update update.json so that all people who have the dev version installed get the new update

      - uses: actions/checkout@v3
        with:
          ref: metadata

      - name: Recreate update.json
        run: |
          cat > update.json << EOF
          {
              "addons": {
                  "{2d13e145-294e-4ead-9bce-b4644b203a00}": {
                      "updates": [
                          {
                              "version": "${{ github.event.release.name }}",
                              "update_link": "${{ steps.uploadReleaseAsset.browser_download_url }}"
                          }
                      ]
                  }
              }
          }
          EOF

      - name: Commit files
        run: |
          git config --local user.email "github-actions[bot]@users.noreply.github.com"
          git config --local user.name "github-actions[bot]"
          git commit -a -m "${{ github.event.release.name }} - ${{ github.event.release.html_url }}"

      - name: Push changes
        uses: ad-m/github-push-action@29f05e01bb17e6f28228b47437e03a7b69e1f9ef # pin@master
        with:
          branch: metadata