-
-
Notifications
You must be signed in to change notification settings - Fork 1
101 lines (86 loc) · 3.53 KB
/
Copy pathrelease-notes.yml
File metadata and controls
101 lines (86 loc) · 3.53 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
98
99
100
101
name: Release Notes Generator
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Tag to generate release notes for'
required: true
type: string
jobs:
generate-release-notes:
name: Generate Release Notes
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version info
id: version
run: |
if [ "${{ github.event_name }}" == "release" ]; then
TAG="${{ github.event.release.tag_name }}"
else
TAG="${{ github.event.inputs.tag }}"
fi
VERSION=${TAG#v}
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Extract changelog for version
id: changelog
run: |
# Extract the section for this version from CHANGELOG.md
VERSION="${{ steps.version.outputs.version }}"
awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | head -n -1 > release_notes.md
if [ ! -s release_notes.md ]; then
echo "## What's Changed" > release_notes.md
echo "" >> release_notes.md
echo "See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details." >> release_notes.md
fi
- name: Generate contributor list
run: |
# Get previous tag
PREV_TAG=$(git describe --tags --abbrev=0 ${{ steps.version.outputs.tag }}^ 2>/dev/null || git rev-list --max-parents=0 HEAD)
echo "" >> release_notes.md
echo "## 👥 Contributors" >> release_notes.md
echo "" >> release_notes.md
# Get list of contributors
git log $PREV_TAG..${{ steps.version.outputs.tag }} --format='%aN' | sort -u | while read name; do
echo "- @$name" >> release_notes.md
done
- name: Add installation instructions
run: |
echo "" >> release_notes.md
echo "## 📦 Installation" >> release_notes.md
echo "" >> release_notes.md
echo '```yaml' >> release_notes.md
echo 'dependencies:' >> release_notes.md
echo " docx_viewer: ^${{ steps.version.outputs.version }}" >> release_notes.md
echo '```' >> release_notes.md
echo "" >> release_notes.md
echo "## 📚 Documentation" >> release_notes.md
echo "" >> release_notes.md
echo "- [pub.dev](https://pub.dev/packages/docx_viewer)" >> release_notes.md
echo "- [API Docs](https://pub.dev/documentation/docx_viewer/latest/)" >> release_notes.md
echo "- [README](https://github.com/${{ github.repository }}/blob/main/README.md)" >> release_notes.md
- name: Update release notes
if: github.event_name == 'release'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const releaseNotes = fs.readFileSync('release_notes.md', 'utf8');
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: context.payload.release.id,
body: releaseNotes
});
- name: Upload release notes artifact
uses: actions/upload-artifact@v4
with:
name: release-notes-${{ steps.version.outputs.version }}
path: release_notes.md
retention-days: 90