CI/CD for Chrome Extension #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD for Chrome Extension | |
on: | |
push: | |
tags: | |
- '*' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: self-hosted | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Cleanup | |
run: | | |
rm output -rf | |
- name: Zip the extension | |
run: | | |
mkdir output | |
VERSION=$(jq -r '.version' ./app/manifest.json) | |
zip -r ./output/ShaderToy-Chrome-Plugin-$VERSION.zip ./app | |
echo $VERSION >> ./output/version.txt | |
- name: Upload output as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: output | |
path: output/ | |
publish: | |
runs-on: self-hosted | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Download output artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: output | |
- name: Install Dependencies for Publishing | |
run: | | |
npm install -g chrome-webstore-upload-cli | |
- name: Upload & Publish Extension to Chrome Store | |
run: | | |
VERSION=$(cat ./output/version.txt) | |
chrome-webstore-upload upload \\ | |
--source ./output/ShaderToy-Chrome-Plugin-$VERSION.zip \\ | |
--extension-id $APP_ID \\ | |
--client-id $CLIENT_ID \\ | |
--client-secret $CLIENT_SECRET \\ | |
--refresh-token $REFRESH_TOKEN | |
release: | |
runs-on: self-hosted | |
needs: build | |
steps: | |
- name: Download output artifact for release | |
uses: actions/download-artifact@v4 | |
with: | |
name: output | |
- name: Publish Release on GitHub | |
run: | | |
VERSION=$(cat ./output/version.txt) | |
echo "GITHUB_TOKEN" | |
echo $GITHUB_TOKEN | |
gh release create $VERSION ./output/ShaderToy-Chrome-Plugin-$VERSION.zip --title "$VERSION" --notes "Release of version $VERSION" |