Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
push:
branches:
- development
pull_request:
branches:
- development
- main
workflow_dispatch:

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
verify:
name: Typecheck, Test & Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build engine package
run: pnpm --filter school-timetabling-engine build

- name: Run typecheck
run: pnpm typecheck

- name: Run tests
run: pnpm test

- name: Verify production build
run: pnpm build
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Deploy to GitHub Pages
on:
push:
branches:
- development
- main
workflow_dispatch:

Expand Down
110 changes: 110 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ permissions:
contents: write
issues: write
pull-requests: write
packages: write

concurrency:
group: release-${{ github.ref }}
Expand Down Expand Up @@ -55,10 +56,14 @@ jobs:
name: Release Jadwali Platform
needs: [release-engine]
runs-on: ubuntu-latest
outputs:
released: ${{ steps.check_release.outputs.released }}
version: ${{ steps.check_release.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -85,3 +90,108 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm release:platform

- name: Check if new platform version was released
id: check_release
run: |
if [ -f .platform-version ]; then
VERSION=$(cat .platform-version)
echo "released=true" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Platform released version: $VERSION"
else
echo "released=false" >> "$GITHUB_OUTPUT"
echo "No new platform release created."
fi

publish-docker:
name: Build & Publish Docker Images
needs: [release-platform]
if: needs.release-platform.outputs.released == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Lowercase repository owner
id: repo_owner
run: echo "owner=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_OUTPUT"

- name: Extract metadata for Server
uses: docker/metadata-action@v5
id: meta_server
with:
images: ghcr.io/${{ steps.repo_owner.outputs.owner }}/jadwali-server
tags: |
type=raw,value=${{ needs.release-platform.outputs.version }}
type=raw,value=latest

- name: Build and push Server Docker image
uses: docker/build-push-action@v5
with:
context: .
file: server/Dockerfile
push: true
tags: ${{ steps.meta_server.outputs.tags }}
labels: ${{ steps.meta_server.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Extract metadata for Client
uses: docker/metadata-action@v5
id: meta_client
with:
images: ghcr.io/${{ steps.repo_owner.outputs.owner }}/jadwali-client
tags: |
type=raw,value=${{ needs.release-platform.outputs.version }}
type=raw,value=latest

- name: Build and push Client Docker image
uses: docker/build-push-action@v5
with:
context: .
file: client/Dockerfile
push: true
tags: ${{ steps.meta_client.outputs.tags }}
labels: ${{ steps.meta_client.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

sync-development:
name: Sync Release to Development Branch
needs: [release-platform]
if: always() && needs.release-platform.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Merge main back into development
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout development
git pull origin development
git merge origin/main --no-edit -m "chore: sync release from main back to development [skip ci]" || echo "No changes or already up to date"
git push origin development || echo "Nothing to push"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,4 @@ local/
docs/
.superpowers/
**/superpowers/
.platform-version
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"build": "pnpm --filter school-timetabling-engine build && pnpm --filter client build",
"test": "pnpm -r run test",
"typecheck": "pnpm --filter school-timetabling-engine build && pnpm -r run typecheck",
"release:engine": "semantic-release --config release-engine.config.cjs",
"release:platform": "semantic-release --config release-platform.config.cjs"
"release:engine": "semantic-release --extends ./release-engine.config.cjs",
"release:platform": "semantic-release --extends ./release-platform.config.cjs"
},
"devDependencies": {
"@semantic-release/changelog": "^6.0.3",
Expand Down
3 changes: 2 additions & 1 deletion release-platform.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ module.exports = {
[
'@semantic-release/exec',
{
prepareCmd: 'node scripts/sync-platform-versions.js ${nextRelease.version}'
prepareCmd: 'node scripts/sync-platform-versions.js ${nextRelease.version}',
successCmd: 'node -e "require(\'fs\').writeFileSync(\'.platform-version\', \'${nextRelease.version}\')"'
}
],
[
Expand Down
6 changes: 2 additions & 4 deletions scripts/sync-platform-versions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const fs = require('node:fs');
const path = require('node:path');

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.resolve(__dirname, '..');

const version = process.argv[2];
Expand Down
Loading