diff --git a/.github/workflows/release-entry.yaml b/.github/workflows/release-entry.yaml new file mode 100644 index 0000000..92078fc --- /dev/null +++ b/.github/workflows/release-entry.yaml @@ -0,0 +1,53 @@ +name: Release Changelog + +on: + push: + # Automatically create a GitHub Release entry when a tag that looks like a new release is pushed. + # The tag pattern is defined in maven-release-plugin's settings in pom.xml authoritatively. The changelog + # generator - git-cliff - just goes through all relevant tags, regardless of their name. + tags: + - 'v[0-9]+.*' + +jobs: + release: + name: Create GitHub Release entry + runs-on: ubuntu-latest + permissions: + # Needed by softprops/action-gh-release to create the GitHub Release entry: + contents: write + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + + - uses: cachix/install-nix-action@v31 + + - uses: cachix/cachix-action@v16 + with: + name: devenv + + - name: Install devenv.sh + run: nix profile install nixpkgs#devenv + + - name: Generate change list + shell: devenv shell bash -- -e {0} + run: | + task release:changelog FILE=changes.md + + - name: Include the change list in summary + shell: devenv shell bash -- -e {0} + continue-on-error: true + run: | + echo -e "# Generated change list:\n\n----\n\n" >> "$GITHUB_STEP_SUMMARY" + cat changes.md >> "$GITHUB_STEP_SUMMARY" + + - name: Create GitHub Release entry + uses: softprops/action-gh-release@v2 + if: github.ref_type == 'tag' + with: + # Populate the release entry body with the notes we generated + body_path: changes.md + # A hooman still needs to push the butan + draft: true + +# eof diff --git a/Taskfile.yaml b/Taskfile.yaml index c40de82..84596ce 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -22,15 +22,21 @@ tasks: cmds: - cmd: mvn -Pupgrades - maintenance:check-reproducibility: + release:changelog: + desc: Creates list of changes since the last release tag + cmds: + - cmd: git-cliff --current --unreleased --output {{ .FILE | default "-" | shellQuote }} + + release:check-reproducibility: # See https://maven.apache.org/guides/mini/guide-reproducible-builds.html desc: Check if artifacts are reproducible cmds: - cmd: mvn artifact:check-buildplan - cmd: mvn clean install - cmd: mvn clean verify artifact:compare + - cmd: mvn clean - maintenance:release: + release:create: desc: Cuts off a new release and deploys artifacts to Sonatype Maven Central summary: | This task verifies that appropriate credentials have been entered, cuts off a new @@ -81,6 +87,7 @@ tasks: echo - cmd: echo "This step primes GnuPG cache so it can be used in non-interactive mode" | gpg --clearsign + - task: release:check-reproducibility - cmd: mvn --settings={{ .SETTINGS_FILE | shellQuote }} -Prelease -DdryRun=true - cmd: mvn --settings={{ .SETTINGS_FILE | shellQuote }} -Prelease - silent: true diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..434a149 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,92 @@ +# git-cliff ~ configuration file +# https://github.com/orhun/git-cliff +# https://git-cliff.org/docs/configuration + +[changelog] +# A Tera template to be rendered for each release in the changelog. +# See https://keats.github.io/tera/docs/#introduction +body = """ +{% if version %}\ + ## [{{ version }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits %} + * {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message | upper_first | split(pat='\n') | first }}\ + {% endfor %} +{% endfor %} +""" +# Remove leading and trailing whitespaces from the changelog's body. +trim = true +# Render body even when there are no releases to process. +render_always = true +# An array of regex based postprocessors to modify the changelog. +postprocessors = [ + # Replace the placeholder with a URL. + { pattern = '', replace = "https://github.com/tguzik/valueclasses" }, +] +# Default output file path +#output = "CHANGELOG.md" + +[git] +# Parse commits according to the conventional commits specification. +# See https://www.conventionalcommits.org +conventional_commits = true +# Exclude commits that do not match the conventional commits specification. +filter_unconventional = false +# Require all commits to be conventional. +# Takes precedence over filter_unconventional. +require_conventional = false +# Split commits on newlines, treating each line as an individual commit. +split_commits = false +# An array of regex based parsers to modify commit messages prior to further processing. +commit_preprocessors = [ + # Replace issue numbers with link templates to be updated in `changelog.postprocessors`. + { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))" }, +] +# Prevent commits that are breaking from being excluded by commit parsers. +protect_breaking_commits = true +# An array of regex-based parsers that assign commits to a group. +# Optionally sets the commit's scope and can decide to exclude commits from further processing. +# The regex is applied over the whole message. + +# The entries here are processed in order and the first matched regex (the `message` prop) will assign the commit to a group. The +# groups in the output appear in the ascending lexical order of the group names, not the order of these entries. The HTML comment +# in the name of the group still participates in sorting but is omitted from the output - we're using it to manually set the +# order. +# Additional examples: https://git-cliff.org/docs/configuration/git#commit_parsers +commit_parsers = [ + { message = "^feat", group = "Features:" }, + { message = "^fix", group = "Bug Fixes:" }, + { message = "^doc", group = "Documentation:" }, + { message = "^perf", group = "Performance:" }, + { message = "^refactor", group = "Refactor:" }, + { message = "^style", group = "Code Styling:" }, + { message = "^test", group = "Testing:" }, + { message = "^deps|^build\\(deps(-dev)?\\)", group = "Dependencies:" }, + { message = "^build|^ci|^chore", group = "Maintenance:" }, + { message = "^revert", group = "Revert:" }, + # { message = "^chore\\(pull\\)", skip = true }, + { message = ".*", group = "Other:" }, +] +# Exclude commits that are not matched by any commit parser. +filter_commits = false +# An array of link parsers for extracting external references, and turning them into URLs, using regex. +link_parsers = [] +# Include only the tags that belong to the current branch. +use_branch_tags = false +# Order releases topologically instead of chronologically. +topo_order = false +# Order releases topologically instead of chronologically. +topo_order_commits = true +# Order of commits in each group/release within the changelog. +# Allowed values: newest, oldest +sort_commits = "newest" +# Process submodules commits +recurse_submodules = false + +# eof diff --git a/devenv.nix b/devenv.nix index 3edcb77..6e86fd9 100644 --- a/devenv.nix +++ b/devenv.nix @@ -14,12 +14,21 @@ # https://devenv.sh/packages/ # https://search.nixos.org/packages # Note that the JDK and Maven are already pulled in through the `languages.java` props. - packages = [ + packages = with pkgs; [ # Basic utilities - pkgs.curl - pkgs.git - pkgs.go-task - pkgs.gnupg + curl + git + go-task + gnupg + + # Maven Daemon + # https://github.com/apache/maven-mvnd + mvnd + + # Highly customizable changelog generator + # https://github.com/orhun/git-cliff + # https://git-cliff.org/docs/ + git-cliff ]; git-hooks.hooks = {