-
-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (81 loc) · 2.89 KB
/
release-notes-generator.yml
File metadata and controls
97 lines (81 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Generate Release Notes
on:
release:
types: [published, prereleased, released]
workflow_dispatch:
inputs:
tag_name:
description: "Tag to generate notes for (optional). If empty, uses latest tag in repo."
required: false
default: ""
permissions:
contents: write
jobs:
generate-release-notes:
name: Generate AI-powered release notes
runs-on: ubuntu-latest
timeout-minutes: 10
env:
PIP_DISABLE_PIP_VERSION_CHECK: '1'
PIP_NO_PYTHON_VERSION_WARNING: '1'
PIP_PROGRESS_BAR: 'off'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install openai
- name: Determine tag
id: tag
shell: bash
run: |
set -euo pipefail
if [[ "${{ github.event_name }}" == "release" ]]; then
TAG_NAME="${{ github.event.release.tag_name }}"
else
# workflow_dispatch
if [[ -n "${{ github.event.inputs.tag_name }}" ]]; then
TAG_NAME="${{ github.event.inputs.tag_name }}"
else
# Fallback: most recent tag by creation date
TAG_NAME="$(git tag --sort=-creatordate | head -n 1 || true)"
fi
fi
if [[ -z "${TAG_NAME}" ]]; then
echo "No tag found/provided. Exiting."
exit 1
fi
echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
echo "Will generate notes for tag: ${TAG_NAME}"
- name: Generate release notes (OpenAI)
id: generate
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
set -euo pipefail
python .github/scripts/generate_release_notes.py "${{ steps.tag.outputs.tag_name }}" --output /tmp/release_notes.md
echo "notes_path=/tmp/release_notes.md" >> "$GITHUB_OUTPUT"
- name: Update release with generated notes (gh)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="${{ steps.tag.outputs.tag_name }}"
NOTES_FILE="${{ steps.generate.outputs.notes_path }}"
# If run from 'release' event, the release exists. If run manually, ensure there is a release.
# We simply edit the release for the tag (must exist). You can also create if missing.
gh release edit "${TAG}" --repo "${{ github.repository }}" --notes-file "${NOTES_FILE}"
- name: Upload release notes as artifact
uses: actions/upload-artifact@v4
with:
name: release-notes-${{ steps.tag.outputs.tag_name }}
path: /tmp/release_notes.md
retention-days: 30