Skip to content

Commit

Permalink
feat(build): Add release automation tooling adapted from decasify
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jan 10, 2025
1 parent 21cc480 commit e5b21b2
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
./bootstrap.sh
./configure \
--enable-developer-mode \
GITCLIFF=: JUST=: TAPLO=: TYPOS=: \
CARGO_SET_VERSION=: GIT_CLIFF=: JUST=: TAPLO=: TYPOS=: \
--without-{bash,fish,zsh}-completion-dir
- name: Publish Docker Image to GH Container Registry
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
./bootstrap.sh
./configure \
--enable-developer-mode \
GITCLIFF=: JUST=: TAPLO=: TYPOS=:\
CARGO_SET_VERSION=: GIT_CLIFF=: JUST=: TAPLO=: TYPOS=: \
--without-{bash,fish,zsh}-completion-dir
echo "VERSION=$(./build-aux/git-version-gen .tarball-version)" >> $GITHUB_ENV
- name: Build source package
Expand Down
43 changes: 43 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
set ignore-comments := true
set shell := ["zsh", "+o", "nomatch", "-ecu"]
set unstable := true
set script-interpreter := ["zsh", "+o", "nomatch", "-eu"]

_default:
@just --list --unsorted

[private]
[doc('Block execution if Git working tree isn’t pristine.')]
pristine:
# Ensure there are no changes in staging
git diff-index --quiet --cached HEAD || exit 1
# Ensure there are no changes in the working tree
git diff-files --quiet || exit 1

[private]
[doc('Block execution if we don’t have access to private keys.')]
keys:
gpg -a --sign > /dev/null <<< "test"

release semver: pristine keys
cargo-set-version set-version {{semver}}
taplo format Cargo.toml
sed -i -e "/^git-warp-time =/s/\".*\"/\"${${:-{{semver}}}%\.*}\"/" README.md
sed -i -e "/image:/s/:v.*/:v{{semver}}/" action.yml
make SEMVER={{semver}} CHANGELOG.md git-warp-time-{{semver}}.md -B
git add Cargo.{toml,lock} README.md CHANGELOG.md action.yml
git commit -m "chore: Release v{{semver}}"
git tag -s v{{semver}} -F git-warp-time-{{semver}}.md
cargo build
git diff-files --quiet || exit 1
./config.status && make
git push --atomic origin master v{{semver}}
cargo publish --locked

post-release semver: keys
gh release download v{{semver}}
ls git-warp-time-{{semver}}.{tar.zst,zip} | xargs -n1 gpg -a --detach-sign
gh release upload v{{semver}} git-warp-time-{{semver}}.{tar.zst,zip}.asc

# vim: set ft=just

14 changes: 12 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,23 @@ include $(top_srcdir)/aminclude.am
PHONY_DEVELOPER_TARGETS = release-preview
.PHONY: $(PHONY_DEVELOPER_TARGETS)

SEMVER := $(shell $(AWK) -F\" '/^version/ { print $$2 }' $(top_srcdir)/Cargo.toml)
TAG := v$(SEMVER)

if DEVELOPER_MODE

release-preview:
$(GIT_CLIFF) --unreleased

CHANGELOG.md: .version
$(GIT_CLIFF) -o $@
CHANGELOG.md:
$(GIT_CLIFF) -p $@ --unreleased -t $(TAG)

git-warp-time-%.md: CHANGELOG.md
$(SED) -e '/^## \[$*\]/,/^## \[/!d' $< | \
$(SED) -e '1s/^/Release v$*\n/' | \
$(SED) -e '/^#/d' -e '/^$$/d' | \
$(SED) -e 's/\*//g' | \
$(SED) -e '1a\\' > $@

else !DEVELOPER_MODE

Expand Down

0 comments on commit e5b21b2

Please sign in to comment.