-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b59b72
commit 5124bc3
Showing
12 changed files
with
436 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,112 @@ | ||
name: "Build and release" | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
get-tag: | ||
name: "Get tag from package version" | ||
frontend: | ||
name: Build frontend assets | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
pkg-version: ${{ steps.pkg-version.outputs.PKG_VERSION }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: actions/checkout@v3 | ||
- run: rustup toolchain install stable --profile minimal | ||
- run: rustup target add wasm32-unknown-unknown | ||
- uses: jetli/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Get tag | ||
id: pkg-version | ||
shell: bash | ||
run: | | ||
echo PKG_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' backend/Cargo.toml) >> $GITHUB_OUTPUT | ||
version: 'v0.16.0' | ||
|
||
- name: Set tag | ||
shell: bash | ||
run: | | ||
git tag v${{ steps.pkg-version.outputs.PKG_VERSION }} && git push --tags | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
frontend/target/ | ||
key: frontend-${{ hashFiles('frontend/Cargo.toml') }} | ||
restore-keys: frontend- | ||
|
||
- name: Build frontend | ||
run: trunk build | ||
working-directory: frontend | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: frontend-build-${{ github.sha }} | ||
path: frontend/dist | ||
|
||
build: | ||
name: "Build and release" | ||
needs: "get-tag" | ||
runs-on: ubuntu-22.04 | ||
name: Binaries for ${{ matrix.name }} | ||
needs: frontend | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
name: | ||
- linux-x86-64-gnu | ||
- linux-armv7-gnu | ||
- linux-arm64-gnu | ||
- linux-x86-64-musl | ||
- linux-arm64-musl | ||
include: | ||
- name: linux-x86-64-gnu | ||
os: ubuntu-22.04 | ||
target: x86_64-unknown-linux-gnu | ||
platform: ~ | ||
cross: false | ||
|
||
- name: linux-armv7-gnu | ||
os: ubuntu-22.04 | ||
target: armv7-unknown-linux-gnueabihf | ||
platform: ~ | ||
cross: true | ||
|
||
- name: linux-arm64-gnu | ||
os: ubuntu-22.04 | ||
target: aarch64-unknown-linux-gnu | ||
platform: ~ | ||
cross: true | ||
|
||
- name: linux-x86-64-musl | ||
os: ubuntu-22.04 | ||
target: x86_64-unknown-linux-musl | ||
platform: amd64 | ||
cross: true | ||
|
||
- name: linux-arm64-musl | ||
os: ubuntu-22.04 | ||
target: aarch64-unknown-linux-musl | ||
platform: arm64 | ||
cross: true | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Cache build assets | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
backend/target/ | ||
frontend/target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- name: Configure Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
target: wasm32-unknown-unknown | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- name: Download trunk | ||
uses: jetli/[email protected] | ||
with: | ||
version: 'latest' | ||
|
||
- name: Build target amd64 | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
use-cross: true | ||
command: build | ||
args: --release --target x86_64-unknown-linux-musl --manifest-path backend/Cargo.toml | ||
|
||
- name: Copy binary | ||
run: | | ||
mkdir bin | ||
cp target/x86_64-unknown-linux-musl/release/mailcrab-backend bin/amd64 | ||
working-directory: ./backend | ||
|
||
- name: Cargo clean | ||
run: cargo clean | ||
working-directory: ./backend | ||
|
||
- name: Build target arm64 | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
use-cross: true | ||
command: build | ||
args: --release --target aarch64-unknown-linux-musl --manifest-path backend/Cargo.toml | ||
|
||
- name: Copy binary | ||
run: | | ||
cp target/aarch64-unknown-linux-musl/release/mailcrab-backend bin/arm64 | ||
working-directory: ./backend | ||
|
||
- name: Build frontend | ||
run: trunk build | ||
working-directory: ./frontend | ||
|
||
- name: Build docker image | ||
run: docker buildx build --push --platform=linux/amd64,linux/arm64 . -t marlonb/mailcrab:latest -t marlonb/mailcrab:${{ needs.get-tag.outputs.pkg-version }} | ||
- uses: actions/checkout@v3 | ||
- run: rustup toolchain install stable --profile minimal | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: frontend-build-${{ github.sha }} | ||
path: frontend/dist | ||
|
||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
backend/target/ | ||
key: backend-${{ matrix.name }}-${{ hashFiles('backend/Cargo.toml') }} | ||
restore-keys: backend-${{ matrix.name }}- | ||
|
||
- run: cargo install cross --git https://github.com/cross-rs/cross || true | ||
|
||
- name: Build | ||
if: ${{ !matrix.cross }} | ||
run: cargo build --release --locked --target ${{ matrix.target }} --manifest-path backend/Cargo.toml | ||
|
||
- name: Cross build | ||
if: ${{ matrix.cross }} | ||
run: cross build --release --locked --target ${{ matrix.target }} --manifest-path backend/Cargo.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,62 +4,27 @@ on: | |
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
check: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Cache build assets | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
backend/target/ | ||
frontend/target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- name: Configure Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
target: wasm32-unknown-unknown | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Download trunk | ||
uses: jetli/[email protected] | ||
with: | ||
version: 'latest' | ||
|
||
- name: Build target amd64 | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
use-cross: true | ||
command: build | ||
args: --release --target x86_64-unknown-linux-musl --manifest-path backend/Cargo.toml | ||
|
||
- name: Cargo clean | ||
run: cargo clean | ||
working-directory: ./backend | ||
|
||
- name: Build target arm64 | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
use-cross: true | ||
command: build | ||
args: --release --target aarch64-unknown-linux-musl --manifest-path backend/Cargo.toml | ||
|
||
- name: Build frontend | ||
run: trunk build | ||
working-directory: ./frontend | ||
- uses: actions/checkout@v3 | ||
- run: rustup toolchain install stable --profile minimal | ||
- run: rustup component add clippy | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
frontend/target/ | ||
backend/target/ | ||
key: check-${{ hashFiles('**/Cargo.toml') }} | ||
restore-keys: check- | ||
- run: cargo check --manifest-path backend/Cargo.toml | ||
- run: cargo check --manifest-path frontend/Cargo.toml | ||
- run: cargo clippy --manifest-path backend/Cargo.toml | ||
- run: cargo clippy --manifest-path frontend/Cargo.toml | ||
- run: cargo fmt --check --manifest-path backend/Cargo.toml | ||
- run: cargo fmt --check --manifest-path frontend/Cargo.toml |
Oops, something went wrong.