-
Notifications
You must be signed in to change notification settings - Fork 1
123 lines (115 loc) · 4.35 KB
/
deploy.yml
File metadata and controls
123 lines (115 loc) · 4.35 KB
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
name: Deploy Browser Extension
on:
workflow_dispatch:
inputs:
browser:
description: Browser platform to build for as an array (e.g., '["chrome"]", '["firefox", "chrome"]')
required: false
default: '["chrome", "firefox"]'
type: string
tag:
description: Tag to deploy (e.g., "ecu-test-diff-1.0.0")
required: true
type: string
push:
tags:
- 'ecu-test-diff-[0-9]+.[0-9]+.[0-9]+'
jobs:
setup:
runs-on: ubuntu-latest
outputs:
tag-version: ${{ steps.set-tag.outputs.tag-version }}
steps:
- name: Set tag
id: set-tag
run: |
# determine if the workflow was triggered by a dispatch event or a tag push, and set the tag version accordingly
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
TAG_VERSION="${{ github.event.inputs.tag }}"
# validate tag version
if [[ ! $TAG_VERSION =~ ^ecu-test-diff-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Invalid tag version format. Expected format: ecu-test-diff-x.y.z"
exit 1
fi
echo "tag-version=$TAG_VERSION" >> $GITHUB_OUTPUT
else
TAG_VERSION="${GITHUB_REF#refs/tags/}"
echo "tag-version=$TAG_VERSION" >> $GITHUB_OUTPUT
fi
version-check:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check tag matches manifest version
id: version-check
run: |
sudo apt-get update -y
sudo apt-get install -y jq
TAG_VERSION="${{ needs.setup.outputs.tag-version }}"
MANIFEST_VERSION=$(jq -r '.version' static/manifest.json)
echo "Tag version: $TAG_VERSION"
echo "Manifest version: $MANIFEST_VERSION"
# check for beta versions first
if [[ ! "$MANIFEST_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Manifest version ($MANIFEST_VERSION) is not a valid semantic version. Expected format: x.y.z"
exit 1
fi
# extract the version from the tag
TAG_VERSION=${TAG_VERSION#ecu-test-diff-}
if [ "$TAG_VERSION" != "$MANIFEST_VERSION" ]; then
echo "❌ Tag version ($TAG_VERSION) does not match manifest version ($MANIFEST_VERSION)."
exit 1
fi
echo "✅ Tag version matches manifest version."
build:
needs: version-check
uses: ./.github/workflows/build.yml
with:
browser: ${{ github.event.inputs.browser || '["chrome", "firefox"]' }}
publish:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
browser: ${{ fromJSON(github.event.inputs.browser || '["chrome", "firefox"]') }}
steps:
- name: Get artifact from build job
uses: actions/download-artifact@v4
with:
name: ${{ matrix.browser }}-extension
path: ./${{ matrix.browser }}-extension/
- name: Set up Node v20
if: ${{ matrix.browser == 'firefox' }}
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install web-ext
if: matrix.browser == 'firefox'
run: npm install -g web-ext
- name: Publish as Firefox add-on
if: ${{ matrix.browser == 'firefox' }}
env:
AMO_JWT_ISSUER: ${{ secrets.AMO_JWT_ISSUER }}
AMO_JWT_SECRET: ${{ secrets.AMO_JWT_SECRET }}
run: |
# sign the extension
web-ext sign \
--api-key="$AMO_JWT_ISSUER" \
--api-secret="$AMO_JWT_SECRET" \
--channel=listed \
--approval-timeout=0 \
--source-dir="./${{ matrix.browser }}-extension"
- name: Zip Chrome extension
if: ${{ matrix.browser == 'chrome' }}
run: |
zip -r ${{ matrix.browser }}-extension.zip ${{ matrix.browser }}-extension
- name: Publish to Chrome Web Store
if: ${{ matrix.browser == 'chrome' }}
uses: mnao305/chrome-extension-upload@v5.0.0
with:
file-path: ${{ matrix.browser }}-extension.zip
extension-id: ${{ secrets.EXTENSION_ID }}
client-id: ${{ secrets.CLIENT_ID }}
client-secret: ${{ secrets.CLIENT_SECRET }}
refresh-token: ${{ secrets.REFRESH_TOKEN }} # or "trustedTesters" for internal testing