Use composite actions

This commit is contained in:
Maximilian Ammann 2022-04-20 14:55:29 +02:00
parent 3b37875a5b
commit 33f48a0a1b
16 changed files with 219 additions and 224 deletions

26
.github/actions/android/action.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: android
description: Build for android
runs:
using: "composite"
steps:
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install just
shell: bash
run: cargo install just
- name: Build
shell: bash
run: just build-apk
- uses: actions/upload-artifact@v2
with:
name: maplibre-rs.apk
path: target/debug/apk/maplibre-rs-demo.apk

21
.github/actions/check/action.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: check
description: Check
runs:
using: "composite"
steps:
- name: Setup
shell: bash
run: |
rustup component add rustfmt
- name: Format
shell: bash
run: cargo fmt --all -- --check
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Clippy
shell: bash
run: |
rustup component add clippy
cargo clippy --all-targets --all-features

26
.github/actions/deploy/action.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: deploy
description: Deploy on maxammann.org
inputs:
source:
required: true
description: TODO
destination:
required: true
description: TODO
key:
required: true
description: TODO
runs:
using: "composite"
steps:
- name: Deploy to maxammann.org
env:
SSH_KEY: ${{ inputs.key }}
shell: bash
run: |
echo "$SSH_KEY" > id_rsa
chmod 600 id_rsa
ssh -o StrictHostKeyChecking=no -i id_rsa max@maxammann.org 'mkdir -p ~/public_html/maplibre-rs/${{ inputs.destination }} && find ~/public_html/maplibre-rs/${{ inputs.destination }} -type f -not -name ".htaccess" -delete'
rsync -e "ssh -o StrictHostKeyChecking=no -i id_rsa" -r "${{ inputs.source }}" max@maxammann.org:~/public_html/maplibre-rs/${{ inputs.destination }}/

26
.github/actions/desktop/action.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: desktop
description: Build for desktop
runs:
using: "composite"
steps:
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Build
shell: bash
run: cargo build --example desktop
- uses: actions/upload-artifact@v2
with:
name: maplibre-rs
path: target/debug/maplibre

30
.github/actions/docs/action.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: docs
description: Build documentation
runs:
using: "composite"
steps:
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1
- name: Install mdbook
shell: bash
run: |
cargo install mdbook --no-default-features --vers "^0.4.0"
- name: Install Dependencies
shell: bash
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Build
working-directory: docs
shell: bash
run: mdbook build
- name: API Documentation
shell: bash
run: cargo doc --no-deps --workspace --lib --all-features --document-private-items

22
.github/actions/webgl/action.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: webgl
description: Build for webgl
runs:
using: "composite"
steps:
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install just
shell: bash
run: cargo install just
- name: Build
shell: bash
run: just webpack-webgl-production

22
.github/actions/webgpu/action.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: webgpu
description: Build for webgpu
runs:
using: "composite"
steps:
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install just
shell: bash
run: cargo install just
- name: Build
shell: bash
run: just webpack-production

View File

@ -1,32 +0,0 @@
name: android
on: [ workflow_dispatch ]
jobs:
build-aarch64-android:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install just
run: cargo install just
- name: Build
run: just build-apk
- uses: actions/upload-artifact@v2
with:
name: maplibre-rs.apk
path: target/debug/apk/maplibre-rs-demo.apk

View File

@ -1,23 +0,0 @@
name: check
on: [ workflow_dispatch ]
jobs:
check-format:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Setup
run: |
rustup component add rustfmt
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: |
rustup component add clippy
cargo clippy --all-targets --all-features

View File

@ -1,22 +0,0 @@
on:
workflow_call:
inputs:
source:
required: true
type: string
destination:
required: true
type: string
jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- name: Deploy to maxammann.org
env:
SSH_KEY: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}
run: |
echo "$SSH_KEY" > id_rsa
chmod 600 id_rsa
ssh -o StrictHostKeyChecking=no -i id_rsa max@maxammann.org 'mkdir -p ~/public_html/maplibre-rs/${{ inputs.destination }} && find ~/public_html/maplibre-rs/${{ inputs.destination }} -type f -not -name ".htaccess" -delete'
rsync -e "ssh -o StrictHostKeyChecking=no -i id_rsa" -r "${{ inputs.source }}" max@maxammann.org:~/public_html/maplibre-rs/${{ inputs.destination }}/

View File

