diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8d8aeb..019b51e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: CI env: - MIN_SUPPORTED_RUST_VERSION: "1.66.0" + MIN_SUPPORTED_RUST_VERSION: "1.70.0" on: [push, pull_request] @@ -49,12 +49,11 @@ jobs: - uses: Swatinem/rust-cache@v2 - - name: Install latest nextest release - uses: taiki-e/install-action@nextest - - name: Install latest just release uses: taiki-e/install-action@just + - uses: taiki-e/install-action@nextest + - name: Prepare config run: | mkdir -p tests/.config/bilal @@ -86,10 +85,7 @@ jobs: with: target: ${{ matrix.target }} - - name: Rust cache - uses: Swatinem/rust-cache@v2 - with: - key: ${{ matrix.os }}-${{ matrix.target }} + - uses: Swatinem/rust-cache@v2 - name: Show version information shell: bash @@ -108,5 +104,10 @@ jobs: sudo apt-get install -y --no-install-recommends \ --allow-unauthenticated musl-tools + - name: Rust cache + uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.os }}-${{ matrix.target }} + - name: Build run: cargo build --release --locked --target ${{ matrix.target }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d00a652..8baf897 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: - 'v*' env: - BIN_NAME: bilal + APP_NAME: tin jobs: create-github-release: @@ -36,7 +36,7 @@ jobs: id: git-cliff with: config: configs/cliff.toml - args: -vv --strip header --current + args: -vv --strip header --current env: OUTPUT: CHANGELOG.md.tmp @@ -46,11 +46,11 @@ jobs: - name: Release uses: softprops/action-gh-release@v1 with: + token: ${{ secrets.GH_TOKEN }} name: "v${{ env.RELEASE_VERSION }}" prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }} generate_release_notes: true body_path: "${{ steps.git-cliff.outputs.changelog }}" - token: ${{ secrets.GH_TOKEN }} publish: name: Publish @@ -59,12 +59,12 @@ jobs: fail-fast: false matrix: include: - - { build: linux-gnu, os: ubuntu-22.04, target: x86_64-unknown-linux-gnu } - - { build: linux-musl, os: ubuntu-22.04, target: x86_64-unknown-linux-musl } - - { build: win-gnu, os: windows-2022, target: x86_64-pc-windows-gnu } - - { build: win-msvc, os: windows-2022, target: x86_64-pc-windows-msvc } - - { build: win32-msvc, os: windows-2022, target: i686-pc-windows-msvc } - - { build: macos, os: macos-12 , target: x86_64-apple-darwin } + - { build: linux-gnu, os: ubuntu-22.04, target: x86_64-unknown-linux-gnu } + - { build: linux-musl, os: ubuntu-22.04, target: x86_64-unknown-linux-musl } + - { build: win-gnu, os: windows-2022, target: x86_64-pc-windows-gnu } + - { build: win-msvc, os: windows-2022, target: x86_64-pc-windows-msvc } + - { build: win32-msvc, os: windows-2022, target: i686-pc-windows-msvc } + - { build: macos, os: macos-12, target: x86_64-apple-darwin } steps: - name: Checkout @@ -95,19 +95,19 @@ jobs: shell: bash run: | outdir="./target/release" - staging="${{ env.BIN_NAME }}-${{ env.RELEASE_VERSION }}-${{ matrix.target }}" + staging="${{ env.APP_NAME }}-${{ env.RELEASE_VERSION }}-${{ matrix.target }}" - mkdir -p "$staging"/{complete,doc} + mkdir -p "$staging"/doc cp -r {README.md,LICENSE*} "$staging/" cp -r {CHANGELOG.md,docs/*} "$staging/doc/" - if [ "${{ matrix.os }}" = "windows-2019" ]; then - cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" "$staging/" + if [[ "${{ matrix.os }}" =~ ^windows-.*$ ]]; then + cp "target/${{ matrix.target }}/release/${{ env.APP_NAME }}.exe" "$staging/" cd "$staging" 7z a "../$staging.zip" . echo "ASSET=$staging.zip" >> $GITHUB_ENV else - cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" "$staging/" + cp "target/${{ matrix.target }}/release/${{ env.APP_NAME }}" "$staging/" tar czf "$staging.tar.gz" -C "$staging" . echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV fi diff --git a/Cargo.toml b/Cargo.toml index 5942423..eb83187 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,8 @@ bin-dir = "{ bin }{ binary-ext }" pkg-fmt = "tgz" [package.metadata.release] -tag-message = "For details, see the CHANGELOG.md" +sign-commit = true +sign-tag = true +tag-message = "v{{version}}" pre-release-commit-message = "v{{version}}" -pre-release-hook = ["just", "_prepare-release", "{{version}}"] +pre-release-hook = ["just", "_release-prepare", "{{version}}"] diff --git a/clippy.toml b/clippy.toml index e90d7e3..1645c19 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.66.0" +msrv = "1.70.0" diff --git a/configs/cliff.toml b/configs/cliff.toml index 9dc9145..2aca678 100644 --- a/configs/cliff.toml +++ b/configs/cliff.toml @@ -1,10 +1,7 @@ -# configuration file for git-cliff (0.1.0) - [changelog] # changelog header header = """ # Changelog - All notable changes to this project will be documented in this file.\n """ # template for the changelog body @@ -19,14 +16,20 @@ body = """ ### {{ group | striptags | trim | upper_first }} {% for commit in commits %} {%- if commit.scope -%} - - **{{commit.scope}}:** {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}]({{ commit.id }})) + - **{{ commit.scope }}:** {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/azzamsa/bilal/commit/{{ commit.id }})) {% if commit.breaking -%} - {% raw %} {% endraw %}- **BREAKING!** ⚠️ : {{commit.breaking_description}} + {% raw %} {% endraw %}- **BREAKING!** ⚠️ : {{ commit.breaking_description }} + {% endif -%} + {% if commit.body -%} + {% raw %}\n{% endraw %}{% raw %} {% endraw %}{{ commit.body | indent(width=4) }}{% raw %}\n{% endraw %} {% endif -%} {% else -%} - - {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}]({{ commit.id }})) + - {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/azzamsa/bilal/commit/{{ commit.id }})) {% if commit.breaking -%} - {% raw %} {% endraw %}- **BREAKING!** ⚠️ : {{commit.breaking_description}} + {% raw %} {% endraw %}- **BREAKING!** ⚠️ : {{ commit.breaking_description }} + {% endif -%} + {% if commit.body -%} + {% raw %}\n{% endraw %}{% raw %} {% endraw %}{{ commit.body | indent(width=4) }}{% raw %}\n{% endraw %} {% endif -%} {% endif -%} {% endfor -%} @@ -44,9 +47,9 @@ footer = """""" conventional_commits = true # regex for parsing and grouping commits commit_parsers = [ - { message = "^feat*", group = "Features" }, - { message = "^fix*", group = "Bug fixes" }, - { message = "^perf*", group = "Performance" }, + { message = "^feat*", group = "Features" }, + { message = "^fix*", group = "Bug fixes" }, + { message = "^perf*", group = "Performance" }, ] # filter out the commits that are not matched by commit parsers filter_commits = true diff --git a/justfile b/justfile index 4049c9b..a2c3ef6 100755 --- a/justfile +++ b/justfile @@ -8,11 +8,14 @@ _default: just --list --unsorted # Setup the repository. -setup: +setup: _areyousure + just _cargo-install 'cargo-edit cargo-nextest cargo-outdated cargo-watch dprint git-cliff spacer' -# Setup the development tools. -_setup-dev: - cargo install --locked cargo-nextest git-cliff cargo-watch dprint cargo-edit cargo-outdated spacer +# Tasks to make the code-base comply with the rules. Mostly used in git hooks. +comply: _doc-check fmt lint test + +# Check if the repository comply with the rules and ready to be pushed. +check: fmt-check lint test # Develop the app. dev: @@ -28,40 +31,34 @@ fmt-check: cargo fmt --all -- --check dprint check --config configs/dprint.json -# Lint the docstring. -_lint_doc: - cargo doc --all-features --no-deps - # Lint the codebase. lint: cargo clippy # Test the codebase. -test: +test: test-unit cargo test --doc cargo nextest run -# Tasks to make the code-base comply with the rules. Mostly used in git hooks. -comply: fmt lint _lint_doc test - -# Check if the repository comply with the rules and ready to be pushed. -check: fmt-check lint test - -# Open documentation. -doc: - cargo doc --open +# Test unit tests only +test-unit: + cargo nextest run --lib # Create a new release. Example `cargo-release release minor --tag-name v0.2.0` release level: cargo-release release {{ level }} --execute # Make sure the repo is ready for release -_release-check level: +release-check level: just up cargo-release release {{ level }} +# Lint the docstring. +_doc-check: + cargo doc --all-features --no-deps + # Release hooks -_prepare-release version: +_release-prepare version: git-cliff --config configs/cliff.toml --output CHANGELOG.md --tag {{ version }} just fmt @@ -70,8 +67,7 @@ _prepare-release version: up arg="": #!/usr/bin/env bash if [ "{{ arg }}" = "--write" ]; then - cargo upgrade - cargo update + cargo upgrade && cargo update else cargo outdated --root-deps-only fi; @@ -79,10 +75,43 @@ up arg="": [windows] up arg="": #!powershell.exe - if ( "{{ arg }}" -eq "--write") { + if ( "tool" -eq "--write") { cargo upgrade cargo update } else { cargo outdated --root-deps-only } + +# +# Helper +# + +[unix] +_cargo-install tool: + #!/usr/bin/env bash + if command -v cargo-binstall >/dev/null 2>&1; then + echo "cargo-binstall..." + cargo binstall --no-confirm --no-symlinks {{ tool }} + else + echo "Building from source" + cargo install --locked {{ tool }} + fi + +[unix] +_areyousure: + #!/usr/bin/env bash + echo -e "This command will alter your system. ⚠️ + You are advised to run in inside containerized environment. + Such as [toolbx](https://containertoolbx.org/). + + If you are unsure. Run the installation commands manually. + Take a look at the 'setup' recipe in the Justfile.\n" + + read -p "Are you sure you want to proceed? (Y/n) " response; + if [[ $response =~ ^[Yy] ]]; then + echo "Continue!"; + else + echo "Cancelled!"; + exit 1; + fi