Skip to content

Commit

Permalink
ci: setup release flow
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanddd committed Mar 15, 2024
1 parent 134dbf5 commit 93c55cd
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
push:
branches:
- main
- preview

permissions:
contents: read # for checkout

jobs:
release:
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3 # v3
with:
fetch-depth: 0 # to be able to checkout any commit
persist-credentials: false # <--- this
- uses: pnpm/action-setup@v2
with:
version: 6.32.9
- uses: actions/setup-node@v3 # v3
with:
cache: pnpm
node-version: 18
- name: Install dependencies
run: pnpm install
# pinned version updated automatically by Renovate.
# details at https://semantic-release.gitbook.io/semantic-release/usage/installation#global-installation
- run: pnpm dlx [email protected]
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
19 changes: 19 additions & 0 deletions .github/workflows/vercel-preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Vercel Preview Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
release:
types: [prereleased]
jobs:
Deploy-Preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Merge to Preview
uses: devmasx/merge-branch@master
with:
type: now
from_branch: preview
target_branch: preview-release
github_token: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/vercel-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Vercel Production Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
workflow_dispatch:
release:
types: [released]
jobs:
Deploy-Production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Merge to Prod
uses: devmasx/merge-branch@master
with:
type: now
from_branch: main
target_branch: prod-release
github_token: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
RELEASE_BRANCH=main
BETA_BRANCH=preview
DEVELOP_BRANCH=develop

.PHONY: release
release:
git checkout $(BETA_BRANCH) && git pull origin $(BETA_BRANCH) && \
git checkout $(RELEASE_BRANCH) && git pull origin $(RELEASE_BRANCH) && \
git merge $(BETA_BRANCH) --no-edit --no-ff && \
git push origin $(RELEASE_BRANCH) && \
git checkout $(DEVELOP_BRANCH)

.PHONY: release-preview
release-preview: sync-release
git checkout $(DEVELOP_BRANCH) && git pull origin $(DEVELOP_BRANCH) && \
git checkout $(BETA_BRANCH) && git pull origin $(BETA_BRANCH) && \
git merge $(DEVELOP_BRANCH) --no-edit --no-ff && \
git push origin $(BETA_BRANCH) && \
git checkout $(DEVELOP_BRANCH) && git push origin $(DEVELOP_BRANCH)

.PHONY: sync-release
sync-release:
git checkout $(RELEASE_BRANCH) && git pull origin $(RELEASE_BRANCH) && \
git checkout $(BETA_BRANCH) && git pull origin $(BETA_BRANCH) && \
git merge $(RELEASE_BRANCH) --no-edit --no-ff

0 comments on commit 93c55cd

Please sign in to comment.