From e982c95159c0c4c039884fb2b1f8f42abeab0d16 Mon Sep 17 00:00:00 2001 From: Mahmoud Mazouz Date: Thu, 29 Feb 2024 15:21:25 +0100 Subject: [PATCH] feat: Add Release workflow (#6) * chore: Rename rust-toolchain to rust-toolchain.toml * chore: Rename rust.yml to ci.yml * chore: Remove deprecated actions in ci.yml * feat: Add .editorconfig * feat: Add Release workflow * fix: Typo in ci.yml --- .editorconfig | 8 ++++ .github/workflows/{rust.yml => ci.yml} | 40 +++++++--------- .github/workflows/release.yml | 66 ++++++++++++++++++++++++++ rust-toolchain | 1 - rust-toolchain.toml | 2 + 5 files changed, 92 insertions(+), 25 deletions(-) create mode 100644 .editorconfig rename .github/workflows/{rust.yml => ci.yml} (55%) create mode 100644 .github/workflows/release.yml delete mode 100644 rust-toolchain create mode 100644 rust-toolchain.toml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..17bdb37 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +insert_final_newline = true diff --git a/.github/workflows/rust.yml b/.github/workflows/ci.yml similarity index 55% rename from .github/workflows/rust.yml rename to .github/workflows/ci.yml index ec51e17..3299fda 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/ci.yml @@ -12,46 +12,38 @@ # ZettaScale Zenoh Team, # - name: CI on: push: - branches: [ '**' ] + branches: ["**"] pull_request: - branches: [ '**' ] + branches: ["**"] schedule: - - cron: '0 0 * * 1-5' + - cron: "0 0 * * 1-5" + workflow_call: jobs: checks: name: Code checks runs-on: [self-hosted, ubuntu-22.04] steps: - - uses: actions/checkout@v2 + - name: Clone this repository + uses: actions/checkout@v4 + - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - components: rustfmt, clippy + run: rustup component add rustfmt clippy + - name: Code format check - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check + run: cargo fmt --check + - name: Clippy check - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all-targets -- -D warnings + run: cargo clippy --all-targets --all-features -- --deny warnings + - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --all-targets + run: cargo build --release --all-targets + - name: Run tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --release --verbose + run: cargo test --release --verbose env: ASYNC_STD_THREAD_COUNT: 4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3ea83a0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Release + +on: + workflow_dispatch: + inputs: + dry-run: + description: Perform a dry-run of the release, without any side-effects + type: boolean + required: true + version: + description: > + Release version. Can be left unspecified if `dry-run = true`, + in which case the workflow will generate it using `git describe`. + type: string + required: false + +env: + ACTOR_NAME: zettascale-bot + ACTOR_EMAIL: bot@zettascale.tech + +jobs: + ci: + uses: ./.github/workflows/ci.yml@main + + tag: + runs-on: [self-hosted, ubuntu-20.04] + needs: ci + outputs: + branch: ${{ steps.tag.outputs.branch }} + version: ${{ steps.tag.outputs.version }} + steps: + - id: tag + uses: ZettaScaleLabs/ci/tag-crates@develop + with: + repo: ${{ github.repository }} + dry-run: ${{ inputs.dry-run }} + github-token: ${{ secrets.ZETTASCALE_BOT_PERSONAL_ACCESS_TOKEN }} + actor-name: ${{ env.ACTOR_NAME }} + actor-email: ${{ env.ACTOR_EMAIL }} + inter-deps-pattern: ^$ + + publish-cargo: + runs-on: [self-hosted, ubuntu-20.04] + needs: tag + steps: + - uses: ZettaScaleLabs/ci/publish-crates-cargo@develop + with: + repos: ${{ github.repository }} + branch: ${{ needs.tag.outputs.branch }} + dry-run: ${{ inputs.dry-run }} + github-token: ${{ secrets.ZETTASCALE_BOT_PERSONAL_ACCESS_TOKEN }} + crates-io-token: ${{ secrets.ZETTASCALE_CRATES_IO_TOKEN }} + inter-deps-pattern: ^$ + + publish-github: + runs-on: [self-hosted, ubuntu-20.04] + needs: tag + steps: + - if: ${{ !inputs.dry-run }} + run: > + gh release create ${{ needs.tag.outputs.version }} + --target ${{ needs.tag.outputs.branch }} + --latest + --generate-notes + env: + GH_TOKEN: ${{ secrets.ZETTASCALE_BOT_PERSONAL_ACCESS_TOKEN }} diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 2bf5ad0..0000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -stable diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..292fe49 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "stable"