Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI and more cargo metadata #7

Merged
merged 5 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -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/*']
35 changes: 35 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build

on:
pull_request:
push:
branches:
- master

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
39 changes: 39 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}


5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name = "ndisapi"
version = "0.1.0"
edition = "2021"
authors = ["Vadim Smirnov <vadim@ntkernel.com>"]
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

Expand Down