This repository was archived by the owner on Aug 4, 2026. It is now read-only.
Repository navigation
105 lines (94 loc) · 4.16 KB
/
Copy pathrelease.yml
File metadata and controls
105 lines (94 loc) · 4.16 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
name: Release Extension
# Manual release: bump the version in manifest.json, merge to develop, then
# run this workflow from the Actions tab. It packages the extension, tags
# the commit, attaches the zip to a GitHub Release, and uploads (optionally
# publishes) the build to the Chrome Web Store.
#
# Required repo secrets for the Chrome Web Store step:
# CWS_EXTENSION_ID — the extension's ID on the Web Store
# CWS_CLIENT_ID — OAuth client ID with chromewebstore scope
# CWS_CLIENT_SECRET — matching client secret
# CWS_REFRESH_TOKEN — long-lived refresh token for the publisher account
# See https://github.com/fregante/chrome-webstore-upload-cli#authentication
on:
workflow_dispatch:
inputs:
publish_cws:
description: "Publish on the Chrome Web Store after upload (uncheck to upload a draft only)"
type: boolean
default: true
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # for tag push + GitHub Release creation
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0 # need history so the tag check below sees existing tags
- name: Read manifest version
id: ver
run: |
VERSION=$(awk -F'"' '/"version"[[:space:]]*:/ { print $4; exit }' manifest.json)
if [[ -z "$VERSION" ]]; then
echo "::error::Could not parse version from manifest.json"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
echo "zip=dist/vp-cloud-chrome-ext-$VERSION.zip" >> "$GITHUB_OUTPUT"
- name: Verify tag does not already exist
run: |
if git rev-parse -q --verify "refs/tags/${{ steps.ver.outputs.tag }}" >/dev/null; then
echo "::error::Tag ${{ steps.ver.outputs.tag }} already exists. Bump manifest.json before releasing."
exit 1
fi
- name: Package extension
run: bash scripts/package-extension.sh
- name: Create and push tag
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.ver.outputs.tag }}" -m "Release ${{ steps.ver.outputs.tag }}"
git push origin "${{ steps.ver.outputs.tag }}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.ver.outputs.tag }}
name: ${{ steps.ver.outputs.tag }}
generate_release_notes: true
files: ${{ steps.ver.outputs.zip }}
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: "20"
- name: Upload to Chrome Web Store
env:
CWS_EXTENSION_ID: ${{ secrets.CWS_EXTENSION_ID }}
CWS_CLIENT_ID: ${{ secrets.CWS_CLIENT_ID }}
CWS_CLIENT_SECRET: ${{ secrets.CWS_CLIENT_SECRET }}
CWS_REFRESH_TOKEN: ${{ secrets.CWS_REFRESH_TOKEN }}
run: |
npx --yes chrome-webstore-upload-cli@3 upload \
--source "${{ steps.ver.outputs.zip }}" \
--extension-id "$CWS_EXTENSION_ID" \
--client-id "$CWS_CLIENT_ID" \
--client-secret "$CWS_CLIENT_SECRET" \
--refresh-token "$CWS_REFRESH_TOKEN"
# Publishes to the default ("public") channel. The item's visibility is
# set to Unlisted on the Web Store dashboard, so this publishes a public
# but unlisted listing (installable via direct link, not surfaced in search).
- name: Publish on Chrome Web Store
if: ${{ inputs.publish_cws }}
env:
CWS_EXTENSION_ID: ${{ secrets.CWS_EXTENSION_ID }}
CWS_CLIENT_ID: ${{ secrets.CWS_CLIENT_ID }}
CWS_CLIENT_SECRET: ${{ secrets.CWS_CLIENT_SECRET }}
CWS_REFRESH_TOKEN: ${{ secrets.CWS_REFRESH_TOKEN }}
run: |
npx --yes chrome-webstore-upload-cli@3 publish \
--extension-id "$CWS_EXTENSION_ID" \
--client-id "$CWS_CLIENT_ID" \
--client-secret "$CWS_CLIENT_SECRET" \
--refresh-token "$CWS_REFRESH_TOKEN"