From 8e054330da894b2024a78738796d649036390cd2 Mon Sep 17 00:00:00 2001 From: Keming Date: Thu, 17 Oct 2024 15:00:20 +0800 Subject: [PATCH] add ci Signed-off-by: Keming --- .github/workflows/release.yml | 26 ++++++++++++++++++ .github/workflows/rust.yml | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..eb98798 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: crates.io Publish + +on: + release: + types: [created] + workflow_dispatch: + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + publish: + name: "Publish Rust Package" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - name: Publish Crates + env: + CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }} + run: | + cargo login $CARGO_TOKEN + cargo publish diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..9a49213 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,50 @@ +name: Rust + +on: + push: + branches: [ "main" ] + paths: + - '.github/workflows/rust.yml' + - 'src/**' + - 'Cargo.toml' + - 'Cargo.lock' + pull_request: + branches: [ "main" ] + paths: + - '.github/workflows/rust.yml' + - 'src/**' + - 'Cargo.toml' + - 'Cargo.lock' + merge_group: + +env: + CARGO_TERM_COLOR: always + +jobs: + lint: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Install lint tools + run: rustup component add rustfmt clippy + - name: Lint + run: | + cargo fmt -- --check + cargo clippy -- -D warnings + + test: + strategy: + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - name: Test + run: cargo test + \ No newline at end of file