diff --git a/.ci/build.sh b/.ci/build.sh new file mode 100755 index 0000000..f3e0792 --- /dev/null +++ b/.ci/build.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euxo pipefail +cargo build --release +cp -a target/release/notmuch-mailmover dist/notmuch-mailmover_linux_amd64_v1/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1dd542..2d0175c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,25 +1,33 @@ name: Release -permissions: - contents: write - on: push: tags: - - v[0-9]+.* + - "v*" -defaults: - run: - shell: bash +permissions: + contents: write jobs: - create-release: + release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: taiki-e/create-gh-release-action@v1 + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-go@v5 # for dummy.go + - uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install build deps + run: sudo apt-get update -q && sudo apt-get install -y libnotmuch-dev + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 with: - changelog: CHANGELOG.md - branch: "main|v[0-9]+" - draft: true - token: ${{ secrets.GITHUB_TOKEN }} + distribution: goreleaser + version: 'latest' + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index d787b70..abe4e42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /target /result +/dist +/share diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..74c6f14 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,86 @@ +version: 2 + +project_name: notmuch-mailmover + +builds: + - id: notmuch-mailmover + main: dummy.go + goarch: + - amd64 + goos: + - linux + binary: notmuch-mailmover + hooks: + post: sh .ci/build.sh + +archives: + - id: notmuch-mailmover + builds: + - notmuch-mailmover + name_template: >- + {{ .ProjectName }}_{{ .Version }}_ + {{- if eq .Os "darwin" }}macOS + {{- else if eq .Os "linux" }}Linux + {{- else }}{{ .Os }}{{ end }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else }}{{ .Arch }}{{ end }} + format: tar.zst + files: + - LICENSE + - share + +nfpms: + - id: notmuch-mailmover + package_name: notmuch-mailmover + builds: + - notmuch-mailmover + formats: + - deb + - rpm + - archlinux + maintainer: Michael Adler + homepage: https://github.com/michaeladler/notmuch-mailmover + description: move notmuch tagged mails into Maildir folders + dependencies: + - notmuch + section: mail + priority: extra + contents: + # zsh completion + - src: share/_notmuch-mailmover + dst: /usr/share/zsh/vendor-completions/_notmuch-mailmover + + # bash completion + - src: share/notmuch-mailmover.bash + dst: /usr/share/bash-completion/completions/notmuch-mailmover + + # fish completion + - src: share/notmuch-mailmover.fish + dst: /usr/share/fish/completions/notmuch-mailmover.fish + + # man page + - src: share/notmuch-mailmover.1.gz + dst: /usr/share/man/man1/notmuch-mailmover.1.gz + +checksum: + name_template: 'checksums.txt' + +release: + draft: true + replace_existing_draft: true + +changelog: + sort: asc + groups: + - title: Features + regexp: "^.*feat[(\\w)]*:+.*$" + order: 0 + - title: "Bug fixes" + regexp: "^.*fix[(\\w)]*:+.*$" + order: 1 + - title: Others + order: 999 + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index eaf28b5..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,22 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines. - ---- -## [0.2.0](https://github.com/michaeladler/notmuch-mailmover/compare/v0.1.0..v0.2.0) - 2023-10-26 - -### Bug Fixes - -- don't panic if rules are empty - ([837f7fd](https://github.com/michaeladler/notmuch-mailmover/commit/837f7fd3d654a6b76c7646c9adf275f9ad61a67c)) -- overlap check - ([1f18a37](https://github.com/michaeladler/notmuch-mailmover/commit/1f18a37873526ae9ec2ac4090fe704826ecdd9d4)) - -### Refactoring - -- use clap and generate man pages - ([0e140aa](https://github.com/michaeladler/notmuch-mailmover/commit/0e140aae279daf8b5d56a4e2fd9d3648eeb00931)) - ---- -## [0.1.0] - 2022-11-14 - -Initial release - -[0.1.0]: https://github.com/michaeladler/notmuch-mailmover/releases/tag/v0.1.0 diff --git a/Cargo.lock b/Cargo.lock index 3b3c544..b7b895e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "aho-corasick" version = "1.1.3" @@ -143,6 +149,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + [[package]] name = "darling" version = "0.10.2" @@ -237,6 +252,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "flate2" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" @@ -369,6 +394,15 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "notmuch" version = "0.8.0" @@ -389,6 +423,7 @@ dependencies = [ "clap_mangen", "directories", "env_logger", + "flate2", "git-version", "log", "notmuch", diff --git a/Cargo.toml b/Cargo.toml index 18f3d68..bcd5ba7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,6 +38,7 @@ clap = { version = "4.5.13", features = [ "derive", "cargo" ] } clap_complete = "4.5.13" clap_mangen = "0.2.23" git-version = "0.3.9" +flate2 = "1.0.17" [dev-dependencies] regex = "1.10.6" diff --git a/build.rs b/build.rs index a11ae93..f351c47 100644 --- a/build.rs +++ b/build.rs @@ -1,11 +1,10 @@ -use std::{ - fs::{create_dir_all, File}, - path::Path, -}; - use clap::CommandFactory; use clap_complete::{generate_to, Shell}; use clap_mangen::Man; +use flate2::write::GzEncoder; +use flate2::Compression; +use std::fs::{create_dir_all, File}; +use std::path::Path; include!("src/lib/cli.rs"); @@ -16,9 +15,10 @@ fn main() { create_dir_all(out).unwrap(); let cmd = &mut Cli::command(); - Man::new(cmd.clone()) - .render(&mut File::create(out.join("notmuch-mailmover.1")).unwrap()) - .unwrap(); + let f = File::create(out.join("notmuch-mailmover.1.gz")).unwrap(); + let mut encoder = GzEncoder::new(f, Compression::default()); + + Man::new(cmd.clone()).render(&mut encoder).unwrap(); for shell in Shell::value_variants() { generate_to(*shell, cmd, "notmuch-mailmover", out).unwrap(); diff --git a/cliff.toml b/cliff.toml deleted file mode 100644 index 8df3ebe..0000000 --- a/cliff.toml +++ /dev/null @@ -1,91 +0,0 @@ -# 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 = """ ---- -{% 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") %} - - **({{commit.scope}})**{% if commit.breaking %} [**breaking**]{% endif %} \ - {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {%- endfor -%} - {% raw %}\n{% endraw %}\ - {%- for commit in commits %} - {%- if commit.scope -%} - {% else -%} - - {% if commit.breaking %} [**breaking**]{% endif %}\ - {{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {% endif -%} - {% endfor -%} -{% endfor %}\n -""" -# remove the leading and trailing whitespace from the template -trim = true -# changelog footer -footer = "" -# postprocessors -postprocessors = [ - { pattern = '\$REPO', replace = "https://github.com/michaeladler/notmuch-mailmover" }, # 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", skip = true }, - { message = "^perf", group = "Performance" }, - { message = "^refactor", group = "Refactoring" }, - { message = "^style", group = "Style", skip = true }, - { message = "^revert", group = "Revert" }, - { message = "^test", group = "Tests" }, - { message = "^chore\\(version\\):", skip = true }, - { message = "^chore", group = "Miscellaneous Chores", skip = true }, - { body = ".*security", group = "Security" }, - { message = "^ci", group = "CI", skip = true }, -] -# 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 -# glob pattern 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 = "oldest" -# limit the number of commits included in the changelog. -# limit_commits = 42 diff --git a/dummy.go b/dummy.go new file mode 100644 index 0000000..38dd16d --- /dev/null +++ b/dummy.go @@ -0,0 +1,3 @@ +package main + +func main() {} diff --git a/flake.nix b/flake.nix index 1744a48..4437af8 100644 --- a/flake.nix +++ b/flake.nix @@ -33,7 +33,7 @@ buildInputs = with pkgs; [ notmuch ]; postInstall = '' - installManPage share/notmuch-mailmover.1 + installManPage share/notmuch-mailmover.1.gz installShellCompletion --cmd notmuch-mailmover \ --bash share/notmuch-mailmover.bash \ --fish share/notmuch-mailmover.fish \