diff --git a/.gitignore b/.gitignore index e96d68e..70d09d0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ target .idea completions.* +Makefile.config diff --git a/Makefile b/Makefile index a29fdd2..255da84 100644 --- a/Makefile +++ b/Makefile @@ -1,42 +1,42 @@ -ifeq ($(CARGO_PKG_VERSION),) - CARGO_PKG_VERSION := 0.0.0 -endif +SHELL := /bin/sh -ifeq ($(APP_NAME),) - APP_NAME := feddy -endif +PROJECT ?= $(shell grep "^name =" Cargo.toml | cut -d '"' -f 2) +VERSION ?= $(shell grep "^version =" Cargo.toml | cut -d '"' -f 2) -build: clean +-include Makefile.config + +INSTALL ?= install +INSTALL_PROGRAM ?= $(INSTALL) -m 755 +INSTALL_DATA ?= $(INSTALL) -m 644 + +.PHONY: build format rpm install uninstall + +build: cargo build --release - ./target/release/$(APP_NAME) --generate=bash > completions.bash - ./target/release/$(APP_NAME) --generate=zsh > completions.zsh - ./target/release/$(APP_NAME) --generate=fish > completions.fish - -clean: - rm -f completions.bash - rm -f completions.zsh - rm -f completions.fish format: cargo fmt --all -# PREFIX is environment variable, but if it is not set, then set default value -ifeq ($(PREFIX),) - PREFIX := /usr/local -endif +rpm: + rm -rf $(HOME)/rpmbuild + rpmdev-setuptree + tar -czf $(HOME)/rpmbuild/SOURCES/$(PROJECT)-$(VERSION).tar.gz \ + --transform "s|^|$(PROJECT)-$(VERSION)/|" \ + data \ + src \ + Cargo.toml \ + Cargo.lock \ + configure \ + Makefile \ + README.md \ + LICENSE + + cp $(PROJECT).spec $(HOME)/rpmbuild/SPECS/$(PROJECT).spec + rpmbuild -ba $(HOME)/rpmbuild/SPECS/$(PROJECT).spec install: - install -d $(PREFIX)/bin/ - install -m 755 target/release/$(APP_NAME) $(PREFIX)/bin/ - install -d /usr/share/bash-completion/completions/ - install -m 644 completions.bash /usr/share/bash-completion/completions/$(APP_NAME) - install -d /usr/share/zsh/site-functions/ - install -m 644 completions.zsh /usr/share/zsh/site-functions/_$(APP_NAME) - install -d /usr/share/fish/vendor_completions.d/ - install -m 644 completions.fish /usr/share/fish/vendor_completions.d/$(APP_NAME).fish + $(INSTALL) -d $(DESTDIR)$(bindir) + $(INSTALL_PROGRAM) target/release/$(PROJECT) $(DESTDIR)$(bindir)/$(PROJECT) uninstall: - rm -f $(PREFIX)/bin/$(APP_NAME) - rm -f /usr/share/bash-completion/completions/$(APP_NAME) - rm -f /usr/share/zsh/site-functions/_$(APP_NAME) - rm -f /usr/share/fish/vendor_completions.d/$(APP_NAME).fish \ No newline at end of file + rm -f $(DESTDIR)$(bindir)/$(PROJECT) \ No newline at end of file diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..ccc83b2 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,102 @@ +# git-cliff ~ configuration file +# https://git-cliff.org/docs/configuration + +[changelog] +# changelog header +header = """ +# Changelog\n +All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.\n +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{% macro print_commit(commit) -%} + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message | upper_first }} - \ + ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }}))\ +{% endmacro -%} + +{% if version %}\ + {% if previous.version %}\ + ## [{{ version | trim_start_matches(pat="v") }}]\ + ($REPO/-/compare/{{ previous.version }}...{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }} + {% else %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} + {% endif %}\ +{% else %}\ + ## [unreleased] +{% endif %}\ + +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits + | filter(attribute="scope") + | sort(attribute="scope") %} + {{ self::print_commit(commit=commit) }} + {%- endfor -%} + {% raw %}\n{% endraw %}\ + {%- for commit in commits %} + {%- if not commit.scope -%} + {{ self::print_commit(commit=commit) }} + {% endif -%} + {% endfor -%} +{% endfor %}\n +""" +# template for the changelog footer +footer = """ + +""" +# remove the leading and trailing whitespace from the templates +trim = true +# postprocessors +postprocessors = [ + { pattern = '\$REPO', replace = "https://git.rawleenc.dev/rawleenc/feddy" }, # replace repository URL +] + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, # replace issue numbers +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "๐Ÿš€ Features" }, + { message = "^fix", group = "๐Ÿ› Bug Fixes" }, + { message = "^doc", group = "๐Ÿ“š Documentation" }, + { message = "^perf", group = "โšก Performance" }, + { message = "^refactor\\(clippy\\)", skip = true }, + { message = "^refactor", group = "๐Ÿšœ Refactor" }, + { message = "^style", group = "๐ŸŽจ Styling" }, + { message = "^test", group = "๐Ÿงช Testing" }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(deps.*\\)", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore|^ci", group = "โš™๏ธ Miscellaneous Tasks" }, + { body = ".*security", group = "๐Ÿ›ก๏ธ Security" }, + { message = "^revert", group = "โ—€๏ธ Revert" }, + { message = "^build", group = "๐Ÿ”จ Build" }, +] +# protect breaking changes from being skipped due to matching a skipping commit_parser +protect_breaking_commits = false +# filter out the commits that are not matched by commit parsers +filter_commits = false +# regex for matching git tags +# tag_pattern = "v[0-9].*" +# regex for skipping tags +# skip_tags = "v0.1.0-beta.1" +# regex for ignoring tags +ignore_tags = "" +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "newest" +# limit the number of commits included in the changelog. +# limit_commits = 42 diff --git a/configure b/configure new file mode 100755 index 0000000..42ffa4b --- /dev/null +++ b/configure @@ -0,0 +1,145 @@ +#!/bin/bash +# Configuration script for the feddy project + +usage() { + cat < /dev/null; then + echo "Error: cargo is required but not installed. Please install Rust and cargo." + exit 1 +fi + +# Generate Makefile.config +cat > Makefile.config <