Skip to content

Commit

Permalink
feat: build releases using goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeladler committed Sep 2, 2024
1 parent 2258a91 commit de33658
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 136 deletions.
4 changes: 4 additions & 0 deletions .ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -eux
cargo build --release
cp -a target/release/notmuch-mailmover dist/notmuch-mailmover_linux_amd64_v1/
36 changes: 22 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/target
/result
/dist
/share
86 changes: 86 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
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:"
22 changes: 0 additions & 22 deletions CHANGELOG.md

This file was deleted.

35 changes: 35 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
16 changes: 8 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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");

Expand All @@ -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();
Expand Down
91 changes: 0 additions & 91 deletions cliff.toml

This file was deleted.

3 changes: 3 additions & 0 deletions dummy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

func main() {}
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit de33658

Please sign in to comment.