@ -1,32 +0,0 @@
name: desktop
on: [ workflow_dispatch ]
jobs:
build-x86:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Dependencies
run: sudo apt-get install -y libwayland-dev libxkbcommon-dev # Required for winit
- name: Build
run: cargo build --example desktop
- uses: actions/upload-artifact@v2
with:
name: maplibre-rs
path: target/debug/maplibre

View File

@ -1,32 +0,0 @@
name: docs
on: [ workflow_dispatch ]
jobs:
book:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
working-directory: docs
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1
- name: Install mdbook
run: |
cargo install mdbook --no-default-features --vers "^0.4.0"
- name: Build
run: mdbook build
- name: API Documentation
run: cargo doc --no-deps --workspace --lib --all-features --document-private-items

View File

@ -1,45 +1,58 @@
name: Rust
name: Build & Deploy
on: [ workflow_dispatch, push ]
on:
workflow_dispatch:
push:
branches:
- main
jobs:
run-check:
runs-on: ubuntu-20.04
steps:
- uses: ./.github/workflows/check.yml
- uses: actions/checkout@v2
- uses: ./.github/actions/check
build-desktop:
runs-on: ubuntu-20.04
steps:
- uses: ./.github/workflows/desktop.yml
- uses: actions/checkout@v2
- uses: ./.github/actions/desktop
build-android:
runs-on: ubuntu-20.04
steps:
- uses: ./.github/workflows/android.yml
build-web:
- uses: actions/checkout@v2
- uses: ./.github/actions/android
build-deploy-web:
runs-on: ubuntu-20.04
steps:
- uses: ./.github/workflows/webgpu.yml
- uses: ./.github/workflows/deploy.yml
- uses: actions/checkout@v2
- uses: ./.github/actions/webgpu
- uses: ./.github/actions/deploy
with:
source: dist/demo/.
source: web/dist/demo/.
destination: webgpu
- uses: ./.github/workflows/webgl.yml
- uses: ./.github/workflows/deploy.yml
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}
- uses: ./.github/actions/webgl
- uses: ./.github/actions/deploy
with:
source: dist/demo/.
source: web/dist/demo/.
destination: webgl
build-docs:
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}
build-deploy-docs:
runs-on: ubuntu-20.04
steps:
- uses: ./.github/workflows/docs.yml
- uses: ./.github/workflows/deploy.yml
- uses: actions/checkout@v2
- uses: ./.github/actions/docs
- uses: ./.github/actions/deploy
with:
source: target/x86_64-unknown-linux-gnu/doc/.
destination: api-docs
- uses: ./.github/workflows/deploy.yml
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}
- uses: ./.github/actions/deploy
with:
source: book/.
source: docs/book/.
destination: docs
key: ${{ secrets.SSH_KEY_MAXAMMANN_ORG }}

View File

@ -1,26 +1,35 @@
name: Pull Request
on: [ workflow_dispatch, pull_request ]
on:
workflow_dispatch:
pull_request:
branches:
- main
jobs:
run-check:
runs-on: ubuntu-20.04
steps:
- uses: ./.github/workflows/check.yml
- uses: actions/checkout@v2
- uses: ./.github/actions/check
build-desktop:
runs-on: ubuntu-20.04
steps:
- uses: ./.github/workflows/desktop.yml
- uses: actions/checkout@v2
- uses: ./.github/actions/desktop
build-android:
runs-on: ubuntu-20.04
steps:
- uses: ./.github/workflows/android.yml
- uses: actions/checkout@v2
- uses: ./.github/actions/android
build-web:
runs-on: ubuntu-20.04
steps:
- uses: ./.github/workflows/webgpu.yml
- uses: ./.github/workflows/webgl.yml
- uses: actions/checkout@v2
- uses: ./.github/actions/webgpu
- uses: ./.github/actions/webgl
build-docs:
runs-on: ubuntu-20.04
steps:
- uses: ./.github/workflows/docs.yml
- uses: actions/checkout@v2
- uses: ./.github/actions/docs

View File

@ -1,29 +0,0 @@
name: web
on: [ workflow_dispatch ]
jobs:
build-wasm-webgl:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
working-directory: web
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install just
run: cargo install just
- name: Build
run: just webpack-webgl-production

View File

@ -1,30 +0,0 @@
name: web
on: [ workflow_dispatch ]
jobs:
build-wasm-webgpu:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
working-directory: web
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates*
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install just
run: cargo install just
- name: Build
run: just webpack-production