Browse Source

ci: Add autogenerated release notes

Signed-off-by: Dave Tucker <[email protected]>
Dave Tucker 3 years ago
parent
commit
dc16739b06
3 changed files with 78 additions and 0 deletions
  1. 31 0
      .github/changelog-base.json
  2. 13 0
      .github/prep-changelog-config.sh
  3. 34 0
      .github/workflows/release.yml

+ 31 - 0
.github/changelog-base.json

@@ -0,0 +1,31 @@
+{
+    "categories": [
+      {
+        "title": "## 🚀 Features",
+        "labels": ["feature"],
+        "exhaustive": true
+      },
+      {
+        "title": "## 🐛 Fixes",
+        "labels": ["fix"],
+        "exhaustive": true
+      },
+      {
+        "title": "## 🧪 Tests",
+        "labels": ["test"],
+        "exhaustive": true
+      }
+    ],
+    "ignore_labels": [
+      "ignore"
+    ],
+    "tag_resolver": {
+      "filter": {
+        "pattern": "<from-workflow>"
+      },
+      "transformer": {
+        "pattern": "<from-workflow>",
+        "target": "$1"
+      }
+    }
+}

+ 13 - 0
.github/prep-changelog-config.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Remove "refs/tags/"
+tag="${GITHUB_REF##*/}"
+# Extract crate name
+crate=$(echo $tag | sed 's/-v[0-9].*//g')
+# Semver portion follows after the ${crate}-v
+tagPattern="${crate}-v(.+)"
+
+echo ::group::Configuring changelog generator
+jq '.tag_resolver.filter.pattern="'$tagPattern'" | .tag_resolver.transformer.pattern="'$tagPattern'" | .categories[].labels += ["'$crate'"]' \
+  .github/changelog-base.json | tee .github/changelog-config.json
+echo ::endgroup::

+ 34 - 0
.github/workflows/release.yml

@@ -0,0 +1,34 @@
+name: 'release'
+on:
+  push:
+    tags:
+      - '*'
+
+jobs:
+  release:
+    if: startsWith(github.ref, 'refs/tags/')
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+        with:
+          fetch-depth: 0
+
+      - name: Prep Config
+        run: .github/prep-changelog-config.sh
+
+      - name: Build Changelog
+        id: github_release
+        uses: mikepenz/release-changelog-builder-action@v2
+        with:
+          configuration: ".github/changelog-config.json"
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Create Release
+        uses: actions/create-release@v1
+        with:
+          tag_name: ${{ github.ref }}
+          release_name: ${{ github.ref }}
+          body: ${{steps.github_release.outputs.changelog}}
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}