feat: update to P2P indexer (#560) #244
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
name: Semantic Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
semantic_release: | |
# disallow reading code, should only need commit message | |
permissions: | |
contents: none | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout head | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Semantic Release | |
uses: cycjimmy/semantic-release-action@v4 | |
id: semantic | |
with: | |
# replace master branch with main as a release branch | |
# see https://github.com/semantic-release/semantic-release/issues/1581 | |
# note that branches may already be filtered by the triggers of this workflow | |
branches: | | |
[ | |
'+([0-9])?(.{+([0-9]),x}).x', | |
'main', | |
'next', | |
'next-major', | |
{ | |
name: 'beta', | |
prerelease: true | |
}, | |
{ | |
name: 'alpha', | |
prerelease: true | |
} | |
] | |
extra_plugins: | | |
@semantic-release/commit-analyzer@^11.0.0 | |
@semantic-release/release-notes-generator@^12.0.0 | |
@semantic-release/git@^10.0.1 | |
@semantic-release/changelog@^6.0.3 | |
@semantic-release/github@^9.0.6 | |
@semantic-release/npm@^11.0.0 | |
@semantic-release/exec@^6.0.3 | |
conventional-changelog-conventionalcommits@6 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Echo new release | |
if: steps.semantic.outputs.new_release_published == 'true' | |
run: echo ${{ steps.semantic.outputs.new_release_version }} | |
outputs: | |
new_release_published: ${{ steps.semantic.outputs.new_release_published }} # 'true' | 'false' | |
new_release_version: ${{ steps.semantic.outputs.new_release_version }} # eg. '1.0.0' | |
new_release_major_version: ${{ steps.semantic.outputs.new_release_major_version }} # eg '1' | |
new_release_minor_version: ${{ steps.semantic.outputs.new_release_minor_version }} # eg '0' | |
new_release_patch_version: ${{ steps.semantic.outputs.new_release_patch_version }} # eg '0' | |
build: | |
# deploy only if a new release was created | |
needs: semantic_release | |
if: needs.semantic_release.outputs.new_release_published == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# it is important to remove the default token credentials from git in this step | |
# otherwise they will get in the way of fetching the private TradingView dependency | |
persist-credentials: false | |
- name: Set Node version | |
# use basic regex (first found digits and dots) to get Node engine version from package.json | |
# will fail if not correctly specified | |
run: | | |
NODE_VERSION=$(node -p "require('./package.json').engines.node.match(/[\d.]+/)[0]") | |
echo "::set-output name=NODE_VERSION::$NODE_VERSION" | |
id: get-node-version | |
- name: Use Node.js ${{ steps.get-node-version.outputs.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ steps.get-node-version.outputs.NODE_VERSION }} | |
cache: npm | |
- name: Install dependencies | |
# note: from https://github.com/actions/setup-node/issues/49#issuecomment-1293249466 | |
# security consideration: | |
# Skip post-install scripts here, as a malicious script could steal NODE_AUTH_TOKEN. | |
# use variable to read in the exact chart library dependency specified in package.json | |
run: | | |
TVC_LOCATION=$( node -p "require('./package.json').dependencies['charting_library'].replace('github:','github.com/')" ); | |
npm install --ignore-scripts https://dib542:$TOKEN@$TVC_LOCATION | |
env: | |
# to install TradingView private dependency, private GitHub credentials are needed | |
# secret tokens are added in Github project settings under [project]/settings/secrets/actions | |
TOKEN: ${{ secrets.GH_TOKEN }} | |
# `npm rebuild` will run all those post-install scripts for us. | |
- name: Run post-install scripts | |
run: npm rebuild && npm run prepare --if-present | |
# run build with .env.testnet file (instead of .env.production) | |
# and add Netlify settings | |
- name: Build testnet | |
run: npm run build -- --mode testnet && cp netlify.toml build/netlify.toml | |
env: | |
REACT_APP__BUILD_NUMBER: ${{ github.run_id }} | |
REACT_APP__INDEXER_API_KEY: ${{ secrets.REACT_APP__INDEXER_API_KEY }} | |
- name: Deploy testnet to Netlify | |
id: netlify_deploy_testnet | |
# see: https://github.com/marketplace/actions/netlify-deploy | |
uses: jsmrcaga/action-netlify-deploy@v1.7.2 | |
with: | |
# secret tokens are added in Github project settings under [project]/settings/secrets/actions | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_TESTNET_SITE_ID }} | |
NETLIFY_DEPLOY_MESSAGE: 'Production deploy ${{ github.ref }}' # github.ref looks like `refs/pull/[PR#]/merge` | |
NETLIFY_DEPLOY_TO_PROD: true | |
build_directory: build | |
# we skip the build steps in this custom step because if we allow the project to build inside this step | |
# and specify the node version for that, this action will first download the latest node version, | |
# then switch back to the specified node version, then build the project. | |
# this wastes build minutes, so we instead pre-build the "build" folder | |
build_command: echo "already built app" | |
install_command: echo "already installed dependencies" | |
- name: Clear build folder | |
run: rm -rf build | |
# run build with .env.beta file (instead of .env.production) | |
# and add Netlify settings | |
- name: Build beta | |
run: npm run build -- --mode beta && cp netlify.toml build/netlify.toml | |
env: | |
REACT_APP__BUILD_NUMBER: ${{ github.run_id }} | |
REACT_APP__INDEXER_API_KEY: ${{ secrets.REACT_APP__INDEXER_API_KEY }} | |
- name: Deploy beta to Netlify | |
id: netlify_deploy_beta | |
# see: https://github.com/marketplace/actions/netlify-deploy | |
uses: jsmrcaga/action-netlify-deploy@v1.7.2 | |
with: | |
# secret tokens are added in Github project settings under [project]/settings/secrets/actions | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_BETA_SITE_ID }} | |
NETLIFY_DEPLOY_MESSAGE: 'Production deploy ${{ github.ref }}' # github.ref looks like `refs/pull/[PR#]/merge` | |
NETLIFY_DEPLOY_TO_PROD: true | |
build_directory: build | |
# we skip the build steps in this custom step because if we allow the project to build inside this step | |
# and specify the node version for that, this action will first download the latest node version, | |
# then switch back to the specified node version, then build the project. | |
# this wastes build minutes, so we instead pre-build the "build" folder | |
build_command: echo "already built app" | |
install_command: echo "already installed dependencies" |