Skip to content

Commit

Permalink
refactor: build job
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Oct 10, 2023
1 parent f26c5fe commit 917a00b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 68 deletions.
91 changes: 24 additions & 67 deletions .github/workflows/build-extension.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
name: PR Extensions builds
on: [pull_request, workflow_dispatch]

env:
COINBASE_APP_ID: ${{ secrets.COINBASE_APP_ID }}
MOONPAY_API_KEY: ${{ secrets.MOONPAY_API_KEY }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_STAGING }}
TRANSAK_API_KEY: ${{ secrets.TRANSAK_API_KEY }}
PR_NUMBER: ${{ github.event.number }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
WALLET_ENVIRONMENT: feature

jobs:
pre-run:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@ad6cb1b847ffb509a69b745b6ee2f1d14dfe14b8
uses: styfle/cancel-workflow-action@main
with:
access_token: ${{ github.token }}

build-in-progress-message:
name:
set-in-progress-message:
if: github.repository == 'leather-wallet/extension' && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
needs:
Expand All @@ -32,81 +21,49 @@ jobs:
header: '> _Building Leather…_'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-chromium:
name: Build debug Chrome extension
build:
name: build-${{ matrix.target }}-extension
runs-on: ubuntu-latest
needs:
- pre-run
strategy:
matrix:
target: [chromium, firefox]
env:
WALLET_ENVIRONMENT: feature
TARGET_BROWSER: ${{ matrix.target }}
COINBASE_APP_ID: ${{ secrets.COINBASE_APP_ID }}
MOONPAY_API_KEY: ${{ secrets.MOONPAY_API_KEY }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_STAGING }}
TRANSAK_API_KEY: ${{ secrets.TRANSAK_API_KEY }}
PR_NUMBER: ${{ github.event.number }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

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

- uses: ./.github/actions/provision

- run: echo ${{ github.event.pull_request.head.sha }}
- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV

- name: Build project
run: yarn build

- name: Build extension
run: sh build-ext.sh

- uses: actions/upload-artifact@v3
name: Upload Chrome Extension Zip
with:
name: leather-chromium
path: leather-chromium.zip

build-firefox:
name: Build debug Firefox extension
runs-on: ubuntu-latest
needs:
- pre-run
env:
TARGET_BROWSER: firefox
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

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

- uses: ./.github/actions/provision

- name: Build project
run: yarn build

- name: Build extension
run: sh build-ext.sh

- name: Rename file
run: mv leather-chromium.zip leather-firefox.zip

- uses: actions/upload-artifact@v3
name: Upload ${{ matrix.target }} Extension Zip
with:
name: leather-firefox
path: leather-firefox.zip
name: leather-${{ matrix.target }}-${{ env.SHORT_SHA }}
path: dist

add-download-link:
name: Add link to built extensions
set-download-link:
if: github.repository == 'leather-wallet/extension' && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
needs:
- pre-run
- build-chromium
- build-firefox
- build
steps:
- uses: kyranjamie/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@ad6cb1b847ffb509a69b745b6ee2f1d14dfe14b8
uses: styfle/cancel-workflow-action@main
with:
access_token: ${{ github.token }}

Expand Down

0 comments on commit 917a00b

Please sign in to comment.