Skip to content

Commit 10b9b99

Browse files
committed
feat(ci): adds github release, npm publish and store upload
1 parent c641983 commit 10b9b99

File tree

4 files changed

+93
-10
lines changed

4 files changed

+93
-10
lines changed

.github/actions/build/action.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Build
22
description: Install and build the repo
33

44
inputs:
5+
script:
6+
description: Build script
7+
default: 'build'
8+
59
node_version:
610
description: Pnpm version to use
711
required: true
@@ -20,7 +24,7 @@ runs:
2024
- name: Setup Node.js ${{ inputs.node_version }}
2125
uses: actions/setup-node@v3
2226
with:
23-
node-version: ${{ env.node_version }}
27+
node-version: ${{ inputs.node_version }}
2428
registry-url: 'https://registry.npmjs.org'
2529
cache: pnpm
2630

@@ -36,4 +40,4 @@ runs:
3640
run: |
3741
# ================= Build =================
3842
39-
pnpm run build
43+
pnpm run ${{ inputs.script }}·

.github/workflows/build.yml

+32-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
pnpm_version: 8.x
1818

1919
jobs:
20-
release:
20+
build-extension:
2121
name: Build
2222
runs-on: ubuntu-latest
2323

@@ -31,12 +31,43 @@ jobs:
3131
node_version: ${{ env.node_version }}
3232
pnpm_version: ${{ env.pnpm_version }}
3333

34+
build-web:
35+
name: Build
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: Checkout branch ${{ github.ref }}
40+
uses: actions/checkout@v3
41+
42+
- name: Build
43+
uses: ./.github/actions/build
44+
with:
45+
script: 'build:web'
46+
node_version: ${{ env.node_version }}
47+
pnpm_version: ${{ env.pnpm_version }}
48+
49+
test:
50+
name: Build
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- name: Checkout branch ${{ github.ref }}
55+
uses: actions/checkout@v3
56+
3457
- name: Test
3558
run: |
3659
# ================= Test =================
3760
3861
pnpm run test:unit
3962
63+
lint:
64+
name: Build
65+
runs-on: ubuntu-latest
66+
67+
steps:
68+
- name: Checkout branch ${{ github.ref }}
69+
uses: actions/checkout@v3
70+
4071
- name: Eslint
4172
run: |
4273
# ================= Eslint =================

.github/workflows/deploy.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ jobs:
4040
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
4141
uses: actions/checkout@v3
4242

43-
- name: Build
43+
- name: Build·
4444
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
4545
uses: ./.github/actions/build
4646
with:
47+
script: 'build:web'
4748
node_version: ${{ env.node_version }}
4849
pnpm_version: ${{ env.pnpm_version }}
4950

.github/workflows/publish.yml

+53-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020
pnpm_version: 8.x
2121

2222
jobs:
23-
publish:
23+
publish-npm:
2424
name: Github release and npm publish
2525
runs-on: ubuntu-latest
2626

@@ -34,6 +34,7 @@ jobs:
3434
- name: Build
3535
uses: ./.github/actions/build
3636
with:
37+
script: 'build:web'
3738
node_version: ${{ env.node_version }}
3839
pnpm_version: ${{ env.pnpm_version }}
3940

@@ -46,6 +47,44 @@ jobs:
4647
env:
4748
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4849

50+
- uses: actions/cache/save@v3
51+
id: cache
52+
with:
53+
path: dist
54+
key: ${{ github.ref }}-${{ github.run_id }}-build
55+
56+
57+
publish-store:
58+
name: Publish extension
59+
runs-on: ubuntu-latest
60+
if: ${{ github.event.workflow_run.conclusion != 'failure' }}
61+
62+
steps:
63+
- name: Checkout branch ${{ github.ref }}
64+
uses: actions/checkout@v3
65+
with:
66+
fetch-depth: 0
67+
68+
- name: Build
69+
uses: ./.github/actions/build
70+
with:
71+
script: 'build'
72+
node_version: ${{ env.node_version }}
73+
pnpm_version: ${{ env.pnpm_version }}
74+
75+
- name: Zip build folder
76+
run: |
77+
# ================= Zipping build folder =================
78+
79+
# Zipping dist folder for artifact upload
80+
cd dist;
81+
zip -r trakt-extension.zip *
82+
83+
# Check zip created
84+
echo "Zip created in 'dist/'"
85+
ls -l trakt-extension.zip
86+
cd ..
87+
4988
- name: Generate Release changelog
5089
run: |
5190
# ================= Changelog =================
@@ -67,9 +106,17 @@ jobs:
67106
with:
68107
tag_name: ${{ github.event.inputs.tag-name || steps.latest-tag.outputs.TAG_NAME }}
69108
body_path: RELEASE.md
109+
files: dist/trakt-extension.zip
70110

71-
- uses: actions/cache/save@v3
72-
id: cache
73-
with:
74-
path: dist
75-
key: ${{ github.ref }}-${{ github.run_id }}-build
111+
- name: Publish to Chrome Webstore
112+
env:
113+
CHROME_WEB_STORE_EXTENSION_ID: pdodapikbijcfickiofjkjgkkmlcnbba
114+
CHROME_WEB_STORE_CLIENT_ID: ${{ secrets.CHROME_WEB_STORE_CLIENT_ID }}
115+
CHROME_WEB_STORE_CLIENT_SECRET: ${{ secrets.CHROME_WEB_STORE_CLIENT_SECRET }}
116+
CHROME_WEB_STORE_REFRESH_TOKEN: ${{ secrets.CHROME_WEB_STORE_REFRESH_TOKEN }}
117+
run: |
118+
# ================= Publish to Chrome store =================
119+
120+
# Uploading zip to web store
121+
yarn dlx -q chrome-webstore-upload-cli upload --source dist/trakt-extension.zip --extension-id "$CHROME_WEB_STORE_EXTENSION_ID" --client-id "$CHROME_WEB_STORE_CLIENT_ID" --client-secret "$CHROME_WEB_STORE_CLIENT_SECRET" --refresh-token "$CHROME_WEB_STORE_REFRESH_TOKEN"
122+

0 commit comments

Comments
 (0)