From 834d738552715374bff5c6ad3246158a9df749bf Mon Sep 17 00:00:00 2001 From: Jamil Bou Kheir Date: Wed, 5 Apr 2023 16:01:12 -0500 Subject: [PATCH] Add CI and more cargo metadata main not master --- .github/pr-labeler.yml | 11 +++++++ .github/release-drafter.yml | 35 ++++++++++++++++++++ .github/workflows/build.yml | 60 +++++++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 39 +++++++++++++++++++++++ Cargo.toml | 5 +++ 5 files changed, 150 insertions(+) create mode 100644 .github/pr-labeler.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/pr-labeler.yml b/.github/pr-labeler.yml new file mode 100644 index 0000000..e586a23 --- /dev/null +++ b/.github/pr-labeler.yml @@ -0,0 +1,11 @@ +feature: ['feat/*', 'feature/*'] +chore: ['chore/*'] +bug: ['fix/*', 'bug/*'] +build: ['build/*'] +ci: ['ci/*'] +docs: ['docs/*'] +style: ['style/*'] +refactor: ['refactor/*'] +perf: ['perf/*'] +test: ['test/*'] +revert: ['revert/*'] diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..9624695 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,35 @@ +name-template: "$RESOLVED_VERSION" +tag-template: "$RESOLVED_VERSION" +categories: + - title: "✨ Features" + labels: + - "feature" + - "enhancement" + - title: "🐛 Bug Fixes" + labels: + - "fix" + - "bugfix" + - "bug" + - title: "🧰 Maintenance" + label: + - "chore" + - "dependencies" + - title: "📝 Documentation" + label: "docs" +exclude-labels: + - "skip-changelog" +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - "major" + minor: + labels: + - "minor" + patch: + labels: + - "patch" + default: patch +template: | + $CHANGES diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0112f54 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,60 @@ +name: build + +on: + pull_request: + push: + branches: + - main + +env: + RUSTFLAGS: -Dwarnings + CARGO_NET_GIT_FETCH_WITH_CLI: true + +jobs: + draft-release: + runs-on: ubuntu-latest + outputs: + tag_name: ${{ steps.release_drafter.outputs.tag_name }} + steps: + - uses: release-drafter/release-drafter@v5 + id: release_drafter + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build: + name: Build + strategy: + matrix: + rust: [stable, nightly] + runs-on: + - windows-2019 + - windows-2022 + runs-on: ${{ matrix.runs-on }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/.package-cache + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Setup toolchain + run: | + rustup update --no-self-update ${{ matrix.rust }} + rustup default ${{ matrix.rust }} + rustup component add clippy + - name: Run cargo static analysis checks + run: | + cargo check + cargo clippy -- -D clippy::all + cargo test + - name: Build crate + run: | + cargo publish --dry-run diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..d3405d8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,39 @@ +name: Publish crate + +on: + release: + types: [published] + +jobs: + publish: + runs-on: windows-2022 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Update toolchain + run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }} && rustup component add clippy + - name: Run cargo static analysis checks + run: | + cargo check + cargo clippy --all-targets --all-features -- -D clippy::all + cargo test + - name: Setup toolchain + run: | + rustup update --no-self-update ${{ matrix.rust }} + rustup default ${{ matrix.rust }} + rustup component add clippy + rustup target add aarch64-pc-windows-msvc i686-pc-windows-msvc x86_64-pc-windows-msvc + - name: Sanity check tag equals crate version + run: | + pkg_version=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2); exit; }' Cargo.toml) + if [[ "${{ github.ref }}" -eq "$pkg_version" ]]; then + echo "Github ref ${{ github.ref }} equals from parsed package version $pkg_version. Continuing..." + else + echo "Github ref ${{ github.ref }} differs from parsed package version $pkg_version! Aborting..." + exit 1 + fi + - name: Publish to crates.io + run: | + cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} + + diff --git a/Cargo.toml b/Cargo.toml index 005b106..8b8d595 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,11 @@ name = "ndisapi" version = "0.1.0" edition = "2021" authors = ["Vadim Smirnov "] +description = "NDIS API bindings for Rust" +license = "Apache-2.0" +documentation = "https://docs.rs/ndisapi" +repository = "https://github.com/firezone/ndisapi" +readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html