-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (60 loc) · 2.49 KB
/
build-and-publish.yml
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
name: Build and Publish
on:
push:
branches:
- 'master'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
# 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": *"[^"]*"' ./extension/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