Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add release cycle #93

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Development

on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened
workflow_call:

jobs:
test:
name: Test application
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: '☁️ checkout repository'
uses: actions/checkout@v3

- name: '🔧 setup node'
uses: actions/setup-node@v3
with:
node-version: 18

- name: '🔧 install npm@latest'
run: npm i -g npm@latest

- name: '📦 install dependencies'
uses: bahmutov/npm-install@v1

- name: '🔍 run tests'
run: npm run test --if-present

lint:
name: Code standards
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: '☁️ checkout repository'
uses: actions/checkout@v3

- name: '🔧 setup node'
uses: actions/setup-node@v3
with:
node-version: 18

- name: '🔧 install npm@latest'
run: npm i -g npm@latest

- name: '📦 install dependencies'
uses: bahmutov/npm-install@v1

- name: '🔍 lint code'
run: npm run lint --if-present

build:
name: Build application
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: '☁️ checkout repository'
uses: actions/checkout@v3

- name: '🔧 setup node'
uses: actions/setup-node@v3
with:
node-version: 18

- name: '🔧 install npm@latest'
run: npm i -g npm@latest

- name: '📦 install dependencies'
uses: bahmutov/npm-install@v1

- name: '🔍 build application'
run: npm run prepare --if-present
114 changes: 114 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: 'Semantic release'

on:
push:
branches:
- main
- alpha
- beta
- next

concurrency:
# group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
group: release-${{ github.ref }}
cancel-in-progress: true

jobs:
setup:
name: Set environment variables
runs-on: ubuntu-latest
outputs:
DEPLOY_ENVIRONMENT: ${{ steps.env.outputs.DEPLOY_ENVIRONMENT }}
VERCEL_ENVIRONMENT: ${{ steps.env.outputs.VERCEL_ENVIRONMENT }}
steps:
- name: '☁️ compute environment variables'
id: env
run: |
echo "DEPLOY_ENVIRONMENT=$([[ ${{ github.ref_name }} == 'main' ]] && echo 'production' || echo ${{ github.ref_name }})" >> $GITHUB_OUTPUT
echo "VERCEL_ENVIRONMENT=$([[ ${{ github.ref_name }} == 'main' ]] && echo 'production' || echo 'preview')" >> $GITHUB_OUTPUT

test:
name: Test, lint and build
uses: ./.github/workflows/development.yml

release:
environment:
name: ${{ needs.setup.outputs.DEPLOY_ENVIRONMENT }}
url: https://github.com/${{ github.repository }}/releases/tag/${{ steps.semantic-release.outputs.release-tag }}
outputs:
release-tag: ${{ steps.semantic-release.outputs.release-tag }}
name: Semantic release
needs:
- setup
- test
runs-on: ubuntu-latest
steps:
- name: '☁️ checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: '🔧 setup node'
uses: actions/setup-node@v4
with:
node-version: 20

- name: '🔧 install npm@latest'
run: npm i -g npm@latest

- name: '📦 install dependencies'
uses: bahmutov/[email protected]

- name: '🚀 release'
id: semantic-release
uses: 0-vortex/release@v11
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

deploy:
environment:
name: ${{ needs.setup.outputs.DEPLOY_ENVIRONMENT }}
name: Deploy to Vercel
needs:
- release
runs-on: ubuntu-latest
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- name: '☁️ checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: '🔧 setup node'
uses: actions/setup-node@v4
with:
node-version: 20

- name: '🔧 install npm@latest vercel@canary'
run: npm i -g npm@latest vercel@canary

- name: '📦 Pull Vercel Environment Information'
run: npx vercel pull --yes --environment=${{ needs.setup.outputs.VERCEL_ENVIRONMENT }} --token=${{ secrets.VERCEL_TOKEN }}

- name: '📦 Pull Vercel Build Environment'
run: npx vercel env pull .env.local --token=${{ secrets.VERCEL_TOKEN }}

- name: '📂 Build Project Artifacts'
run: npx vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}

- name: '🚀 Deploy Project Artifacts to Vercel'
run: npx vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

cleanup:
name: Cleanup actions
needs:
- release
runs-on: ubuntu-latest
steps:
- name: '♻️ remove build artifacts'
uses: geekyeggo/delete-artifact@v2
with:
name: |
docker
Loading