Skip to content

Commit cfa7fc9

Browse files
committed
download selfhosted from amo
update updates.json file
1 parent bb0cd60 commit cfa7fc9

File tree

9 files changed

+546
-47
lines changed

9 files changed

+546
-47
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: download-firefox-selfhosted
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
extensionId:
6+
description: "The Firefox extension ID"
7+
required: true
8+
default: ${{ secrets.FF_EXTENSION_ID }}
9+
xpiFilePath:
10+
description: "Path where to save the XPI file"
11+
required: true
12+
default: "Downloads/rikaitan-firefox-selfhosted.xpi"
13+
githubRef:
14+
description: "The tag to associate with the release"
15+
required: true
16+
default: ${{ github.ref_name }}
17+
18+
jobs:
19+
download:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Setup node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version-file: "package.json"
28+
29+
# intentially do not use cache to keep the build more comprehensible and sandboxed
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Download latest approved self-hosted version
34+
run: |
35+
npm run-script dl
36+
env:
37+
extensionId: ${{ inputs.extensionId }}
38+
xpiFilePath: ${{ inputs.xpiFilePath }}
39+
jwtIssuer: ${{ secrets.FF_JWT_ISSUER }}
40+
jwtSecret: ${{ secrets.FF_JWT_SECRET }}
41+
githubRef: ${{ inputs.githubRef }}
42+
43+
# https://github.com/softprops/action-gh-release
44+
- name: Upload offline xpi release asset
45+
uses: softprops/action-gh-release@v2.4.2
46+
with:
47+
tag_name: ${{ inputs.githubRef }}
48+
files: |
49+
${{ inputs.xpiFilePath }}
50+
51+
- name: Update updates.json file.
52+
uses: aurelien-baudet/workflow-dispatch@3133c5d135c7dbe4be4f9793872b6ef331b53bc7 # pin@v2
53+
with:
54+
workflow: update-updates-json-file
55+
token: ${{ secrets.GITHUB_TOKEN }}
56+
wait-for-completion: false
57+
inputs: |
58+
{
59+
"githubRef:": "${{ github.ref_name }}",
60+
"xpiFilePath": "${{ inputs.xpiFilePath }}"
61+
}

.github/workflows/publish-firefox-selfhosted.yml

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -63,50 +63,6 @@ jobs:
6363
asset_name: rikaitan-firefox-selfhosted.xpi
6464
asset_content_type: application/x-xpinstall
6565

66-
# update updates.json so that all people who have the selfhosted version installed get the new update
67-
68-
- uses: actions/checkout@v4
69-
with:
70-
ref: metadata_selfhosted
71-
72-
# note: change version because firefox doesn't allow duplicate versions
73-
# https://extensionworkshop.com/documentation/manage/updating-your-extension/
74-
- name: Recreate updates.json
75-
run: |
76-
if [[ -f prerelease.json ]]; then
77-
cp -- prerelease.json updates.json
78-
fi
79-
if [[ -z "${{ steps.uploadReleaseAsset.outputs.browser_download_url }}" ]]; then
80-
exit 1
81-
fi
82-
# TODO - the version set in manifest is +1 to ref name
83-
cat > prerelease.json << EOF
84-
{
85-
"addons": {
86-
"tatsu@autistici.org": {
87-
"updates": [
88-
{
89-
"version": "${{ github.ref_name }}",
90-
"update_link": "${{ steps.uploadReleaseAsset.outputs.browser_download_url }}"
91-
}
92-
]
93-
}
94-
}
95-
}
96-
EOF
97-
98-
- name: Commit files
99-
continue-on-error: true
100-
run: |
101-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
102-
git config --local user.name "github-actions[bot]"
103-
git commit -a -m "${{ github.ref_name }}"
104-
105-
- name: Push changes
106-
uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df # pin@master
107-
with:
108-
branch: metadata_selfhosted
109-
11066
provenance:
11167
needs: [build]
11268
permissions:

.github/workflows/publish-firefox.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ jobs:
88
runs-on: ubuntu-latest
99
environment: cd
1010
steps:
11+
- name: Dispatch download selfhosted XPI
12+
uses: aurelien-baudet/workflow-dispatch@3133c5d135c7dbe4be4f9793872b6ef331b53bc7 # pin@v2
13+
with:
14+
workflow: download-firefox-selfhosted
15+
token: ${{ secrets.GITHUB_TOKEN }}
16+
wait-for-completion: false
17+
inputs: |
18+
{
19+
"githubRef:": "${{ github.ref_name }}",
20+
"xpiFilePath": "Downloads/rikaitan-firefox-selfhosted.xpi"
21+
}
22+
1123
- uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # pin@v1.12
1224
with:
1325
tag: ${{ github.ref_name }}
@@ -19,8 +31,8 @@ jobs:
1931
uses: cardinalby/webext-buildtools-firefox-addons-action@987e338100095280ec8daf942e5640aeb55d3647 # pin@v1.0.10
2032
continue-on-error: true
2133
with:
22-
zipFilePath: rikaitan-firefox.zip
23-
sourcesZipFilePath: rikaitan-${{ github.ref_name }}.zip
34+
zipFilePath: rikaitan-firefox.zip # Path to packed extension (relative to repository).
35+
sourcesZipFilePath: rikaitan-${{ github.ref_name }}.zip # source code of the extension
2436
extensionId: ${{ secrets.FF_EXTENSION_ID }}
2537
jwtIssuer: ${{ secrets.FF_JWT_ISSUER }}
2638
jwtSecret: ${{ secrets.FF_JWT_SECRET }}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: update-updates-json-file
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
githubRef:
6+
description: "The tag to associate with the release"
7+
required: true
8+
default: ${{ github.ref_name }}
9+
xpiFilePath:
10+
description: "Path to the XPI file"
11+
required: true
12+
default: "Downloads/rikaitan-firefox-selfhosted.xpi"
13+
metadataBranch:
14+
description: "Branch to get updates.json from"
15+
required: true
16+
default: "metadata_selfhosted"
17+
18+
jobs:
19+
update:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Setup node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version-file: "package.json"
28+
29+
# intentially do not use cache to keep the build more comprehensible and sandboxed
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Get updates.json from metadata branch
34+
run: |
35+
# Get the updates.json file from the specified metadata branch
36+
mkdir -p Downloads
37+
git show ${{ inputs.metadataBranch }}:updates.json > Downloads/updates.json
38+
39+
- name: Run update_updates_json_file.ts script
40+
run: |
41+
npm run-script update_updates_json_file
42+
env:
43+
githubRef: ${{ inputs.githubRef }}
44+
xpiFilePath: ${{ inputs.xpiFilePath }}
45+
updatesFilePath: Downloads/updates.json
46+
47+
# update updates.json so that all people who have
48+
# the selfhosted version installed get the new update
49+
# https://extensionworkshop.com/documentation/manage/updating-your-extension/
50+
- name: Checkout metadata branch for commit
51+
uses: actions/checkout@v4
52+
with:
53+
ref: ${{ inputs.metadataBranch }}
54+
55+
- name: Copy updated updates.json to metadata branch
56+
run: |
57+
mv -f -- Downloads/updates.json updates.json
58+
59+
- name: Commit updated updates.json
60+
run: |
61+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
62+
git config --local user.name "github-actions[bot]"
63+
git add updates.json
64+
git commit -m "Update updates.json for release ${{ inputs.githubRef }}"
65+
66+
- name: Push changes
67+
uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df # pin@master
68+
with:
69+
branch: ${{ inputs.metadataBranch }}

0 commit comments

Comments
 (0)