Release - Mainnet #59
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: Release - Mainnet | |
on: | |
workflow_dispatch: | |
inputs: | |
bumpType: | |
description: 'Bump version' | |
required: true | |
default: 'patch' | |
type: choice | |
options: | |
- 'patch' | |
- 'minor' | |
- 'major' | |
jobs: | |
bump: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'yarn' | |
- name: Automated Version Bump | |
uses: phips28/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} | |
with: | |
version-type: ${{ inputs.bumpType }} | |
tag-prefix: 'v' | |
target-branch: 'main' | |
commit-message: 'CI: bumps version to {{version}}' | |
bump-policy: 'last-commit' | |
cleanup: | |
runs-on: ubuntu-latest | |
needs: [bump] | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Cleanup | |
run: | | |
gh extension install actions/gh-actions-cache | |
REPO=${{ github.repository }} | |
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" | |
echo "Fetching list of cache key" | |
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 ) | |
## Setting this to not fail the workflow while deleting cache keys. | |
set +e | |
echo "Deleting caches..." | |
for cacheKey in $cacheKeysForPR | |
do | |
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm | |
done | |
echo "Done" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
sentry-release: | |
runs-on: ubuntu-latest | |
needs: [ cleanup ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'yarn' | |
- name: Install Dependencies | |
run: | | |
export NODE_OPTIONS=--max_old_space_size=8192 | |
yarn install --immutable | |
- name: Build Project for Sentry | |
run: yarn build-with-source-maps | |
env: | |
CI: false | |
RELEASE_TYPE: 'PRODUCTION' | |
GENERATE_SOURCEMAPS: true | |
NODE_OPTIONS: '--max-old-space-size=4096' | |
- name: Get package info | |
id: package | |
uses: codex-team/[email protected] | |
- name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
with: | |
environment: production | |
sourcemaps: "./dist" | |
version: ${{ steps.package.outputs.version }} | |
url_prefix: '~' | |
build: | |
runs-on: ubuntu-latest | |
needs: [cleanup] | |
environment: | |
name: mainnet | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Build Project | |
run: yarn production-build | |
env: | |
CI: false | |
RELEASE_TYPE: 'PRODUCTION' | |
- name: Configure AWS | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets[format('AWS_ACCESS_KEY_ID_{0}', 'PRODUCTION')] }} | |
aws-secret-access-key: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', 'PRODUCTION')] }} | |
aws-region: us-east-1 | |
- name: Deploy app build to S3 bucket | |
run: aws s3 sync ./dist/ s3://$BUCKET_NAME | |
env: | |
BUCKET_NAME: ${{ secrets[format('AWS_S3_BUCKET_NAME_{0}', 'PRODUCTION')] }} | |
- name: Run Cache Invalidation | |
run: aws cloudfront create-invalidation --distribution-id $CDN_DISTRIBUTION_ID --paths /\* | |
env: | |
CDN_DISTRIBUTION_ID: ${{ secrets[format('AWS_CDN_DISTRIBUTION_ID_{0}', 'PRODUCTION')] }} |