From ed1f30c100d3266c81a8b39b0e87ef88d21a6477 Mon Sep 17 00:00:00 2001 From: leonlux Date: Thu, 15 Feb 2024 09:05:14 +0100 Subject: [PATCH] implement automatic publishing of crate when a tagged commit is pushed. --- .github/workflows/publish.yml | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..fa3caa9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,56 @@ +on: + push: + tags: + - '*' + +jobs: + test: + name: Build and Test Project + runs-on: ubuntu-latest + + env: + CARGO_TERM_COLORS: always + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: rustfmt, clippy + + - name: Setup Cargo Cache + uses: actions/cache@v3 + continue-on-error: false + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + + - name: Setup Protobuf Compiler + uses: arduino/setup-protoc@v2 + + - name: Run Unit Tests + run: cargo test + + publish: + name: Publish crate to crates.io + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - uses: katyo/publish-crates@v2 + with: + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} \ No newline at end of file