Skip to content

Merge pull request #382 from badaitech/feat/dbos-simplify-flow #21

Merge pull request #382 from badaitech/feat/dbos-simplify-flow

Merge pull request #382 from badaitech/feat/dbos-simplify-flow #21

Workflow file for this run

name: Release
on:
push:
branches:
- main
- release
release:
types: [created]
# Prevent concurrent releases
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
packages: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_VERSION: 24.11.1
PNPM_VERSION: 10.5.2
jobs:
release:
name: Release
runs-on: ubuntu-latest-m-2
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://npm.pkg.github.com'
scope: '@badaitech'
- name: Setup PNPM
uses: pnpm/action-setup@v3
with:
version: ${{ env.PNPM_VERSION }}
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
# run: |
# echo "STORE_PATH=$(pnpm store path)" | tee -a $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Lint check
run: pnpm run lint
- name: Run tests
run: pnpm run test
- name: Build packages
run: pnpm run build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max-old-space-size=8192
# Create .npmrc file for GitHub Packages
- name: Setup .npmrc
run: |
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
echo "@badaitech:registry=https://npm.pkg.github.com" >> .npmrc
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# For GitHub releases, publish directly with version from tag
- name: Publish packages from release
run: |
TAG_VERSION="${{ github.event.release.tag_name }}"
# Remove 'v' prefix if present
VERSION="${TAG_VERSION#v}"
echo "Setting version to $VERSION for all packages"
pnpm -r exec -- npm version $VERSION --no-git-tag-version
echo "Publishing release packages..."
pnpm -r publish --access restricted --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Use changesets action for main branch pushes
- name: Create Release PR or Publish
if: github.event_name == 'push'
uses: changesets/action@v1
with:
version: pnpm run changeset:version
publish: pnpm run changeset:publish
commit: 'chore: update package versions'
title: 'chore: update package versions'
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Extract app versions from package.json
id: extract-versions
run: |
BACK_VERSION=$(node -p "require('./apps/chaingraph-backend/package.json').version")
FRONT_VERSION=$(node -p "require('./apps/chaingraph-frontend/package.json').version")
EXEC_API_VERSION=$(node -p "require('./apps/chaingraph-execution-api/package.json').version")
EXEC_WORKER_VERSION=$(node -p "require('./apps/chaingraph-execution-worker/package.json').version")
echo "BACK_VERSION=$BACK_VERSION" >> $GITHUB_ENV
echo "FRONT_VERSION=$FRONT_VERSION" >> $GITHUB_ENV
echo "EXEC_API_VERSION=$EXEC_API_VERSION" >> $GITHUB_ENV
echo "EXEC_WORKER_VERSION=$EXEC_WORKER_VERSION" >> $GITHUB_ENV
echo "Extracted versions:"
echo " Backend: $BACK_VERSION"
echo " Frontend: $FRONT_VERSION"
echo " Execution API: $EXEC_API_VERSION"
echo " Execution Worker: $EXEC_WORKER_VERSION"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build all application Docker images in parallel (self-contained builds)
build-apps:
name: Build Application Images
runs-on: ubuntu-latest-m-2
needs: release
strategy:
matrix:
app:
- name: backend
dockerfile: apps/chaingraph-backend/Dockerfile
version_env: BACK_VERSION
- name: frontend
dockerfile: apps/chaingraph-frontend/Dockerfile
version_env: FRONT_VERSION
- name: execution-api
dockerfile: apps/chaingraph-execution-api/Dockerfile
version_env: EXEC_API_VERSION
- name: execution-worker
dockerfile: apps/chaingraph-execution-worker/Dockerfile
version_env: EXEC_WORKER_VERSION
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract app versions from package.json
id: extract-versions
run: |
BACK_VERSION=$(node -p "require('./apps/chaingraph-backend/package.json').version")
FRONT_VERSION=$(node -p "require('./apps/chaingraph-frontend/package.json').version")
EXEC_API_VERSION=$(node -p "require('./apps/chaingraph-execution-api/package.json').version")
EXEC_WORKER_VERSION=$(node -p "require('./apps/chaingraph-execution-worker/package.json').version")
echo "BACK_VERSION=$BACK_VERSION" >> $GITHUB_ENV
echo "FRONT_VERSION=$FRONT_VERSION" >> $GITHUB_ENV
echo "EXEC_API_VERSION=$EXEC_API_VERSION" >> $GITHUB_ENV
echo "EXEC_WORKER_VERSION=$EXEC_WORKER_VERSION" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ${{ matrix.app.name }} Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.app.dockerfile }}
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/chaingraph-${{ matrix.app.name }}:latest
ghcr.io/${{ github.repository_owner }}/chaingraph-${{ matrix.app.name }}:${{ env[matrix.app.version_env] }}
cache-from: type=gha,scope=${{ matrix.app.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.app.name }}
# - name: Build and push images (Push to main/develop/tags)
# uses: docker/bake-action@v6
# with:
# files: docker-bake.hcl
# targets: backend,frontend
# push: true
# env:
# REGISTRY: ghcr.io/${{ github.repository_owner }}
# BACK_VERSION: ${{ env.BACK_VERSION }}
# FRONT_VERSION: ${{ env.FRONT_VERSION }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}