chore: replace justfile with nu script
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
@@ -68,8 +68,8 @@ to their read relays, most tools handle this automatically.
|
|||||||
#### Patch Guidelines
|
#### Patch Guidelines
|
||||||
|
|
||||||
- Keep patches small: Focused changes are easier to review and merge.
|
- Keep patches small: Focused changes are easier to review and merge.
|
||||||
- Run `just ci` before submitting your patch.
|
- Run `./tasks ci` before submitting your patch.
|
||||||
- Update the change log with your patch. Run `just changelog` or `git-cliff > CHANGELOG.md`
|
- Update the change log with your patch. Run `./tasks changelog` or `git-cliff > CHANGELOG.md`
|
||||||
- Add your name to the [AUTHORS](AUTHORS) file if this is your first contribution. (alphabetical order)
|
- Add your name to the [AUTHORS](AUTHORS) file if this is your first contribution. (alphabetical order)
|
||||||
- Use [Conventional Commits]: Start the patch subject with one of these types:
|
- Use [Conventional Commits]: Start the patch subject with one of these types:
|
||||||
- `feat`: New feature
|
- `feat`: New feature
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
packages = [
|
packages = [
|
||||||
dbus
|
dbus
|
||||||
git-cliff
|
git-cliff
|
||||||
just
|
|
||||||
mdbook
|
mdbook
|
||||||
nushell
|
nushell
|
||||||
pkg-config
|
pkg-config
|
||||||
|
|||||||
99
justfile
99
justfile
@@ -1,99 +0,0 @@
|
|||||||
# This justfile is for the contrbutors of this project, not for the end user.
|
|
||||||
#
|
|
||||||
# Requirements for this justfile:
|
|
||||||
# - Linux distribution
|
|
||||||
# - just (Of course) <https://github.com/casey/just>
|
|
||||||
# - cargo (For the build and tests) <https://doc.rust-lang.org/cargo/getting-started/installation.html>
|
|
||||||
# - mdbook (<https://rust-lang.github.io/mdBook>)
|
|
||||||
# - git-cliff (<https://git-cliff.org>)
|
|
||||||
# - taplo (<https://taplo.tamasfe.dev/>)
|
|
||||||
# - cargo-msrv (<https://github.com/foresterre/cargo-msrv>)
|
|
||||||
# - nushell (<https://nushell.sh>)
|
|
||||||
|
|
||||||
set quiet
|
|
||||||
set unstable
|
|
||||||
set shell := ["/usr/bin/env", "bash", "-c"]
|
|
||||||
set script-interpreter := ["/usr/bin/env", "nu"]
|
|
||||||
|
|
||||||
JUST_EXECUTABLE := "just -u -f " + justfile()
|
|
||||||
header := "Available tasks:\n"
|
|
||||||
BOOK_DEST_DIR := "dest"
|
|
||||||
tag_change_body := '''{% for group, commits in commits | group_by(attribute="group") %}
|
|
||||||
|
|
||||||
{{ group | upper_first }}
|
|
||||||
|
|
||||||
{% for commit in commits %}
|
|
||||||
- {{ commit.message | split(pat="\n") | first | split(pat=":") | slice(start=1) | join(sep=":") | upper_first | trim }} - by {{ commit.author.name}}{% endfor %}{% endfor %}
|
|
||||||
'''
|
|
||||||
|
|
||||||
export TZ := "UTC"
|
|
||||||
|
|
||||||
_default:
|
|
||||||
@{{JUST_EXECUTABLE}} --list-heading "{{header}}" --list
|
|
||||||
|
|
||||||
# Run the CI
|
|
||||||
ci: && _done_ci
|
|
||||||
echo "🔨 Building n34..."
|
|
||||||
cargo build -q
|
|
||||||
echo "🔍 Checking code formatting..."
|
|
||||||
cargo fmt -q -- --check
|
|
||||||
RUST_LOG=none taplo fmt --check --config "./.taplo.toml" || (echo "❌Toml files is not properly formatted" && exit 1)
|
|
||||||
echo "🧹 Running linter checks..."
|
|
||||||
cargo clippy -q -- -D warnings
|
|
||||||
echo "🧪 Running tests..."
|
|
||||||
cargo test -q
|
|
||||||
|
|
||||||
_done_ci:
|
|
||||||
echo "🎉 CI pipeline completed successfully"
|
|
||||||
|
|
||||||
# Update the changelog
|
|
||||||
[script]
|
|
||||||
changelog:
|
|
||||||
def get_hash [] { open "./CHANGELOG.md" | hash sha256 }
|
|
||||||
|
|
||||||
let old_hash = get_hash
|
|
||||||
git-cliff out> "CHANGELOG.md"
|
|
||||||
|
|
||||||
if old_hash != get_hash {
|
|
||||||
git add "CHANGELOG.md"
|
|
||||||
git commit -m "chore(changelog): Update the changelog"
|
|
||||||
print "The changes have been added to the changelog file and committed"
|
|
||||||
} else {
|
|
||||||
print "No changes have been added to the changelog"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Releases a new version of n34. Requires a clean file tree with no uncommitted changes.
|
|
||||||
[script]
|
|
||||||
release version:
|
|
||||||
let tag_msg = "Version {{ version }}" + (git-cliff --strip all --unreleased --body '{{ tag_change_body }}')
|
|
||||||
mut cargo_file = open "Cargo.toml"
|
|
||||||
|
|
||||||
$cargo_file.package.version = "{{ version }}"
|
|
||||||
$cargo_file | save -f "Cargo.toml"
|
|
||||||
|
|
||||||
RUST_LOG=none taplo fmt --config "./.taplo.toml"
|
|
||||||
{{ JUST_EXECUTABLE }} ci
|
|
||||||
git-cliff -t "v{{ version }}" out> "./CHANGELOG.md"
|
|
||||||
git add .
|
|
||||||
git commit -m "chore: Bump the version to `v{{ version }}`"
|
|
||||||
git tag -s -m $tag_msg "v{{ version }}"
|
|
||||||
git push origin master --tags
|
|
||||||
cargo publish
|
|
||||||
|
|
||||||
# Deploy the book to Github Pages
|
|
||||||
[script]
|
|
||||||
deploy:
|
|
||||||
mdbook build --dest-dir {{ BOOK_DEST_DIR }}
|
|
||||||
cd {{ BOOK_DEST_DIR }}
|
|
||||||
git init .
|
|
||||||
git checkout -B gh-pages
|
|
||||||
touch ".nojekyll"
|
|
||||||
echo "n34.dev" out> "CNAME"
|
|
||||||
|
|
||||||
git add .
|
|
||||||
git commit -m "Deploy the book to github pages"
|
|
||||||
git remote add origin "git@github.com:TheAwiteb/n34-book"
|
|
||||||
git push origin gh-pages -f
|
|
||||||
cd ..
|
|
||||||
rm -fr {{ BOOK_DEST_DIR }}
|
|
||||||
|
|
||||||
100
tasks
Executable file
100
tasks
Executable file
@@ -0,0 +1,100 @@
|
|||||||
|
#!/usr/bin/env nu
|
||||||
|
|
||||||
|
# Set the timezone to UTC
|
||||||
|
$env.TZ = "UTC"
|
||||||
|
|
||||||
|
const BOOK_DEST_DIR = "dest"
|
||||||
|
|
||||||
|
# Releases a new version of n34. Requires a clean file tree with no uncommitted changes.
|
||||||
|
def "main release" [version: string]: [nothing -> nothing] {
|
||||||
|
let tag_change_body = "{% for group, commits in commits | group_by(attribute='group') %}\n{{ group | capitalize }}:\n{% for commit in commits %}- {{ commit.message | split(pat='\n') | first | split(pat=':') | slice(start=1) | join(sep=':') | trim | capitalize }} - by {{ commit.author.name}}\n{% endfor %}{% endfor %}"
|
||||||
|
mut tag_msg = $"Version ($version) \n(git-cliff --strip all --unreleased --body $tag_change_body)\n"
|
||||||
|
mut cargo_file = open "Cargo.toml"
|
||||||
|
let old_version = $cargo_file.package.version
|
||||||
|
|
||||||
|
$cargo_file.package.version = $version
|
||||||
|
$cargo_file | save -f "Cargo.toml"
|
||||||
|
|
||||||
|
let old_contributors = git show v($old_version):AUTHORS | split row "\n"
|
||||||
|
let current_contributors = cat AUTHORS | split row "\n"
|
||||||
|
let new_contributors = $current_contributors | where {|user| not ($user in $old_contributors)}
|
||||||
|
|
||||||
|
if not ($new_contributors | is-empty) {
|
||||||
|
$tag_msg = $"($tag_msg)\nNew Contributors:\n($new_contributors | each {|line| '- ' + $line} | str join "\n")"
|
||||||
|
}
|
||||||
|
|
||||||
|
RUST_LOG=none taplo fmt --config "./.taplo.toml"
|
||||||
|
main ci
|
||||||
|
git-cliff -t $"v($version)" out> "./CHANGELOG.md"
|
||||||
|
git add .
|
||||||
|
git commit -m $"chore: Bump the version to `v($version)`"
|
||||||
|
git tag -s -m $tag_msg $"v($version)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run the CI
|
||||||
|
def "main ci" []: [nothing -> nothing] {
|
||||||
|
print "🔨 Building n34..."
|
||||||
|
cargo build -q
|
||||||
|
print "🔍 Checking code formatting..."
|
||||||
|
cargo fmt -q -- --check
|
||||||
|
|
||||||
|
let taplo_output = RUST_LOG=none taplo fmt --check --config "./.taplo.toml" | complete
|
||||||
|
|
||||||
|
if $taplo_output.exit_code != 0 {
|
||||||
|
print "❌Toml files is not properly formatted"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
print "🧹 Running linter checks..."
|
||||||
|
cargo clippy -q -- -D warnings
|
||||||
|
print "🧪 Running tests..."
|
||||||
|
cargo test -q
|
||||||
|
|
||||||
|
print "🎉 CI pipeline completed successfully"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Update the changelog
|
||||||
|
def "main changelog" []: [nothing -> nothing] {
|
||||||
|
def get_hash [] { open "./CHANGELOG.md" | hash sha256 }
|
||||||
|
|
||||||
|
let old_hash = get_hash
|
||||||
|
git-cliff out> "CHANGELOG.md"
|
||||||
|
|
||||||
|
if old_hash != get_hash {
|
||||||
|
git add "CHANGELOG.md"
|
||||||
|
git commit -m "chore(changelog): Update the changelog"
|
||||||
|
print "The changes have been added to the changelog file and committed"
|
||||||
|
} else {
|
||||||
|
print "No changes have been added to the changelog"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Deploy the book to Github Pages
|
||||||
|
def "main deploy" []: [nothing -> nothing] {
|
||||||
|
mdbook build --dest-dir $BOOK_DEST_DIR
|
||||||
|
cd $BOOK_DEST_DIR
|
||||||
|
git init .
|
||||||
|
git checkout -B gh-pages
|
||||||
|
touch ".nojekyll"
|
||||||
|
print "n34.dev" out> "CNAME"
|
||||||
|
|
||||||
|
git add .
|
||||||
|
git commit -m "Deploy the book to github pages"
|
||||||
|
git remote add origin "git@github.com:TheAwiteb/n34-book"
|
||||||
|
git push origin gh-pages -f
|
||||||
|
cd ..
|
||||||
|
rm -fr $BOOK_DEST_DIR
|
||||||
|
}
|
||||||
|
|
||||||
|
# n34 tasks runner. e.g. `./tasks deploy`
|
||||||
|
def main []: [nothing -> string] {
|
||||||
|
# Returns the tasks
|
||||||
|
"n34 tasks runner. Available tasks:\n\n" + (
|
||||||
|
help main
|
||||||
|
| split row "\n"
|
||||||
|
| each {|line| $line | ansi strip | str trim | str replace "(custom) " ""}
|
||||||
|
| where {|line| $line | str starts-with tasks}
|
||||||
|
| each {|line| $"(ansi green)./tasks(ansi reset) ($line | str replace 'tasks ' '')"}
|
||||||
|
| str join "\n"
|
||||||
|
) + ""
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user