Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/sciooga/v2ex-plus
- Loading branch information
Showing
12 changed files
with
590 additions
and
139 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Assumes that: | ||
# 1. the following env variables are set: | ||
# - ZIP_FILE_PATH | ||
# - EXTENSION_DIR | ||
# 2. repository checked out | ||
# Effects: | ||
# - builds and tests an extension, fails on error | ||
# - packed extension.zip saved to env.ZIP_FILE_PATH if inputs.doNotPackZip == 'false' | ||
|
||
name: "Build, test and pack WebExtension" | ||
description: "Builds, tests, and packs extension dir into zip file" | ||
|
||
inputs: | ||
doNotPackZip: | ||
description: 'Set `true` to omit pack step' | ||
required: false | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
# Add additional build and test steps here | ||
|
||
- name: Validate manifest.json of the extension | ||
uses: cardinalby/schema-validator-action@v1 | ||
with: | ||
file: ${{ env.EXTENSION_DIR }}manifest.json | ||
schema: 'https://json.schemastore.org/webextension.json' | ||
|
||
- name: Pack directory to zip | ||
if: inputs.doNotPackZip != 'true' | ||
uses: cardinalby/webext-buildtools-pack-extension-dir-action@v1 | ||
with: | ||
extensionDir: ${{ env.EXTENSION_DIR }} | ||
zipFilePath: ${{ env.ZIP_FILE_PATH }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Assumes that: | ||
# 1. the following env variables are set: | ||
# - ZIP_ASSET_NAME | ||
# - ZIP_FILE_PATH | ||
# - ZIP_FILE_NAME | ||
# - EXTENSION_DIR | ||
# 2. repository checked out | ||
# Effects: | ||
# - extension.zip saved to env.ZIP_FILE_PATH | ||
# - outputs.releaseUploadUrl is set if ref_type == 'tag' and release exists | ||
# - extension.zip uploaded as build artifact to the job if it wasn't found in release | ||
|
||
name: "Obtain extension.zip asset" | ||
description: "Downloads zip asset from a release (if exists) or builds it from the scratch" | ||
inputs: | ||
githubToken: | ||
description: GitHub token | ||
required: true | ||
outputs: | ||
releaseUploadUrl: | ||
description: Release upload url, if exists | ||
value: ${{ steps.getRelease.outputs.upload_url }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Get release | ||
id: getRelease | ||
if: github.ref_type == 'tag' | ||
uses: cardinalby/git-get-release-action@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.githubToken }} | ||
with: | ||
tag: ${{ github.ref_name }} | ||
doNotFailIfNotFound: true | ||
|
||
- name: Find out zip asset id from assets JSON | ||
if: steps.getRelease.outputs.assets | ||
id: readAssetIdFromRelease | ||
uses: cardinalby/js-eval-action@v1 | ||
env: | ||
ASSETS_JSON: ${{ steps.getRelease.outputs.assets }} | ||
ASSET_NAME: ${{ env.ZIP_ASSET_NAME }} | ||
with: | ||
expression: | | ||
JSON.parse(env.ASSETS_JSON) | ||
.find(asset => asset.name == env.ZIP_ASSET_NAME)?.id || '' | ||
- name: Download found zip release asset | ||
id: downloadZipAsset | ||
if: steps.readAssetIdFromRelease.outputs.result | ||
uses: cardinalby/download-release-asset-action@v1 | ||
with: | ||
token: ${{ inputs.githubToken }} | ||
assetId: ${{ steps.readAssetIdFromRelease.outputs.result }} | ||
targetPath: ${{ env.ZIP_FILE_PATH }} | ||
|
||
- name: Build and pack zip | ||
id: buildZip | ||
if: steps.downloadZipAsset.outcome != 'success' | ||
uses: ./.github/workflows/actions/build-test-pack | ||
|
||
- name: Upload zip file artifact | ||
if: steps.buildZip.outcome == 'success' | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ env.ZIP_FILE_NAME }} | ||
path: ${{ env.ZIP_FILE_PATH }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Build and test | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- 'master' | ||
- 'develop' | ||
workflow_dispatch: | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: cardinalby/export-env-action@v1 | ||
with: | ||
envFile: './.github/workflows/constants.env' | ||
expand: true | ||
|
||
- name: Build, test and pack to zip | ||
id: build | ||
uses: ./.github/workflows/actions/build-test-pack | ||
with: | ||
# pack zip only for pull requests or workflow_dispatch events | ||
doNotPackZip: ${{ github.event_name == 'push' && 'true' || 'false'}} | ||
|
||
- name: Upload zip file artifact | ||
if: github.event_name != 'push' | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ env.ZIP_FILE_NAME }} | ||
path: ${{ env.ZIP_FILE_PATH }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# On release published: | ||
# - if no built extension.zip asset attached to release, does that | ||
# - builds and attaches signed crx asset to release | ||
# - builds and attaches signed xpi asset to release | ||
name: Build release assets | ||
|
||
on: | ||
release: | ||
# Creating draft releases will not trigger it | ||
types: [published] | ||
jobs: | ||
# Find out asset id of existing extension.zip asset in a release or | ||
# build and attach it to the release and use its asset id | ||
ensure-zip: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
zipAssetId: | | ||
${{ steps.getZipAssetId.outputs.result || | ||
steps.uploadZipAsset.outputs.id }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: cardinalby/export-env-action@v1 | ||
with: | ||
envFile: './.github/workflows/constants.env' | ||
expand: true | ||
|
||
- name: Find out "extension.zip" asset id from the release | ||
id: getZipAssetId | ||
uses: cardinalby/js-eval-action@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ASSETS_URL: ${{ github.event.release.assets_url }} | ||
ASSET_NAME: ${{ env.ZIP_FILE_NAME }} | ||
with: | ||
expression: | | ||
(await octokit.request("GET " + env.ASSETS_URL)).data | ||
.find(asset => asset.name == env.ASSET_NAME)?.id || '' | ||
- name: Build, test and pack | ||
if: '!steps.getZipAssetId.outputs.result' | ||
id: buildPack | ||
uses: ./.github/workflows/actions/build-test-pack | ||
|
||
- name: Upload "extension.zip" asset to the release | ||
id: uploadZipAsset | ||
if: '!steps.getZipAssetId.outputs.result' | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ${{ env.ZIP_FILE_PATH }} | ||
asset_name: ${{ env.ZIP_FILE_NAME }} | ||
asset_content_type: application/zip | ||
|
||
build-signed-crx-asset: | ||
needs: ensure-zip | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: cardinalby/export-env-action@v1 | ||
with: | ||
envFile: './.github/workflows/constants.env' | ||
expand: true | ||
|
||
- name: Download zip release asset | ||
uses: cardinalby/download-release-asset-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
assetId: ${{ needs.ensure-zip.outputs.zipAssetId }} | ||
targetPath: ${{ env.ZIP_FILE_PATH }} | ||
|
||
- name: Build offline crx | ||
id: buildOfflineCrx | ||
uses: cardinalby/webext-buildtools-chrome-crx-action@v2 | ||
with: | ||
zipFilePath: ${{ env.ZIP_FILE_PATH }} | ||
crxFilePath: ${{ env.OFFLINE_CRX_FILE_PATH }} | ||
privateKey: ${{ secrets.CHROME_CRX_PRIVATE_KEY }} | ||
|
||
- name: Upload offline crx release asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ${{ env.OFFLINE_CRX_FILE_PATH }} | ||
asset_name: ${{ env.OFFLINE_CRX_FILE_NAME }} | ||
asset_content_type: application/x-chrome-extension | ||
|
||
build-signed-xpi-asset: | ||
needs: ensure-zip | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: cardinalby/export-env-action@v1 | ||
with: | ||
envFile: './.github/workflows/constants.env' | ||
expand: true | ||
|
||
- name: Download zip release asset | ||
uses: cardinalby/download-release-asset-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
assetId: ${{ needs.ensure-zip.outputs.zipAssetId }} | ||
targetPath: ${{ env.ZIP_FILE_PATH }} | ||
|
||
- name: Sign Firefox xpi for offline distribution | ||
id: ffSignXpi | ||
continue-on-error: true | ||
uses: cardinalby/webext-buildtools-firefox-sign-xpi-action@v1 | ||
with: | ||
timeoutMs: 1200000 | ||
extensionId: ${{ secrets.FF_OFFLINE_EXT_ID }} | ||
zipFilePath: ${{ env.ZIP_FILE_PATH }} | ||
xpiFilePath: ${{ env.XPI_FILE_PATH }} | ||
jwtIssuer: ${{ secrets.FF_JWT_ISSUER }} | ||
jwtSecret: ${{ secrets.FF_JWT_SECRET }} | ||
|
||
- name: Abort on sign error | ||
if: | | ||
steps.ffSignXpi.outcome == 'failure' && | ||
steps.ffSignXpi.outputs.sameVersionAlreadyUploadedError != 'true' | ||
run: exit 1 | ||
|
||
- name: Upload offline xpi release asset | ||
if: steps.ffSignXpi.outcome == 'success' | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ${{ env.XPI_FILE_PATH }} | ||
asset_name: ${{ env.XPI_FILE_NAME }} | ||
asset_content_type: application/x-xpinstall |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
EXTENSION_DIR=./ | ||
BUILD_DIR=build/ | ||
|
||
ZIP_FILE_NAME=extension.zip | ||
ZIP_FILE_PATH=${BUILD_DIR}${ZIP_FILE_NAME} | ||
|
||
WEBSTORE_CRX_FILE_NAME=extension.webstore.crx | ||
WEBSTORE_CRX_FILE_PATH=${BUILD_DIR}${WEBSTORE_CRX_FILE_NAME} | ||
|
||
OFFLINE_CRX_FILE_NAME=extension.offline.crx | ||
OFFLINE_CRX_FILE_PATH=${BUILD_DIR}${OFFLINE_CRX_FILE_NAME} | ||
|
||
XPI_FILE_NAME=extension.offline.xpi | ||
XPI_FILE_PATH=${BUILD_DIR}${XPI_FILE_NAME} | ||
|
||
|
Oops, something went wrong.