From 4c51adb90353e1956db6d4371d6ff32a5dd10c8b Mon Sep 17 00:00:00 2001 From: davidontop Date: Thu, 27 Feb 2025 17:47:53 +0100 Subject: [PATCH] ci back --- .github/workflows/ci.yaml | 33 +++++++++++++++++++ .github/workflows/release.yaml | 58 ++++++++++++++++++++++++++++++++++ cargo-generate.toml | 30 +++++++++--------- 3 files changed, 106 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..cae0053 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,33 @@ +name: Release + +on: + push: + tags: + - '*' + +env: + binary: rust-template + + +jobs: + release-linux: + runs-on: ubuntu-latest + + steps: + - uses: olegtarasov/get-tag@v2.1.2 + id: get_version + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + with: + targets: x86_64-unknown-linux-gnu + - name: Build + run: | + cargo build --release --target x86_64-unknown-linux-gnu + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: target/x86_64-unknown-linux-gnu/release/${{ env.binary }} + asset_name: ${{ env.binary }} + tag: ${{ github.ref }} + overwrite: true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..612f056 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,58 @@ +name: CI + +on: + push: + branches: + - 'main' + - 'feat/*' + pull_request: + branches: + - 'main' + - 'feat/*' + +env: + CARGO_TERM_COLOR: always + +jobs: +{%- if ci-tests %} + test: + name: Tests + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install toolchain + uses: dtolnay/rust-toolchain@nightly + - name: Run cargo test + run: cargo test +{%- endif %} +{% if ci-clippy %} + clippy_check: + name: Clippy + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install toolchain + uses: dtolnay/rust-toolchain@nightly + with: + components: clippy + - name: Run clippy + run: cargo clippy -- -D warnings +{%- endif %} +{% if ci-fmt %} + format: + name: Format + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install toolchain + uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt + - name: Run cargo fmt + run: cargo fmt --all -- --check +{%- endif -%} diff --git a/cargo-generate.toml b/cargo-generate.toml index 92d5d60..27a468d 100755 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -46,18 +46,18 @@ ignore = ["src/main.rs"] [conditional.'crate_type == "bin"'] ignore = ["src/lib.rs"] -# [placeholders] -# ci-release = { type = "bool", prompt = "CI release?", default = true } -# ci = { type = "bool", prompt = "CI?", default = true } -# -# [conditional.'ci == false'] -# ignore = [".github/workflows/ci.yaml"] -# -# [conditional.'ci == true'.placeholders] -# ci-tests = { type = "bool", prompt = "CI tests?", default = true } -# ci-fmt = { type = "bool", prompt = "CI fmt?", default = true } -# ci-clippy = { type = "bool", prompt = "CI clippy?", default = true } -# -# [conditional.'ci-release == false'] -# ignore = [".github/workflows/release.yaml"] -# +[placeholders] +ci-release = { type = "bool", prompt = "CI release?", default = true } +ci = { type = "bool", prompt = "CI?", default = true } + +[conditional.'ci == false'] +ignore = [".github/workflows/ci.yaml"] + +[conditional.'ci == true'.placeholders] +ci-tests = { type = "bool", prompt = "CI tests?", default = true } +ci-fmt = { type = "bool", prompt = "CI fmt?", default = true } +ci-clippy = { type = "bool", prompt = "CI clippy?", default = true } + +[conditional.'ci-release == false'] +ignore = [".github/workflows/release.yaml"] +