-
-
Notifications
You must be signed in to change notification settings - Fork 2
136 lines (117 loc) · 4.97 KB
/
node.yml
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Node
on:
- push
env:
ARTIFACTS_DIR: ${{ vars.ARTIFACTS_DIR }}
ARTIFACT_FIREFOX_FILENAME: ${{ vars.ARTIFACT_FIREFOX_FILENAME }}
ARTIFACT_CHROMIUM_FILENAME: ${{ vars.ARTIFACT_CHROMIUM_FILENAME }}
ARTIFACT_ARCHIVE_FILENAME: ${{ vars.ARTIFACT_ARCHIVE_FILENAME }}
FIREFOX_ADDON_ID: ${{ vars.FIREFOX_ADDON_ID }}
CHROME_EXTENSION_ID: ${{ vars.CHROME_EXTENSION_ID }}
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
attestations: write
outputs:
firefox-artifact-id: ${{ steps.upload-firefox-artifact.outputs.artifact-id }}
chromium-artifact-id: ${{ steps.upload-chromium-artifact.outputs.artifact-id }}
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm install
- name: Lint
run: npm run lint
- name: Build Firefox extension
run: npm run build:firefox
- uses: actions/upload-artifact@v4
id: upload-firefox-artifact
name: Upload Firefox artifact
with:
name: aria2-integration-firefox
path: dist
- name: Build Chromium extension
run: npm run build:chromium
- uses: actions/upload-artifact@v4
id: upload-chromium-artifact
name: Upload Chromium artifact
with:
name: aria2-integration-chromium
path: dist
- name: Download artifacts
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir "$ARTIFACTS_DIR"
gh api /repos/${{ github.repository }}/actions/artifacts/${{ steps.upload-firefox-artifact.outputs.artifact-id }}/zip > "$ARTIFACTS_DIR/$ARTIFACT_FIREFOX_FILENAME"
gh api /repos/${{ github.repository }}/actions/artifacts/${{ steps.upload-chromium-artifact.outputs.artifact-id }}/zip > "$ARTIFACTS_DIR/$ARTIFACT_CHROMIUM_FILENAME"
- name: Attest artifacts
uses: actions/attest-build-provenance@v2
with:
subject-path: |
${{ env.ARTIFACTS_DIR }}/${{ env.ARTIFACT_FIREFOX_FILENAME }}
${{ env.ARTIFACTS_DIR }}/${{ env.ARTIFACT_CHROMIUM_FILENAME }}
release:
name: Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Download artifacts
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir "$ARTIFACTS_DIR"
gh api /repos/${{ github.repository }}/actions/artifacts/${{ needs.build.outputs.firefox-artifact-id }}/zip > "$ARTIFACTS_DIR/$ARTIFACT_FIREFOX_FILENAME"
gh api /repos/${{ github.repository }}/actions/artifacts/${{ needs.build.outputs.chromium-artifact-id }}/zip > "$ARTIFACTS_DIR/$ARTIFACT_CHROMIUM_FILENAME"
- name: Verify artifacts
env:
GH_TOKEN: ${{ github.token }}
run: |
gh attestation verify "$ARTIFACTS_DIR/$ARTIFACT_FIREFOX_FILENAME" --repo ${{ github.repository }}
gh attestation verify "$ARTIFACTS_DIR/$ARTIFACT_CHROMIUM_FILENAME" --repo ${{ github.repository }}
- name: Archive repository
run: git archive --format zip --output "$ARTIFACTS_DIR/$ARTIFACT_ARCHIVE_FILENAME" ${{ github.ref_name }}
- name: Release Firefox extension
uses: baptistecdr/release-firefox-addon@v1.0.3
if: ${{ vars.RELEASE_FIREFOX_EXTENSION == 'true' }}
with:
addon-id: ${{ env.FIREFOX_ADDON_ID }}
auth-api-issuer: ${{ secrets.MOZILLA_ADDONS_API_KEY }}
auth-api-secret: ${{ secrets.MOZILLA_ADDONS_API_SECRET }}
addon-path: ${{ env.ARTIFACTS_DIR }}/${{ env.ARTIFACT_FIREFOX_FILENAME }}
source-path: ${{ env.ARTIFACTS_DIR }}/${{ env.ARTIFACT_ARCHIVE_FILENAME }}
release-note: 'Release ${{ github.ref_name }}'
- name: Release Microsoft Edge extension
uses: baptistecdr/release-edge-extension@v1.0.1
if: ${{ vars.RELEASE_EDGE_EXTENSION == 'true' }}
with:
api-key: ${{ secrets.MS_API_KEY }}
client-id: ${{ secrets.MS_API_CLIENT_ID }}
product-id: ${{ secrets.EDGE_PRODUCT_ID }}
product-path: ${{ env.ARTIFACTS_DIR }}/${{ env.ARTIFACT_CHROMIUM_FILENAME }}
- name: Release Chrome extension
uses: baptistecdr/release-chrome-extension@v1.0.6
if: ${{ vars.RELEASE_CHROME_EXTENSION == 'true' }}
with:
extension-id: ${{ env.CHROME_EXTENSION_ID }}
extension-path: ${{ env.ARTIFACTS_DIR }}/${{ env.ARTIFACT_CHROMIUM_FILENAME }}
oauth-client-id: ${{ secrets.GOOGLE_API_CLIENT_ID }}
oauth-client-secret: ${{ secrets.GOOGLE_API_CLIENT_SECRET }}
oauth-refresh-token: ${{ secrets.GOOGLE_API_REFRESH_TOKEN }}