Files
spacedrive/.github/workflows/ci.yml
2022-05-15 10:35:12 +01:00

204 lines
4.8 KiB
YAML

name: CI
on:
pull_request:
push:
branches:
- main
- new-ci
paths-ignore:
- '**/.md'
workflow_dispatch:
env:
CARGO_INCREMENTAL: 1
jobs:
typescript:
name: TypeScript
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 17
- name: Install pnpm
uses: pnpm/action-setup@v2.2.1
with:
version: 7.x.x
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Perform typechecks
run: pnpm typecheck
build-js:
name: Build JS
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 17
- name: Install pnpm
uses: pnpm/action-setup@v2.2.1
with:
version: 7.x.x
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build Desktop
run: pnpm desktop build
- name: Build Web
run: pnpm web build
build-core:
name: Build Core (${{ matrix.platform }})
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: true
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install dependencies
uses: ./.github/actions/install-deps
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 17
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt, rust-src
- name: Cache Rust Dependencies
uses: Swatinem/rust-cache@v1
with:
sharedKey: core-v1-${{ hashFiles('**/Cargo.lock') }}
- name: Generate Prisma client
working-directory: core
run: cargo run -p prisma-cli --release -- generate
- name: Build Core
run: cargo build -p sdcore --release
package-desktop:
name: Package desktop (${{ matrix.platform }})
runs-on: ${{ matrix.platform }}
needs: [typescript, build-js, build-core]
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install dependencies
uses: ./.github/actions/install-deps
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 17
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt, rust-src
- name: Cache Rust Dependencies
uses: Swatinem/rust-cache@v1
with:
sharedKey: core-v1-${{ hashFiles('**/Cargo.lock') }}
- name: Install pnpm
uses: pnpm/action-setup@v2.2.1
with:
version: 7.x.x
- name: Install pnpm dependencies
run: pnpm i --frozen-lockfile
- name: Build frontend
run: pnpm desktop build
- name: Generate Prisma client
working-directory: core
run: cargo run -p prisma-cli --release -- generate
- name: Bundle
run: pnpm desktop tauri build
- name: Publish artifacts
uses: ./.github/actions/publish-desktop-artifacts
build-server:
name: Build server
runs-on: ubuntu-latest
needs: build-core
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install dependencies
uses: ./.github/actions/install-deps
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt, rust-src
- name: Cache Rust Dependencies
uses: Swatinem/rust-cache@v1
with:
sharedKey: core-v1-${{ hashFiles('**/Cargo.lock') }}
- name: Generate Prisma client
working-directory: core
run: cargo run -p prisma-cli --release -- generate
- name: Build server image
uses: ./.github/actions/build-server-image
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
deploy-server:
name: Deploy Server
runs-on: ubuntu-latest
needs: build-server
if: github.event_name != 'pull_request'
steps:
- name: Deploy Spacedrive Server to Kubernetes
env:
K8S_KUBECONFIG: ${{ secrets.K8S_KUBECONFIG }}
run: |
mkdir -p ~/.kube
echo "$K8S_KUBECONFIG" > ~/.kube/config 2>&1
kubectl rollout restart deployment/sdserver-deployment