Skip to content

Commit

Permalink
build: add auto build
Browse files Browse the repository at this point in the history
  • Loading branch information
slient-coder committed May 26, 2023
1 parent 53d0f90 commit f0af0dd
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Setup
runs:
using: composite
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org
cache: yarn

- uses: actions/cache@v3
id: install-cache
with:
path: node_modules/
key: ${{ runner.os }}-install-${{ hashFiles('**/yarn.lock') }}

- if: steps.install-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile --ignore-scripts
shell: bash

- uses: gradle/gradle-build-action@v2
64 changes: 64 additions & 0 deletions .github/workflows/auto_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Create Release

on:
push:
tags:
- v*
pull_request:
tags:
- v*

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- uses: ./.github/actions/setup

- name: Build Chrome
run: |
yarn build:chrome
yarn build:chrome:mv3
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Get Version Name
uses: actions/github-script@v3
id: get-version
with:
script: |
const str=process.env.GITHUB_REF;
return str.substring(str.indexOf("v"));
result-encoding: string

- name: Upload Asset
id: upload-asset1
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/unisat-chrome-mv2-${{steps.get-version.outputs.result}}.zip
asset_name: unisat-chrome-mv2-${{steps.get-version.outputs.result}}.zip
asset_content_type: application/zip

- name: Upload Asset
id: upload-asset2
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/unisat-chrome-mv3-${{steps.get-version.outputs.result}}.zip
asset_name: unisat-chrome-mv3-${{steps.get-version.outputs.result}}.zip
asset_content_type: application/zip
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var knownOptions = {
env: 'dev',
browser: 'chrome',
manifest: 'mv3',
channel: 'chrome'
channel: 'store'
}
};

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"build:firefox": "gulp build --env=pro --browser=firefox --manifest=mv2 --channel=github",
"build:brave": "gulp build --env=pro --browser=brave --manifest=mv2 --channel=github",
"build:edge": "gulp build --env=pro --browser=edge --manifest=mv2 --channel=github",
"build:chrome:mv3": "gulp build --env=pro --browser=chrome --manifest=mv3 --channel=chrome",
"build:chrome:mv3:dev": "webpack --progress --env browser=chrome manifest=mv3 config=dev channel=github version=0.0.0",
"build:chrome:mv3": "gulp build --env=pro --browser=chrome --manifest=mv3 --channel=store",
"translate": "node build/pull_translation",
"lint": "eslint src --fix --ext .js,.ts,.tsx,.json && npm run format",
"lint:fix": "eslint --fix src/**/*.{js,jsx,ts,tsx,json}",
Expand Down

0 comments on commit f0af0dd

Please sign in to comment.