CI: Generate GitHub releases 39/72339/1
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Mon, 6 Nov 2023 22:29:29 +0000 (14:29 -0800)
committerAndrew Grimberg <agrimberg@linuxfoundation.org>
Mon, 6 Nov 2023 22:29:29 +0000 (14:29 -0800)
* Increase the checkout depth from 1 to 30 to handle reno needing to be
  able to find all relevant tags (current and current -1) and also pull
  the tags
* Setup Python to run reno
* Generate a reno report for the given tag and then modify the report to
  strip out all the extra garbage that is added by the report process to
  get it into a valid markdown file and not RST file
* Use `gh` cli tool to generate the release notes using the
  auto-changelog generation plus the reno release notes

Issue: RELENG-4975
Change-Id: Ie05579dfd757e7d3be7169da987bf67229f4f818
Signed-off-by: Andrew Grimberg <agrimberg@linuxfoundation.org>
.github/release.yml [new file with mode: 0644]
.github/workflows/release.yaml

diff --git a/.github/release.yml b/.github/release.yml
new file mode 100644 (file)
index 0000000..6072919
--- /dev/null
@@ -0,0 +1,7 @@
+# .github/release.yml
+
+changelog:
+  categories:
+    - title: Changes
+      labels:
+        - "*"
index 06e614f..75091ea 100644 (file)
@@ -10,7 +10,10 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 30
+          fetch-tags: true
       - name: Get tag
         id: tag
         uses: devops-actions/action-get-tag@v1.0.2
@@ -39,3 +42,29 @@ jobs:
 
             Cheers,
             LF Releng
+      - name: Configure Python
+        uses: actions/setup-python@v4
+        with:
+          python-version: "3.8"
+      - name: Generate reno report
+        run: >-
+          pipx run tox -e reno -- report \
+            --version "${{ steps.tag.outputs.tag }}" \
+            2>/dev/null > reno-notes.md || true
+          if grep -q 'reno: FAIL' reno-notes.md
+          then
+            touch modified-reno-notes.md
+          else
+            sed '/^\.pkg.*$/d' reno-notes.md |
+            sed '/^reno:.*$/d' |
+            sed '/^\.\. .*$/d' |
+            sed '$d' |
+            sed '$d' |
+            sed '1d' > modified-reno-notes.md
+          fi
+      - name: Create Release Notes
+        run: >-
+          gh release create ${{ steps.tag.outputs.tag }} --generate-notes \
+            -F modified-reno-notes.md
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}