-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): add ci workflows and actions
- Loading branch information
Showing
6 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: "publish-rust" | ||
description: "Publishes Rust library to crates.io" | ||
inputs: | ||
crates-token: | ||
description: "used for authenticating towards crates.io" | ||
required: true | ||
version: | ||
description: "the version to release under (e.g. `1.2.3-dev.1`)" | ||
required: true | ||
dry-run: | ||
description: "'true' = only log potential result; 'false' = publish'" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup Rust | ||
uses: "./.github/actions/rust/rust-setup" | ||
with: | ||
os: ${{ runner.os }} | ||
job: ${{ github.job }} | ||
|
||
- name: Install cargo-release | ||
shell: bash | ||
run: cargo install --version ^0.21 cargo-release | ||
|
||
- name: Publish library to crates.io | ||
shell: bash | ||
run: | | ||
echo "dry-run: '${{ inputs.dry-run }}'" | ||
echo "version: '${{ inputs.version }}'" | ||
cargo release --workspace --token ${{ inputs.crates-token }} --isolated --no-dev-version --no-push --no-tag --dependent-version error --verbose $(if [ "${{ inputs.dry-run }}" = "false" ]; then echo --execute --no-confirm; fi) ${{ inputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: 'rust-setup' | ||
description: 'Prepares a rust environment and relevant caches.' | ||
inputs: | ||
target: | ||
description: 'Additionally install specified target for this toolchain, ex. x86_64-apple-darwin' | ||
required: false | ||
toolchain: | ||
description: 'Toolchain to install. Default: stable.' | ||
required: false | ||
default: stable | ||
components: | ||
description: 'Comma-separated string of additional components to install e.g. `clippy`, `rustfmt`' | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
|
||
- name: Get current date | ||
shell: bash | ||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | ||
|
||
- name: Setup rust toolchain | ||
shell: bash | ||
run: | | ||
if ! rustup self update; then | ||
echo "rustup self update failed" | ||
fi | ||
TARGET=${{ inputs.target }} | ||
if [[ $TARGET != '' ]]; then | ||
rustup target add $TARGET | ||
fi | ||
rustup update | ||
TOOLCHAIN=${{ inputs.toolchain }} | ||
if [[ $TOOLCHAIN != 'stable' ]]; then | ||
rustup toolchain install $TOOLCHAIN | ||
fi | ||
COMPONENTS=${{ inputs.components }} | ||
if [[ $COMPONENTS != '' ]]; then | ||
for i in ${COMPONENTS//,/ } | ||
do | ||
rustup component add $i $(if [ $TOOLCHAIN != '' ]; then echo --toolchain $TOOLCHAIN; fi) | ||
done | ||
fi | ||
rustup show | ||
# Generate Cargo.lock files for build, sccache cache keys. | ||
# Allows dependencies updated on crates.io between runs to trigger storing an updated cache, | ||
# which hashing Cargo.toml files alone does not. | ||
- name: Cargo update | ||
run: cargo update | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Audit | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '**/Cargo.lock' | ||
- '**/Cargo.toml' | ||
- '.github/workflows/audit.yml' | ||
- '.cargo/audit.toml' | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- '**/Cargo.lock' | ||
- '**/Cargo.toml' | ||
- '.github/workflows/audit.yml' | ||
- '.cargo/audit.toml' | ||
|
||
jobs: | ||
audit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/audit-check@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Clippy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
- 'epic/**' | ||
- 'support/**' | ||
paths: | ||
- '.github/workflows/clippy.yml' | ||
- '**.rs' | ||
- '**.toml' | ||
|
||
jobs: | ||
clippy: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Rust | ||
uses: './.github/actions/rust/rust-setup' | ||
|
||
- name: core clippy check | ||
uses: actions-rs-plus/clippy-check@b09a9c37c9df7db8b1a5d52e8fe8e0b6e3d574c4 | ||
with: | ||
args: --all-targets --all-features -- -D warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Format | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
- 'epic/**' | ||
- 'support/**' | ||
paths: | ||
- '.github/workflows/format.yml' | ||
- '**.rs' | ||
- '**.toml' | ||
- '**.ts' | ||
- '**.js' | ||
- '**.json' | ||
|
||
jobs: | ||
format: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# we use nightly to get access to advanced format capabilities | ||
- name: Setup Rust | ||
uses: './.github/actions/rust/rust-setup' | ||
with: | ||
toolchain: nightly | ||
components: rustfmt | ||
|
||
- name: Install cargo-license-template | ||
run: cargo install cargo-license-template | ||
|
||
- name: core fmt check | ||
run: cargo +nightly fmt --all -- --check | ||
|
||
- name: cargo-license-template check | ||
run: cargo +nightly license-template --template .license_template --ignore .license_template_ignore --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Rust publish to crates.io | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version to publish Rust under (e.g. `1.2.3-dev.1`)' | ||
required: true | ||
branch: | ||
description: 'Branch to run publish from' | ||
required: true | ||
dry-run: | ||
description: 'Run in dry-run mode' | ||
type: boolean | ||
required: false | ||
default: true | ||
|
||
jobs: | ||
publish-rust: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.inputs.branch }} | ||
- name: Publish to crates.io | ||
uses: './.github/actions/publish/publish-rust' | ||
with: | ||
version: ${{ github.event.inputs.version }} | ||
crates-token: ${{ secrets.CRATES_IO_TOKEN }} | ||
dry-run: ${{ github.event.inputs.dry-run }} |