on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v5
- uses: automas-dev/reusable-workflows/increment_version@v1.0
id: version
with:
dry-run: true
- name: Get Next Version
env:
VERSION: ${{ steps.version.outputs.version }}
run: sed -i "/version/c\version = \"$VERSION\"" Cargo.toml
- name: Build
run: cargo build --verbose --release
- name: Lint
run: cargo fmt --verbose --check
- name: Test
run: cargo test --verbose
- name: Authenticate crates.io
uses: rust-lang/crates-io-auth-action@v1
if: github.ref == 'refs/heads/main'
id: auth
- name: Publish
if: github.ref == 'refs/heads/main'
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: cargo publish --verbose --allow-dirty
- name: Create Tag
uses: automas-dev/reusable-workflows/increment_version@v1.0
if: github.ref == 'refs/heads/main'
with:
tag: ${{ steps.version.outputs.version }}