diff --git a/.github/workflows/packages-stl-next-required.yml b/.github/workflows/packages-stl-next-required.yml index 8c37198..03b6228 100644 --- a/.github/workflows/packages-stl-next-required.yml +++ b/.github/workflows/packages-stl-next-required.yml @@ -12,8 +12,8 @@ concurrency: cancel-in-progress: true jobs: - setup: - name: Setup stage + setup-stage: + name: Setup - Stage runs-on: ubuntu-latest outputs: cache-hit: ${{ steps.cache-pnpm-store.outputs.cache-hit }} @@ -42,47 +42,9 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - lint: - name: Lint STL - needs: [setup, build-configs] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.12.3 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'pnpm' - - name: Install dependencies - run: pnpm install --frozen-lockfile - - name: Lint STL package - run: pnpm --filter @ermnvldmr/stl lint - - type-check: - name: Typecheck STL - needs: [setup, build-configs] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.12.3 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'pnpm' - - name: Install dependencies - run: pnpm install --frozen-lockfile - - name: Typecheck STL package - run: pnpm --filter @ermnvldmr/stl typecheck - build-configs: - name: Build Config Packages - needs: setup + name: Build - Configs + needs: setup-stage runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -101,9 +63,47 @@ jobs: - name: Build Vite config run: pnpm --filter @ermnvldmr/vite-config build - test: - name: Test STL - needs: [setup, build-configs] + lint-stl: + name: Lint - STL + needs: build-configs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.3 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Lint STL package + run: pnpm --filter @ermnvldmr/stl lint + + typecheck-stl: + name: Typecheck - STL + needs: build-configs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.3 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Typecheck STL package + run: pnpm --filter @ermnvldmr/stl typecheck + + test-stl: + name: Test - STL + needs: build-configs runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -131,9 +131,9 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - build: - name: Build STL Package - needs: [setup, build-configs] + build-stl: + name: Build - STL + needs: build-configs runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/packages-ui-next-required.yml b/.github/workflows/packages-ui-next-required.yml index 4fd348a..fae4639 100644 --- a/.github/workflows/packages-ui-next-required.yml +++ b/.github/workflows/packages-ui-next-required.yml @@ -13,8 +13,8 @@ concurrency: cancel-in-progress: true jobs: - setup: - name: Setup stage + setup-stage: + name: Setup - Stage runs-on: ubuntu-latest outputs: cache-hit: ${{ steps.cache-pnpm-store.outputs.cache-hit }} @@ -43,51 +43,9 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - lint: - name: Lint UI & Dependencies - needs: [setup, build-configs] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.12.3 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'pnpm' - - name: Install dependencies - run: pnpm install --frozen-lockfile - - name: Lint STL package - run: pnpm --filter @ermnvldmr/stl lint - - name: Lint UI package - run: pnpm --filter @ermnvldmr/ui lint - - type-check: - name: Typecheck UI & Dependencies - needs: [setup, build-configs] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.12.3 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'pnpm' - - name: Install dependencies - run: pnpm install --frozen-lockfile - - name: Typecheck STL package - run: pnpm --filter @ermnvldmr/stl typecheck - - name: Typecheck UI package - run: pnpm --filter @ermnvldmr/ui typecheck - build-configs: - name: Build Config Packages - needs: setup + name: Build - Configs + needs: setup-stage runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -109,8 +67,8 @@ jobs: run: pnpm --filter @ermnvldmr/storybook-config build build-dependencies: - name: Build Dependencies (STL) - needs: [setup, build-configs] + name: Build - Dependencies + needs: build-configs runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -133,9 +91,51 @@ jobs: - name: Build STL package run: pnpm --filter @ermnvldmr/stl build - test: - name: Test UI & Dependencies - needs: [setup, build-dependencies] + lint-ui: + name: Lint - UI + needs: build-dependencies + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.3 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Lint STL package + run: pnpm --filter @ermnvldmr/stl lint + - name: Lint UI package + run: pnpm --filter @ermnvldmr/ui lint + + typecheck-ui: + name: Typecheck - UI + needs: build-dependencies + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.3 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Typecheck STL package + run: pnpm --filter @ermnvldmr/stl typecheck + - name: Typecheck UI package + run: pnpm --filter @ermnvldmr/ui typecheck + + test-ui: + name: Test - UI & Storybook + needs: build-dependencies runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -169,9 +169,9 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - storybook-build: - name: Build UI Storybook - needs: [setup, build-dependencies] + build-storybook: + name: Build - Storybook + needs: build-dependencies runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -198,9 +198,9 @@ jobs: - name: Build UI Storybook run: pnpm --filter @ermnvldmr/ui build-storybook - build: - name: Build UI Package - needs: [setup, build-dependencies] + build-ui: + name: Build - UI + needs: build-dependencies runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/services-docs-next-required.yml b/.github/workflows/services-docs-next-required.yml index ba05c4a..bac936e 100644 --- a/.github/workflows/services-docs-next-required.yml +++ b/.github/workflows/services-docs-next-required.yml @@ -11,8 +11,8 @@ concurrency: cancel-in-progress: true jobs: - setup: - name: Setup Hugo + setup-hugo: + name: Setup - Hugo runs-on: ubuntu-latest steps: - name: Checkout repository @@ -27,9 +27,9 @@ jobs: hugo-version: 'latest' extended: true - build: - name: Build Hugo Site - needs: setup + build-hugo: + name: Build - Hugo Site + needs: setup-hugo runs-on: ubuntu-latest steps: - name: Checkout repository @@ -47,3 +47,41 @@ jobs: - name: Build Hugo site working-directory: services/docs run: hugo --gc --minify + + release-docker: + name: Release - Docker Image + needs: build-hugo + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }}/docs + tags: | + type=raw,value=latest + type=sha,format=short + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ci/docker/docs/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/services-www-next-checkout-release-branch.yml b/.github/workflows/services-www-next-checkout-release-branch.yml new file mode 100644 index 0000000..01aeb57 --- /dev/null +++ b/.github/workflows/services-www-next-checkout-release-branch.yml @@ -0,0 +1,27 @@ +name: services/www - next/checkout-release-branch + +on: + workflow_dispatch: + +jobs: + workflow-create-release-branch: + name: Workflow - Create Release Branch + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Determine Branch Name + id: branch + run: | + BRANCH_NAME=$(bash ci/scripts/semantic-release.sh checkout services/www) + echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT + + - name: Create and Push Branch + run: | + git checkout -b ${{ steps.branch.outputs.branch_name }} + git push origin ${{ steps.branch.outputs.branch_name }} diff --git a/.github/workflows/services-www-next-required.yml b/.github/workflows/services-www-next-required.yml index 1e870b1..046e61c 100644 --- a/.github/workflows/services-www-next-required.yml +++ b/.github/workflows/services-www-next-required.yml @@ -14,8 +14,8 @@ concurrency: cancel-in-progress: true jobs: - setup: - name: Setup stage + setup-stage: + name: Setup - Stage runs-on: ubuntu-latest outputs: cache-hit: ${{ steps.cache-pnpm-store.outputs.cache-hit }} @@ -45,8 +45,8 @@ jobs: run: pnpm install --frozen-lockfile build-configs: - name: Build Config Packages - needs: setup + name: Build - Configs + needs: setup-stage runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -68,8 +68,8 @@ jobs: run: pnpm --filter @ermnvldmr/storybook-config build build-dependencies: - name: Build Dependencies (STL → UI) - needs: [setup, build-configs] + name: Build - Dependencies + needs: build-configs runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -94,9 +94,9 @@ jobs: - name: Build UI package run: pnpm --filter @ermnvldmr/ui build - lint: - name: Lint WWW & Dependencies - needs: [setup, build-configs] + lint-www: + name: Lint - WWW & Deps + needs: build-dependencies runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -117,9 +117,9 @@ jobs: - name: Lint WWW service run: pnpm --filter @ermnvldmr/www lint - type-check: - name: Typecheck WWW & Dependencies - needs: [setup, build-configs] + typecheck-www: + name: Typecheck - WWW & Deps + needs: build-dependencies runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -140,9 +140,9 @@ jobs: - name: Typecheck WWW service run: pnpm --filter @ermnvldmr/www typecheck - storybook-build: - name: Build Storybook - needs: [setup, build-dependencies] + build-storybook: + name: Build - Storybook + needs: build-dependencies runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -175,9 +175,9 @@ jobs: path: services/www/storybook-static/ retention-days: 1 - test: - name: Test - needs: [setup, storybook-build] + test-www: + name: Test - WWW & Storybook + needs: build-storybook runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -224,9 +224,9 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - build: - name: Build WWW Service - needs: [setup, build-dependencies] + build-www: + name: Build - WWW Service + needs: build-dependencies runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -252,3 +252,39 @@ jobs: run: pnpm --filter @ermnvldmr/ui build - name: Build WWW service run: pnpm --filter @ermnvldmr/www build + + release-docker: + name: Release - Docker Image + needs: build-www + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }}/www + tags: | + type=raw,value=next + type=sha,format=short + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ci/docker/www/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/services-www-releases-dispatch-release.yml b/.github/workflows/services-www-releases-dispatch-release.yml new file mode 100644 index 0000000..1acba8d --- /dev/null +++ b/.github/workflows/services-www-releases-dispatch-release.yml @@ -0,0 +1,62 @@ +name: services/www - releases/dispatch-release + +on: + workflow_dispatch: + +jobs: + release-tag-docker: + name: Release - Tag & Docker + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Calculate Release Version + id: version + run: | + RELEASE_VERSION=$(bash ci/scripts/semantic-release.sh release ${{ github.ref_name }}) + # Extract MAJOR.MINOR for tagging + MAJOR_MINOR=$(echo "${{ github.ref_name }}" | cut -d/ -f3 | sed 's/^v//') + MAJOR=$(echo "$MAJOR_MINOR" | cut -d. -f1) + echo "version=$RELEASE_VERSION" >> $GITHUB_OUTPUT + echo "major_minor=$MAJOR_MINOR" >> $GITHUB_OUTPUT + echo "major=$MAJOR" >> $GITHUB_OUTPUT + + - name: Create and Push Tag + run: | + TAG_NAME="releases/www/v${{ steps.version.outputs.version }}" + git tag $TAG_NAME + git push origin $TAG_NAME + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }}/www + tags: | + type=raw,value=v${{ steps.version.outputs.version }} + type=raw,value=v${{ steps.version.outputs.major_minor }} + type=raw,value=v${{ steps.version.outputs.major }} + type=raw,value=latest + type=sha,format=short + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ci/docker/www/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/services-www-releases-required.yml b/.github/workflows/services-www-releases-required.yml new file mode 100644 index 0000000..aeb5133 --- /dev/null +++ b/.github/workflows/services-www-releases-required.yml @@ -0,0 +1,172 @@ +name: services/www - releases/required + +on: + push: + branches: ['releases/www/**'] + +concurrency: + group: ci-www-rel-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + setup-stage: + name: Setup - Stage + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.3 + - name: Setup Node.js with pnpm cache + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile + + build-configs: + name: Build - Configs + needs: setup-stage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.3 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Build configs + run: | + pnpm --filter @ermnvldmr/jest-config build + pnpm --filter @ermnvldmr/vite-config build + pnpm --filter @ermnvldmr/storybook-config build + + build-dependencies: + name: Build - Dependencies + needs: build-configs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.3 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Build dependencies + run: | + pnpm --filter @ermnvldmr/jest-config build + pnpm --filter @ermnvldmr/vite-config build + pnpm --filter @ermnvldmr/storybook-config build + pnpm --filter @ermnvldmr/stl build + pnpm --filter @ermnvldmr/ui build + + test-www: + name: Test - WWW & Deps + needs: build-dependencies + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.3 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Build dependencies + run: | + pnpm --filter @ermnvldmr/jest-config build + pnpm --filter @ermnvldmr/vite-config build + pnpm --filter @ermnvldmr/storybook-config build + pnpm --filter @ermnvldmr/stl build + pnpm --filter @ermnvldmr/ui build + - name: Run tests + run: | + pnpm --filter @ermnvldmr/stl test:coverage + pnpm --filter @ermnvldmr/ui test:coverage + pnpm --filter @ermnvldmr/www test:coverage + + build-www: + name: Build - WWW Service + needs: build-dependencies + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.12.3 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Build WWW service + run: | + pnpm --filter @ermnvldmr/jest-config build + pnpm --filter @ermnvldmr/vite-config build + pnpm --filter @ermnvldmr/storybook-config build + pnpm --filter @ermnvldmr/stl build + pnpm --filter @ermnvldmr/ui build + pnpm --filter @ermnvldmr/www build + + release-rc-docker: + name: Release - RC Docker Image + needs: build-www + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Calculate RC Version + id: version + run: | + RC_VERSION=$(bash ci/scripts/semantic-release.sh rc ${{ github.ref_name }}) + echo "rc_version=$RC_VERSION" >> $GITHUB_OUTPUT + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }}/www + tags: | + type=raw,value=${{ steps.version.outputs.rc_version }} + type=sha,format=short + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ci/docker/www/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/ci/config/nginx/default.conf b/ci/config/nginx/default.conf new file mode 100644 index 0000000..f206a62 --- /dev/null +++ b/ci/config/nginx/default.conf @@ -0,0 +1,31 @@ +server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + # Gzip compression + gzip on; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; + + # Clean URLs (remove .html from URI) + location / { + try_files $uri $uri/ $uri.html /index.html; + } + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, no-transform"; + } + + # Error pages + error_page 404 /404.html; + location = /404.html { + internal; + } +} diff --git a/ci/docker/docs/Dockerfile b/ci/docker/docs/Dockerfile new file mode 100644 index 0000000..9675bf0 --- /dev/null +++ b/ci/docker/docs/Dockerfile @@ -0,0 +1,16 @@ +# Stage 1: Build +FROM klakegg/hugo:ext-alpine AS builder + +WORKDIR /src +COPY services/docs /src + +RUN hugo --gc --minify + +# Stage 2: Runtime +FROM nginx:alpine + +COPY --from=builder /src/public /usr/share/nginx/html +COPY ci/config/nginx/default.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/ci/docker/www/Dockerfile b/ci/docker/www/Dockerfile new file mode 100644 index 0000000..a67794d --- /dev/null +++ b/ci/docker/www/Dockerfile @@ -0,0 +1,41 @@ +# Stage 1: Build +FROM node:20-alpine AS builder + +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat +RUN npm install -g pnpm@9.12.3 + +WORKDIR /app + +# Copy monorepo configuration +COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ +# Copy all package.json files to allow pnpm to fetch dependencies +COPY packages/eslint-config/package.json ./packages/eslint-config/ +COPY packages/jest-config/package.json ./packages/jest-config/ +COPY packages/stl/package.json ./packages/stl/ +COPY packages/storybook-config/package.json ./packages/storybook-config/ +COPY packages/ui/package.json ./packages/ui/ +COPY packages/vite-config/package.json ./packages/vite-config/ +COPY services/www/package.json ./services/www/ + +# Install dependencies +RUN pnpm install --frozen-lockfile + +# Copy source code +COPY . . + +# Build dependencies and then the website +RUN pnpm --filter @ermnvldmr/jest-config build +RUN pnpm --filter @ermnvldmr/vite-config build +RUN pnpm --filter @ermnvldmr/stl build +RUN pnpm --filter @ermnvldmr/ui build +RUN pnpm --filter @ermnvldmr/www build + +# Stage 2: Runtime +FROM nginx:alpine + +COPY --from=builder /app/services/www/dist /usr/share/nginx/html +COPY ci/config/nginx/default.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/ci/scripts/semantic-release.sh b/ci/scripts/semantic-release.sh new file mode 100755 index 0000000..dc88847 --- /dev/null +++ b/ci/scripts/semantic-release.sh @@ -0,0 +1,67 @@ +#!/bin/bash +set -e + +MODE=$1 +TARGET=$2 + +if [ -z "$MODE" ] || [ -z "$TARGET" ]; then + echo "Usage: $0 " + exit 1 +fi + +case $MODE in + checkout) + SERVICE_PATH=$TARGET + SERVICE_NAME=$(basename "$SERVICE_PATH") + VERSION=$(node -p "require('./$SERVICE_PATH/package.json').version") + MAJOR_MINOR=$(echo "$VERSION" | cut -d. -f1,2) + echo "releases/$SERVICE_NAME/v$MAJOR_MINOR" + ;; + rc|release) + BRANCH_NAME=$TARGET + # Extract service name and major.minor from branch: releases/www/v1.2 + if [[ ! $BRANCH_NAME =~ ^releases/([^/]+)/v([0-9]+\.[0-9]+)$ ]]; then + echo "Error: Branch name must follow 'releases//v.' format" + exit 1 + fi + SERVICE_NAME="${BASH_REMATCH[1]}" + MAJOR_MINOR="${BASH_REMATCH[2]}" + + TAG_PREFIX="releases/$SERVICE_NAME/v$MAJOR_MINOR" + + # Ensure we have the latest tags + git fetch --tags --quiet + + # Find the latest patch version for this Major.Minor + LATEST_TAG=$(git tag -l "$TAG_PREFIX.*" | grep -v "\-rc" | sort -V | tail -n1 || echo "") + + if [ -z "$LATEST_TAG" ]; then + PATCH=0 + else + LATEST_VERSION=${LATEST_TAG#"$TAG_PREFIX."} + PATCH=$((LATEST_VERSION + 1)) + fi + + VERSION_TAG="$MAJOR_MINOR.$PATCH" + + if [ "$MODE" == "release" ]; then + echo "$VERSION_TAG" + else + # Find the latest RC for THIS specific version + RC_PREFIX="$TAG_PREFIX.$VERSION_TAG-rc" + LATEST_RC_TAG=$(git tag -l "$RC_PREFIX.*" | sort -V | tail -n1 || echo "") + + if [ -z "$LATEST_RC_TAG" ]; then + RC=1 + else + LATEST_RC=${LATEST_RC_TAG#"$RC_PREFIX."} + RC=$((LATEST_RC + 1)) + fi + echo "$VERSION_TAG-rc.$RC" + fi + ;; + *) + echo "Unknown mode: $MODE" + exit 1 + ;; +esac