From ca9fbb919f3de84e9eb904adfe12d047c5df5cd8 Mon Sep 17 00:00:00 2001 From: Mingwei Zhang Date: Sat, 3 Feb 2024 10:02:16 -0800 Subject: [PATCH] add build and release ci config --- .github/workflows/build.yml | 26 +++++++++++++++++++++ .github/workflows/release.yml | 43 +++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e69de29..77f0183 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: Build + +on: + push: + branches: [ main ] + paths-ignore: + - '**.md' + pull_request: + branches: [ main ] + paths-ignore: + - '**.md' + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Build default + run: cargo build + - name: Run format check + run: cargo fmt --check \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e69de29..584c78f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Release + +permissions: + contents: write + +on: + push: + tags: + - v[0-9]+.* + +jobs: + build-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build + run: cargo build --verbose + - name: cargo fmt test + run: cargo fmt --check + + create-release: + needs: build-test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: taiki-e/create-gh-release-action@v1 + with: + # (optional) Path to changelog. + changelog: CHANGELOG.md + # (required) GitHub token for creating GitHub Releases. + token: ${{ secrets.GITHUB_TOKEN }} + + cargo-publish: + needs: create-release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Publish to crates.io + run: > + cargo publish + --all-features + --verbose + --token ${{ secrets.CARGO_REGISTRY_TOKEN }} \ No newline at end of file