Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
push:
branches:
- main
- feature
- "migrate/**"
pull_request:
branches:
- main

permissions:
contents: read

env:
CARGO_TERM_COLOR: always

jobs:
check:
name: Rust checks
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Check formatting
run: cargo fmt --all -- --check

- name: Check compilation
run: cargo check --all-targets

- name: Run tests
run: cargo test --all-targets
97 changes: 97 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Build and publish release

on:
push:
tags:
- "v*"
workflow_dispatch:

permissions:
contents: write

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl
archive: hat-linux-x86_64-musl.tar.gz
extension: tar.gz
- target: x86_64-pc-windows-gnu
archive: hat-windows-x86_64.zip
extension: zip

steps:
- name: Check out source
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Install Linux musl linker
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install --yes musl-tools

- name: Install Windows linker
if: matrix.target == 'x86_64-pc-windows-gnu'
run: sudo apt-get update && sudo apt-get install --yes mingw-w64

- name: Build client and server
run: |
cargo build --release \
--target "${{ matrix.target }}" \
--bin client \
--bin server

- name: Package Linux binaries
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
mkdir -p dist/hat-linux-x86_64-musl
cp "target/${{ matrix.target }}/release/client" dist/hat-linux-x86_64-musl/
cp "target/${{ matrix.target }}/release/server" dist/hat-linux-x86_64-musl/
cp README.md dist/hat-linux-x86_64-musl/ 2>/dev/null || true
tar -C dist -czf "dist/${{ matrix.archive }}" hat-linux-x86_64-musl

- name: Package Windows binaries
if: matrix.target == 'x86_64-pc-windows-gnu'
run: |
mkdir -p dist/hat-windows-x86_64
cp "target/${{ matrix.target }}/release/client.exe" dist/hat-windows-x86_64/
cp "target/${{ matrix.target }}/release/server.exe" dist/hat-windows-x86_64/
cp README.md dist/hat-windows-x86_64/ 2>/dev/null || true
cd dist
zip -r "${{ matrix.archive }}" hat-windows-x86_64

- name: Upload packaged binaries
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive }}
path: dist/${{ matrix.archive }}
if-no-files-found: error

release:
name: Publish GitHub release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download packaged binaries
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true

- name: Publish release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
fail_on_unmatched_files: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/config.toml
Loading