From 2aa008431ab16551148b7bdadfb47c4fbb093e21 Mon Sep 17 00:00:00 2001 From: Leo Borai Date: Sat, 24 Jan 2026 13:44:20 +0100 Subject: [PATCH] chore: update gh actions --- .github/workflows/build.yml | 30 -- .github/workflows/cd.yml | 116 ++++++++ .github/workflows/ci.yml | 32 ++ .github/workflows/clippy.yml | 37 --- .github/workflows/dependabot-auto-approve.yml | 21 -- ...pendabot-auto-merge.yml => dependabot.yml} | 11 +- .github/workflows/fmt.yml | 39 --- .github/workflows/release.yml | 43 --- .github/workflows/tests.yml | 29 -- rustfmt.toml | 278 ------------------ 10 files changed, 157 insertions(+), 479 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/clippy.yml delete mode 100644 .github/workflows/dependabot-auto-approve.yml rename .github/workflows/{dependabot-auto-merge.yml => dependabot.yml} (69%) delete mode 100644 .github/workflows/fmt.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/tests.yml delete mode 100644 rustfmt.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 860239b..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: build -on: - pull_request: - push: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Cache .cargo and target - uses: actions/cache@v2 - with: - path: | - ~/.cargo - ./target - key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.toml') }} - restore-keys: | - ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.os }}-cargo-build - - - name: cargo build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --locked diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..db7cb19 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,116 @@ +name: Continuous Delivery + +on: + workflow_dispatch: + inputs: + version: + type: choice + required: true + description: 'Version number to bump' + options: + - patch + - minor + - major + pull_request: + branches: + - main + types: + - closed + +permissions: + contents: write + issues: write + pull-requests: write + +jobs: + publish-dry-run: + name: "Runs cargo publish --dry-run" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Setup Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Setup Cargo Binstall + uses: cargo-bins/cargo-binstall@main + + - name: Install Rust Binaries + run: cargo binstall -y --force cargo-tag + + - name: Build (debug) + run: cargo b + + - name: publish crate + run: | + cargo package --list --allow-dirty + cargo publish --dry-run --allow-dirty + + release: + name: Create Release + needs: build-binaries + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Setup Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Setup Cargo Binstall + uses: cargo-bins/cargo-binstall@main + + - name: Install Rust Binaries + run: cargo binstall -y --force cargo-tag + + - name: Retrieve Git Commit SHA + run: echo "GIT_COMMIT_SHA7=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV + + - name: Commit Version Bump + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + echo "CRATE_VERSION=$(cargo tag -p=v ${{ inputs.version }})" >> $GITHUB_ENV + else + echo "CRATE_VERSION=$(cargo tag -p=v prerelease pre.$GIT_COMMIT_SHA7)" >> $GITHUB_ENV + fi + git push origin main --follow-tags + + - name: Login to Crates.io + run: cargo login ${CRATES_IO_TOKEN} + env: + CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} + + - name: Publish crate + run: | + cargo package --list --allow-dirty + cargo publish --allow-dirty + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: ./artifacts + + - name: Create Release with GitHub CLI + env: + GH_TOKEN: ${{ github.token }} + run: | + # Determine if this is a pre-release + IS_PRERELEASE="" + if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then + IS_PRERELEASE="--prerelease" + fi + + # Create the release + gh release create "${{ env.CRATE_VERSION }}" \ + --title "${{ env.CRATE_VERSION }}" \ + --generate-notes \ + $IS_PRERELEASE diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2b1b700 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: build +on: + pull_request: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Setup Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Build + run: cargo b + + - name: Run Formatter Check + run: cargo fmt -- --check + + - name: Run Clippy Check + run: cargo clippy -- -D warnings + + - name: Run Tests + run: cargo test diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml deleted file mode 100644 index 984b4f8..0000000 --- a/.github/workflows/clippy.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: clippy -on: - pull_request: - push: - branches: - - main - -jobs: - clippy: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: clippy - - - name: Cache .cargo and target - uses: actions/cache@v2 - with: - path: | - ~/.cargo - ./target - key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.os }}-cargo-clippy - - - name: cargo clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings diff --git a/.github/workflows/dependabot-auto-approve.yml b/.github/workflows/dependabot-auto-approve.yml deleted file mode 100644 index fa79cad..0000000 --- a/.github/workflows/dependabot-auto-approve.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Dependabot auto-approve -on: pull_request_target - -permissions: - pull-requests: write - -jobs: - dependabot: - runs-on: ubuntu-latest - if: ${{ github.actor == 'dependabot[bot]' }} - steps: - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@v1.1.1 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - name: Approve a PR - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot.yml similarity index 69% rename from .github/workflows/dependabot-auto-merge.yml rename to .github/workflows/dependabot.yml index bbdc1d4..12e7fd9 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot.yml @@ -1,4 +1,4 @@ -name: Dependabot auto-merge +name: Dependabot Automation on: pull_request_target permissions: @@ -15,9 +15,16 @@ jobs: uses: dependabot/fetch-metadata@v1.1.1 with: github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Approve a PR + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Enable auto-merge for Dependabot PRs if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} - run: gh pr merge --auto --merge "$PR_URL" + run: gh pr merge --auto --squash "$PR_URL" env: PR_URL: ${{github.event.pull_request.html_url}} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml deleted file mode 100644 index 65a6649..0000000 --- a/.github/workflows/fmt.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: fmt -on: - pull_request: - push: - branches: - - main - -jobs: - fmt: - name: fmt - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rustfmt - - - name: Cache .cargo and target - uses: actions/cache@v2 - with: - path: | - ~/.cargo - ./target - key: ${{ runner.os }}-cargo-fmt-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-fmt-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.os }}-cargo-fmt - - - name: Run fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index fadeee0..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: release - -on: - push: - tags: - - 'v*' - -jobs: - create-release: - name: Create Release - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - body: '' - draft: false - prerelease: false - - publish-crate: - name: Publish to crates.io - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - - run: cargo login ${CRATES_IO_TOKEN} - env: - CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} - - - name: publish crate - run: cargo publish diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index ed7e21c..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: test -on: - pull_request: - push: - branches: - - main - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Cache .cargo and target - uses: actions/cache@v2 - with: - path: | - ~/.cargo - ./target - key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.os }}-cargo-test - - - name: cargo test - uses: actions-rs/cargo@v1 - with: - command: test diff --git a/rustfmt.toml b/rustfmt.toml deleted file mode 100644 index 9496a5a..0000000 --- a/rustfmt.toml +++ /dev/null @@ -1,278 +0,0 @@ -# Use verbose output. -# Default: false -# verbose = - -# Do not reformat out of line modules. -# Default: false -# skip_children = - -# Lines to format; this is not supported in rustfmt.toml, -# and can only be specified via the --file-lines option. -# file_lines = - -# Maximum width of each line. -# Default: 100 -# max_width = - -# Ideal width of each line. -# Default: 80 -# max_width = - -# Number of spaces per tab. -# Default: 4 -# tab_spaces = 4 - -# Maximum width of the args of a function call before -# falling back to vertical formatting. -# Default: 60 -# fn_call_width = - -# Maximum width in the body of a struct lit before falling back to vertical formatting. -# Default: 16 -# struct_lit_width = - -# Maximum width in the body of a struct variant before falling back to vertical formatting. -# Default: 35 -# struct_variant_width = - -# Always print the abi for extern items. -# Default: true -# force_explicit_abi = - -# Unix or Windows line endings. -# Values: Windows | Unix | Native -# Default: Unix -# newline_style = - -# Brace style for functions. -# Values: AlwaysNextLine | PreferSameLine | SameLineWhere -# Default: SameLineWhere -# fn_brace_style = - -# Brace style for structs and enums. -# Values: AlwaysNextLine | PreferSameLine | SameLineWhere -# Default: SameLineWhere -# item_brace_style = - -# Brace style for control flow construct. -# Values: AlwaysSameLine | ClosingNextLine | AlwaysNextLine -# Default: AlwaysSameLine -# control_brace_style = - -# Put empty-body implementations on a single line. -# Default: true -# impl_empty_single_line = - -# Put empty-body functions on a single line. -# Default: true -# fn fn_empty_single_line = - -# Put single-expression functions on a single line. -# Default: false -# fn_single_line = - -# Location of return type in function declaration. -# Values: WithArgs | WithWhereClause -# Default: WithArgs -# fn_return_indent = - -# If function argument parenthesis goes on a newline. -# Default: true -# fn_args_paren_newline = - -# Argument density in functions. -# Values: Compressed | Tall | CompressedIfEmpty | Vertical -# Default: Tall -# fn_args_density = - -# Layout of function arguments. -# Values: Visual | Block | BlockAlways -# Default: Visual -# fn_args_layout = - -# Indent on function arguments. -# Values: Inherit | Tabbed | Visual -# Default: Visual -# fn_arg_indent = - -# Determines if '+' or '=' are wrapped in spaces in the punctuation of types. -# Values: Compressed | Wide -# Default: Wide -# type_punctuation_density = - -# Density of a where clause. -# Values: Compressed | Tall | CompressedIfEmpty | Vertical -# Default: CompressedIfEmpty -# where_density = - -# Indentation of a where clause. -# Values: Inherit | Tabbed | Visual -# Default: Tabbed -# where_indent = - -# Element layout inside a where clause. -# Values: Vertical | Horizontal | HorizontalVertical | Mixed -# Default: Vertical -# where_layout = - -# Indentation style of a where predicate. -# Values: Inherit | Tabbed | Visual -# Default: Visual -# where_pred_indent = - -# Put a trailing comma on where clauses. -# Default: false -# where_trailing_comma = - -# Indentation of generics. -# Values: Inherit | Tabbed | Visual -# Default: Visual -# generics_indent = - -# If there is a trailing comma on structs. -# Values: Always | Never | Vertical -# Default: Vertical -# struct_trailing_comma = - -# If there is a trailing comma on literal structs. -# Values: Always | Never | Vertical -# Default: Vertical -# struct_lit_trailing_comma = - -# Style of struct definition. -# Values: Visual | Block -# Default: Block -# struct_lit_style = - -# Multiline style on literal structs. -# Values: PreferSingle | ForceMulti -# Default: PreferSingle -# struct_lit_multiline_style = - -# Put a trailing comma on enum declarations. -# Default: true -# enum_trailing_comma = - -# Report all, none or unnumbered occurrences of TODO in source file comments. -# Values: Always | Unnumbered | Never -# Default: Never -# report_todo = - -# Report all, none or unnumbered occurrences of FIXME in source file comments. -# Values: Always | Unnumbered | Never -# Default: Never -# report_fixme = - -# Indent on chain base. -# Values: Inherit | Tabbed | Visual -# Default: Tabbed -# chain_base_indent = - -# Indentation of chain. -# Values: Inherit | Tabbed | Visual -# Default: Tabbed -# chain_indent = - -# Allow last call in method chain to break the line. -# Default: true -# chains_overflow_last = - -# Reorder import statements alphabetically. -# Default: false -# reorder_imports = - -# Reorder lists of names in import statements alphabetically. -# Default: false -# reorder_imported_names = - -# Maximum line length for single line if-else expressions. -# A value of zero means always break if-else expressions. -# Default: 50 -# single_line_if_else_max_width = - -# Format string literals where necessary. -# Default: true -# format_strings = - -# Always format string literals. -# Default: false -# force_format_strings = - -# Retain some formatting characteristics from the source code. -# Default: true -# take_source_hints = - -# Use tab characters for indentation, spaces for alignment. -# Default: false -# hard_tabs = - -# Break comments to fit on the line. -# Default: false -# wrap_comments = - -# Convert /* */ comments to // comments where possible. -# Default: false -# normalize_comments = - -# Wrap multiline match arms in blocks. -# Default: true -# wrap_match_arms = - -# Put a trailing comma after a block based match arm (non-block arms are not affected). -# Default: false -# match_block_trailing_comma = - -# Put a trailing comma after a wildcard arm. -# Default: true -# match_wildcard_trailing_comma = - -# How many lines a closure must have before it is block indented. -# -1 means never use block indent. -# Type: -# Default: 5 -# closure_block_indent_threshold = - -# Leave a space before the colon in a type annotation. -# Default: false -# space_before_type_annotation = - -# Leave a space after the colon in a type annotation. -# Default: true -# space_after_type_annotation_colon = - -# Leave a space before the colon in a trait or lifetime bound. -# Default: false -# space_before_bound = - -# Leave a space after the colon in a trait or lifetime bound. -# Default: true -# space_after_bound_colon = - -# Put spaces around the .. and ... range operators. -# Default: false -# spaces_around_ranges = - -# Put spaces within non-empty generic arguments. -# Default: false -# spaces_within_angle_brackets = - -# Put spaces within non-empty square brackets. -# Default: false -# spaces_within_square_brackets = - -# Put spaces within non-empty parentheses. -# Default: false -# spaces_within_parens = - -# Replace uses of the try! macro by the ? shorthand. -# Default: false -# use_try_shorthand = - -# What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage. -# Values: Replace | Overwrite | Display | Diff | Coverage | Plain | Checkstyle -# Default: Replace -# write_mode = - -# Replace strings of _ wildcards by a single .. in tuple patterns. -# Default: false -# condense_wildcard_suffices =