Skip to content

Commit

Permalink
build monorepo once
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Dec 17, 2024
1 parent 76a953d commit e61f030
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 74 deletions.
114 changes: 41 additions & 73 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,105 +13,87 @@ on:
- 'apps/gui/**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

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

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

- name: Build All Packages
run: pnpm -r run build

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: built-packages
path: |
libraries/
internal/
apps/gui/
publish:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
include:
- package: 'nostrings'
nodeVersion: '20'
- package: 'announce'
nodeVersion: '20'
- package: 'logger'
nodeVersion: '20'
- package: 'seed'
nodeVersion: '20'
- package: 'utils'
nodeVersion: '20'
- package: 'nwcache'
nodeVersion: '20'
- package: 'controlflow'
nodeVersion: '20'
- package: 'publisher'
nodeVersion: '20'
- package: 'nocap'
nodeVersion: '20'
- package: 'nocap-websocket-adapter-default'
nodeVersion: '20'
- package: 'nocap-websocket-browser-adapter-default'
nodeVersion: '20'
- package: 'nocap-info-adapter-default'
nodeVersion: '20'
- package: 'nocap-dns-adapter-default'
nodeVersion: '20'
- package: 'nocap-geo-adapter-default'
nodeVersion: '20'
- package: 'nocap-ssl-adapter-default'
nodeVersion: '20'
- package: 'nocap-every-adapter-default'
nodeVersion: '20'
- package: 'gui'
nodeVersion: '20'

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.nodeVersion }}
node-version: 20

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

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

- name: Build All Packages
run: pnpm -r run build

# Deploy GUI steps only if the current matrix package is 'gui'
- name: Install jq
if: matrix.package == 'gui'
run: sudo apt-get update && sudo apt-get install -y jq

- name: Get package version (GUI)
if: matrix.package == 'gui'
id: get_version
run: |
VERSION=$(jq -r '.version' ./apps/gui/package.json)
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: built-packages
path: .

- name: Prepare Directories (GUI)
if: matrix.package == 'gui'
run: |
VERSION=${{ env.VERSION }}
echo "Deploying version $VERSION"
ssh -i ${{ secrets.GUI_SSH_KEY }} -o StrictHostKeyChecking=no ${{ secrets.GUI_HOST_USER }}@${{ secrets.GUI_HOST_IP }} << EOF
set -e
mkdir -p /var/www/${VERSION}
rm -rf /var/www/html/
ln -s /var/www/${VERSION} /var/www/html
EOF
- name: Upload Build (GUI)
if: matrix.package == 'gui'
run: |
scp -i ${{ secrets.GUI_SSH_KEY }} -o StrictHostKeyChecking=no -r ./apps/gui/dist/* ${{ secrets.GUI_HOST_USER }}@${{ secrets.GUI_HOST_IP }}:/var/www/html/${{ env.VERSION }}
- name: Install Dependencies
run: pnpm install --frozen-lockfile --ignore-scripts

- name: Find Package
id: find_package
run: |
PKG_PATH=$(find libraries -type d -name "${{ matrix.package }}" -print -quit)
if [ -z "$PKG_PATH" ]; then
PKG_PATH=$(find internal -type d -name "${{ matrix.package }}" -print -quit)
fi
if [ -z "$PKG_PATH" ]; then
PKG_PATH=$(find apps -type d -name "${{ matrix.package }}" -print -quit)
fi
PKG_PATH=$(find libraries internal apps -type d -name "${{ matrix.package }}" -print -quit)
echo "the_path=$PKG_PATH" >> "$GITHUB_OUTPUT"
- name: Publish Package
Expand All @@ -129,25 +111,12 @@ jobs:
RELEASE_SLUG="${{ matrix.package }}@v${{ steps.publish.outputs.version }}"
echo "release_slug=$RELEASE_SLUG" >> "$GITHUB_OUTPUT"
- name: Check for Tag
id: slug_exists
run: |
git fetch --tags
TAG="${{ steps.meta.outputs.release_slug }}"
if git show-ref --tags --verify --quiet "refs/tags/${TAG}"; then
echo "release_slug_exists=true" >> "$GITHUB_OUTPUT"
else
echo "release_slug_exists=false" >> "$GITHUB_OUTPUT"
- name: Archive Subdirectory
if: steps.slug_exists.outputs.release_slug_exists != 'true'
id: archive
run: |
zip -r "${{ steps.meta.outputs.release_slug }}.zip" "${{ steps.find_package.outputs.the_path }}"
- name: Create Release ${{ steps.meta.outputs.release_slug }}
if: steps.publish.outputs.type != 'none' && steps.publish.outputs.dry_run != 'true' && steps.slug_exists.outputs.release_slug_exists != 'true'
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -158,8 +127,7 @@ jobs:
draft: false
prerelease: true

- name: Upload Release Asset ${{ steps.meta.outputs.release_slug }}.zip
if: steps.slug_exists.outputs.release_slug_exists != 'true'
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion apps/gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"tailwind-merge": "^2.4.0",
"tailwind-variants": "^0.2.1",
"tailwindcss": "^3.4.4",
"tslib": "^2.4.1",
"tslib": "^2.7.0",
"typescript": "^5.7.2",
"vite": "^5.0.11",
"vite-plugin-copy": "^0.1.6",
Expand Down

0 comments on commit e61f030

Please sign in to comment.