From d16a0361e7b35099076a9d1466b30c072e3f6ce0 Mon Sep 17 00:00:00 2001 From: tonytown Date: Thu, 24 Sep 2026 19:00:28 +0800 Subject: [PATCH 1/2] add CI checks --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6ef6fca --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.gitignore b/.gitignore index ea8c4bf..fabfb87 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/config.toml From 9f2e33d217fa2c6f7b35da937534149253a07c5e Mon Sep 17 00:00:00 2001 From: tonytown Date: Thu, 24 Sep 2026 19:11:42 +0800 Subject: [PATCH 2/2] add release build for Linux and Windows --- .github/workflows/release.yml | 97 +++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4f28d5f --- /dev/null +++ b/.github/workflows/release.yml @@ -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