diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d380db1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,73 @@ +on: + push: + branches: [ main ] + pull_request: + branches: + - main + +name: CI + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + env: + RUSTFLAGS: -D warnings + steps: + - uses: actions/checkout@v2 + with: + # By default actions/checkout checks out a merge commit. Check out the PR head instead. + # https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + components: rustfmt, clippy + - uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c + - name: Lint (clippy) + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all-features --all-targets + - name: Lint (rustfmt) + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --check + - name: Check semver + uses: obi1kenobi/cargo-semver-checks-action@v2 + + build: + name: Build and test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + rust-version: [ stable ] + fail-fast: false + env: + RUSTFLAGS: -D warnings + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust-version }} + override: true + - name: Build all targets with all features + uses: actions-rs/cargo@v1 + with: + command: build + args: --all-targets --all-features + - name: Install latest nextest release + uses: taiki-e/install-action@nextest + - name: Test with latest nextest release + uses: actions-rs/cargo@v1 + with: + command: nextest + args: run --all-features diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2986587 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,81 @@ +name: publish +on: + push: + tags: + - "v*" +env: +jobs: + build_and_test_linux: + name: Build and Test (Linux) + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + + - uses: taiki-e/install-action@nextest + - name: 'Build and test' + run: cargo nextest run --workspace --all-features + + publish_gh_release: + name: Publish GH release + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.release.outputs.upload_url }} + release_version: ${{ env.RELEASE_VERSION }} + steps: + - name: Get the release version from the tag + shell: bash + if: env.RELEASE_VERSION == '' + run: | + # See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027 + echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + echo "version is: ${{ env.RELEASE_VERSION }}" + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Create GitHub release + id: release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.RELEASE_VERSION }} + release_name: ${{ env.RELEASE_VERSION }} + + crates_io_publish: + name: Publish (crates.io) + needs: + - build_and_test_linux + + runs-on: ubuntu-latest + timeout-minutes: 25 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + + - name: cargo-release Cache + id: cargo_release_cache + uses: actions/cache@v4 + with: + path: ~/.cargo/bin/cargo-release + key: ${{ runner.os }}-cargo-release + + - run: cargo install cargo-release + if: steps.cargo_release_cache.outputs.cache-hit != 'true' + + - name: cargo login + run: cargo login ${{ secrets.CRATES_IO_API_TOKEN }} + + # allow-branch HEAD is because GitHub actions switches + # to the tag while building, which is a detached head + - name: "cargo release publish" + run: |- + cargo release \ + publish \ + --workspace \ + --all-features \ + --allow-branch HEAD \ + --no-confirm \ + --execute diff --git a/README.md b/README.md index 3e6e7a0..8cb5de7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # smooth-operator +[![Crates.io](https://img.shields.io/crates/v/smooth-operator.svg)](https://crates.io/crates/smooth-operator) +[![Documentation](https://docs.rs/smooth-operator/badge.svg)](https://docs.rs/smooth-operator) + Procedural macro that transforms regular infix arithmetic expressions into checked arithmetic expressions.