Skip to content

Added frontend changes #9

Added frontend changes

Added frontend changes #9

# Actions that run when opening or updating pull requests, as well
# as when merging them into master or pushing code directly to master
name: Pull Requests and Merges
on:
pull_request:
types: [opened, synchronize]
branches:
- master
push:
branches:
- master
jobs:
tests:
runs-on: ubuntu-latest
name: Build and run tests
env:
RELEASE_PREFIX: "0.5.2"
steps:
##########################################################################
# Setup environment.
##########################################################################
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/cache@v3
name: yarn-cache
id: yarn-cache
with:
path: |
**/node_modules
${{ steps.yarn-cache-dir-path.outputs.dir }}
!**/node_modules/.cache
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn
##########################################################################
# Yarn install.
##########################################################################
- name: yarn install
run: yarn install --frozen-lockfile
##########################################################################
# Build extension.
##########################################################################
#
# Build the extension, beta release.
#
- name: "build beta"
env:
BACKPACK_CONFIG_VERSION: "${{ env.RELEASE_PREFIX }}-latest-beta-${{ github.run_number }}"
BACKPACK_CONFIG_GITHUB_RUN_NUMBER: "${{ github.run_number }}"
BACKPACK_CONFIG_LOG_LEVEL: "info"
BACKPACK_FEATURE_LIGHT_MODE: "true"
BACKPACK_FEATURE_POP_MODE: "true"
BACKPACK_FEATURE_XNFT: "true"
BACKPACK_FEATURE_FORCE_LATEST_VERSION: "true"
# CI!=true so that build warnings aren't treated like errors (for now)
CI: ""
run: yarn build
- name: "rename beta build"
working-directory: packages/app-extension
run: mv build build-beta
##########################################################################
# Yarn test.
##########################################################################
- run: yarn test
##########################################################################
# GitHub Pages (mobile app and hardware wallet support)
##########################################################################
- name: Build background-service-worker.html
run: cd packages/background && yarn build:html
- if: github.event_name == 'pull_request'
name: "set env.commit_sha from latest commit in PR"
run: echo "commit_sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- if: github.event_name == 'push'
name: "set env.commit_sha from commit or merge commit"
run: echo "commit_sha=${{ github.sha }}" >> $GITHUB_ENV
- name: "set env.short_sha"
run: echo "short_sha=`echo "${{ env.commit_sha }}" | cut -c1-7`" >> $GITHUB_ENV
- name: (Github Pages) Deploy background-service-worker.html
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
publish_dir: packages/background/build
github_token: ${{ secrets.GITHUB_TOKEN }}
destination_dir: "background-scripts/${{ env.short_sha }}"
- name: (Github Pages) Deploy ledger injection
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
publish_dir: packages/ledger-injection/dist
deploy_key: ${{ secrets.LEDGER_INJECTION_DEPLOY_KEY }}
external_repository: coral-xyz/ledger-injection
##########################################################################
# Upload build artifacts.
##########################################################################
#
# Upload beta artifact.
#
- name: "zip beta build artifacts"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
working-directory: packages/app-extension
run: zip -r build-beta-${{ github.run_number }}.zip build-beta/
- name: "upload build artifacts"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v2
with:
name: backpack-build-beta
path: packages/app-extension/build-beta-${{ github.run_number }}.zip
##########################################################################
# Release.
##########################################################################
#
# TODO: the master branch conditionson all these are bit hacky. Probably
# a cleaner way of doing this.
#
#
# Download artifacts.
#
- uses: actions/download-artifact@v2
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
name: backpack-build-beta
path: ./
#
# Create release.
#
- uses: actions/create-release@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
name: Create Draft Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_PREFIX }}-latest-${{ github.run_number }}
release_name: ${{ env.RELEASE_PREFIX }}-latest-${{ github.run_number }}
draft: false
prerelease: false
#
# Attach files to the release.
#
- uses: actions/[email protected]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build-beta-${{ github.run_number }}.zip
asset_name: build-beta-${{ github.run_number }}.zip
asset_content_type: application/zip
##########################################################################
# NPM Publish.
##########################################################################
- name: "update npm package version"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: ./scripts/npm_release.sh ${{ env.RELEASE_PREFIX }}-latest.${{ github.run_number }}
- name: "publish to npm: common"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_ACCESS_TOKEN }}
tag: latest
package: packages/common/package.json
- name: "publish to npm: themes"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_ACCESS_TOKEN }}
tag: latest
package: packages/themes/package.json
- name: "publish to npm: @coral-xyz/xnft-cli"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_ACCESS_TOKEN }}
tag: latest
package: packages/xnft-cli/package.json
- name: "change @coral-xyz/xnft-cli package name to xnft"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: sed -i 's/"@coral-xyz\/xnft-cli"/"xnft"/g' packages/xnft-cli/package.json
- name: "publish to npm: xnft"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_ACCESS_TOKEN }}
tag: latest
package: packages/xnft-cli/package.json
- name: "publish to npm: chat-sdk"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_ACCESS_TOKEN }}
tag: latest
package: packages/chat-sdk/package.json