Beta release #455
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 Workflow | |
on: | |
# manual trigger | |
workflow_dispatch: | |
inputs: | |
# main branch name | |
prod-release: | |
description: 'Do prod release' | |
required: true | |
default: false | |
type: boolean | |
# main branch name | |
e2e-tests: | |
description: 'Do e2e tests' | |
required: true | |
default: true | |
type: boolean | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
run-name: ${{ inputs.prod-release && 'Prod' || 'Beta' }} release ${{ inputs.e2e-tests && 'with E2E tests' || '' }} | |
jobs: | |
merge-dev-into-main: | |
name: Merge Dev into Main | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
if: ${{ inputs.prod-release }} | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set Git config | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "Badman Releaser" | |
- name: Merge develop back to main | |
run: | | |
git fetch --unshallow | |
git checkout main | |
git pull | |
git merge --no-ff develop -m "Merging develop into main" | |
git push | |
main: | |
name: Nx Cloud - Main Job | |
uses: ./.github/workflows/nx-cloud-main.yml | |
if: ${{ !cancelled() }} | |
needs: [merge-dev-into-main] | |
secrets: | |
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} | |
with: | |
number-of-agents: 3 | |
node-version: ${{ vars.NODE_VERSION }} | |
main-branch-name: ${{ inputs.prod-release && 'main' || 'develop' }} | |
output-affected-projects: true | |
parallel-commands-on-agents: | | |
npx nx affected --target=build --parallel=3 --configuration ${{ inputs.prod-release && 'production' || 'beta'}} | |
npx nx affected --target=lint --parallel=3 --configuration ${{ inputs.prod-release && 'production' || 'beta'}} | |
npx nx affected --target=test --parallel=3 --configuration ${{ inputs.prod-release && 'production' || 'beta'}} --ci | |
# npx nx affected --target=server | |
timeout: 15 | |
agents: | |
name: Nx Cloud - Agents | |
if: ${{ !cancelled() }} | |
needs: [merge-dev-into-main] | |
uses: ./.github/workflows/nx-cloud-agents.yml | |
secrets: | |
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} | |
with: | |
node-version: ${{ vars.NODE_VERSION }} | |
number-of-agents: 3 | |
timeout: 15 | |
release: | |
runs-on: ubuntu-latest | |
name: Release | |
needs: [e2e, main] | |
if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') | |
# output new version | |
outputs: | |
NEW_VERSION: ${{ steps.push_release.outputs.new_version }} | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.prod-release && 'main' || 'develop' }} | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ vars.NODE_VERSION }} | |
- name: install dependencies for release | |
run: npm --prefix \scripts install | |
- name: Get the new version and changelog | |
id: create_release | |
run: | | |
# if the prod release is false, then we want to create a beta release by appending --beta to the command | |
npm run --prefix \scripts create-release -- --affected="${{ needs.main.outputs.affectedProjects }}" --prod=${{ inputs.prod-release }} | |
- name: Push new version and changelog | |
id: push_release | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Badman Releaser" | |
git config advice.ignoredHook false | |
git add . | |
git status | |
git commit -m "chore(release): v${{ env.NEW_VERSION }}" | |
git tag -a v${{ env.NEW_VERSION }} -m "${{ env.CHANGELOG }}" | |
git push --follow-tags origin ${{ inputs.prod-release && 'main' || 'develop' }} | |
# output new version | |
echo new_version=${{ env.NEW_VERSION }} >> $GITHUB_OUTPUT | |
- name: Create Github Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.github_token }} | |
with: | |
tag_name: v${{ env.NEW_VERSION }} | |
release_name: v${{ env.NEW_VERSION }} | |
body: ${{ env.CHANGELOG }} | |
prerelease: ${{ !inputs.prod-release }} | |
- name: Trigger deploy hooks on Render.com (if affected) | |
run: | | |
# read the affected projects from the main job | |
affectedProjects=$(echo ${{ needs.main.outputs.affectedProjects }} | tr -d ' ') | |
echo "Affected Projects: $affectedProjects" | |
# check if the affected projects contains api or badman | |
if [[ $affectedProjects == *"api"* || $affectedProjects == *"badman"* ]]; then | |
curl -X POST -H "Content-Type: application/json" ${{ inputs.prod-release && secrets.PROD_API_HOOK || secrets.BETA_API_HOOK }} | |
fi | |
# check if the affected projects contains worker-sync | |
if [[ $affectedProjects == *"worker-sync"* ]]; then | |
curl -X POST -H "Content-Type: application/json" ${{ inputs.prod-release && secrets.PROD_WORKER_SYNC_HOOK || secrets.BETA_WORKER_SYNC_HOOK }} | |
fi | |
# check if the affected projects contains worker-sync | |
if [[ $affectedProjects == *"worker-ranking"* ]]; then | |
curl -X POST -H "Content-Type: application/json" ${{ inputs.prod-release && secrets.PROD_WORKER_RANKING_HOOK || secrets.BETA_WORKER_RANKING_HOOK }} | |
fi | |
## Vercel deploys automatically on push to branch with Chore: prefix | |
merge-main-into-dev: | |
name: Merge Main into Dev | |
runs-on: ubuntu-latest | |
needs: [release, main] | |
if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && inputs.prod-release | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set Git config | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "Badman Releaser" | |
- name: Merge main back to develop | |
run: | | |
git fetch --unshallow | |
git checkout develop | |
git pull | |
git merge --no-ff origin/main -m "chore(release): v${{ needs.release.outputs.NEW_VERSION }}" | |
# git merge --no-ff main -m "Merging main into develop" | |
git push | |
- name: Trigger deploy hooks on Render.com (if affected) | |
run: | | |
# read the affected projects from the main job | |
affectedProjects=$(echo ${{ needs.main.outputs.affectedProjects }} | tr -d ' ') | |
echo "Affected Projects: $affectedProjects" | |
# check if the affected projects contains api or badman | |
if [[ $affectedProjects == *"api"* || $affectedProjects == *"badman"* ]]; then | |
curl -X POST -H "Content-Type: application/json" ${{ secrets.BETA_API_HOOK }} | |
fi | |
# check if the affected projects contains worker-sync | |
if [[ $affectedProjects == *"worker-sync"* ]]; then | |
curl -X POST -H "Content-Type: application/json" ${{ secrets.BETA_WORKER_SYNC_HOOK }} | |
fi | |
# check if the affected projects contains worker-sync | |
if [[ $affectedProjects == *"worker-ranking"* ]]; then | |
curl -X POST -H "Content-Type: application/json" ${{ secrets.BETA_WORKER_RANKING_HOOK }} | |
fi | |
e2e: | |
name: E2E Tests | |
needs: [agents, main] | |
if: always() && inputs.e2e-tests && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') | |
uses: ./.github/workflows/playwright.yml |