Merge pull request #4 #9
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: Build and Publish | |
on: | |
push: | |
branches: | |
- 'master' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: '16.x' | |
- name: Install dependencies | |
run: npm install | |
- name: Build extension | |
run: npm run build | |
# pack zip and read manifest, can be reused in the following steps | |
- id: packExtensionDir | |
uses: cardinalby/webext-buildtools-pack-extension-dir-action@v1 | |
with: | |
extensionDir: './build' | |
zipFilePath: './compressed/extension.zip' | |
- uses: cardinalby/webext-buildtools-chrome-crx-action@v2 | |
with: | |
# zip file made at the packExtensionDir step | |
zipFilePath: './compressed/extension.zip' | |
crxFilePath: './compressed/extension.crx' | |
privateKey: ${{ secrets.CHROME_CRX_PRIVATE_KEY }} | |
# Get version from manifest file (replace with your file name and parsing) | |
- name: Get version from manifest | |
id: get_version | |
run: | | |
VERSION=$(grep -o '"version": *"[^"]*"' ./build/manifest.json | grep -o '"[^"]*"$' | tr -d '"') | |
echo "::set-output name=version::$VERSION" | |
# Create a release with the version from the manifest | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ steps.get_version.outputs.version }} | |
release_name: Release ${{ steps.get_version.outputs.version }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.WORKFLOWS_TOKEN }} # Use the secret here | |
# Upload assets (ZIP and CRX) to the release | |
- name: Upload ZIP file | |
id: upload_assets | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./compressed/extension.zip # Replace with your ZIP file path | |
asset_name: extension-${{ steps.get_version.outputs.version }}.zip | |
asset_content_type: application/zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.WORKFLOWS_TOKEN }} # Use the secret here | |
- name: Upload CRX file | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./compressed/extension.crx # Replace with your CRX file path | |
asset_name: extension-${{ steps.get_version.outputs.version }}.crx | |
asset_content_type: application/octet-stream # Adjust content type if needed | |
env: | |
GITHUB_TOKEN: ${{ secrets.WORKFLOWS_TOKEN }} # Use the secret here |