Skip to content

Commit

Permalink
Add CI and more cargo metadata
Browse files Browse the repository at this point in the history
main not master
  • Loading branch information
jamilbk committed Apr 6, 2023
1 parent f2084b9 commit 834d738
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 0 deletions.
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:
- 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
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

0 comments on commit 834d738

Please sign in to comment.