126 lines
3.2 KiB
YAML
126 lines
3.2 KiB
YAML
name: test and deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
build-web:
|
|
runs-on: ubuntu-latest
|
|
name: Build WASM
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: https://gitea.sheep-ghoul.ts.net
|
|
|
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
|
|
- name: Install wasm-pack
|
|
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
|
|
|
- name: Test WASM in-browser
|
|
working-directory: ./draught_web
|
|
run: wasm-pack test --firefox --chrome --headless
|
|
|
|
- name: Build Rust for WASM
|
|
working-directory: ./draught_web
|
|
run: wasm-pack build --release
|
|
|
|
- name: Install Node
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Install Node Modules
|
|
run: npm ci
|
|
working-directory: ./draught_web/www
|
|
|
|
- name: Build Js
|
|
run: npm run build --if-present
|
|
working-directory: ./draught_web/www
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
name: Build Native
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: https://gitea.sheep-ghoul.ts.net
|
|
|
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
|
|
- name: Build Binary
|
|
run: cargo build
|
|
working-directory: ./draught
|
|
|
|
publishLib:
|
|
runs-on: ubuntu-latest
|
|
name: Package Library
|
|
needs: [ build-web ] # for ignoring bad builds
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: https://gitea.sheep-ghoul.ts.net
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Add SarGit Repo
|
|
run: |
|
|
cat <<EOF > ~/.cargo/config.toml
|
|
[registry]
|
|
default = "sargit"
|
|
|
|
[registries.sargit]
|
|
index = "sparse+https://git.sarsoo.xyz/api/packages/${{ secrets.DOCKERHUB_USERNAME }}/cargo/"
|
|
|
|
[net]
|
|
git-fetch-with-cli = true
|
|
EOF
|
|
|
|
- name: Add SarGit Credentials
|
|
run: |
|
|
cat <<EOF > ~/.cargo/credentials.toml
|
|
[registries.sargit]
|
|
token = "Bearer ${{ secrets.DOCKERHUB_TOKEN }}"
|
|
EOF
|
|
|
|
- name: Cargo Publish
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: publish
|
|
args: --package draughtlib
|
|
|
|
package:
|
|
runs-on: ubuntu-latest
|
|
name: Package Container
|
|
needs: [build-web] # for ignoring bad builds
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: https://gitea.sheep-ghoul.ts.net
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: gitea.sheep-ghoul.ts.net
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build & Push Container
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: true
|
|
tags: gitea.sheep-ghoul.ts.net/sarsoo/draught:latest
|
|
context: . |