diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..a406e54 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,46 @@ +name: Publish + +on: + push: + tags: + - v* + +jobs: + version: + name: Version + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Check version + run: | + version=`cargo metadata | jq -r '.packages[] | select(.name == "${{ env.CRATE_NAME }}") | .version'` + version=v"${version}" + [ "${version}" ] && [ "${version}" == "${{ github.ref_name }}" ] + + check: + name: Check + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Build + run: cargo build --verbose + - name: Format + run: cargo fmt --all -- --check + - name: Clippy + run: cargo clippy + - name: Run tests + run: cargo test --verbose + + publish: + name: Publish + needs: [version, check] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Publish + uses: katyo/publish-crates@v2 + with: + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}