Skip to content

Commit fbb78e8

Browse files
authored
Add workflow to generate CHANGELOG (#5106)
For now it's not associated to a release.
1 parent 6b1dd66 commit fbb78e8

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

.github/workflows/reports.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Automatically create CHANGELOG for O2 releases
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
jobs:
10+
build:
11+
runs-on: macOS-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Python 3.7
16+
uses: actions/setup-python@v1
17+
with:
18+
python-version: 3.7
19+
- uses: actions/cache@v2
20+
name: Configure pip caching
21+
with:
22+
path: ~/.cache/pip
23+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
24+
restore-keys: |
25+
${{ runner.os }}-pip-
26+
- uses: octokit/graphql-action@v2.x
27+
id: get_latest_o2_releases
28+
with:
29+
query: |
30+
{
31+
repository(name: "AliceO2", owner: "AliceO2Group") {
32+
releases(last:14) {
33+
edges {
34+
node {
35+
tagName
36+
publishedAt
37+
}
38+
}
39+
}
40+
}
41+
}
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
- uses: octokit/graphql-action@v2.x
45+
id: get_latest_o2_prs
46+
with:
47+
query: |
48+
{
49+
repository(name: "AliceO2", owner: "AliceO2Group") {
50+
pullRequests(last: 100) {
51+
edges {
52+
node {
53+
state
54+
mergedAt
55+
title
56+
number
57+
author {
58+
login
59+
}
60+
files(last: 100) {
61+
edges {
62+
node {
63+
path
64+
}
65+
}
66+
}
67+
}
68+
}
69+
}
70+
}
71+
}
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
- name: Update Changelog
75+
run: |
76+
mkdir -p doc/data
77+
# We create new files once per month, mostly so that
78+
# we can keep the query results small. It does not
79+
# matter if we get results from different months,
80+
# as what matters is how we merge them.
81+
CURRENT_MONTH=`date +%Y-%m`
82+
cat <<\EOF > doc/data/${CURRENT_MONTH}-o2_releases.json
83+
${{ steps.get_latest_o2_releases.outputs.data }}
84+
EOF
85+
cat <<\EOF > doc/data/${CURRENT_MONTH}-o2_prs.json
86+
${{ steps.get_latest_o2_prs.outputs.data }}
87+
EOF
88+
# FIXME: this should really be one second after the last release
89+
# being published
90+
MERGED_AFTER=`date -v -14d +%Y-%m-%d`
91+
92+
# Here we convert all the json files to per subsystem
93+
# logs, using the MERGED_AFTER date to further filter them.
94+
# Notice we can have duplicates in each file,
95+
# as they will be removed in the next iteration.
96+
# FIXME: it's probably enough to iterate on the last two
97+
# months, at least for bi-weekly releases.
98+
for f in doc/data/*_prs.json; do
99+
for x in Algorithm Analysis Common DataFormats Detectors EventVisualisation Examples Framework Generators Steer Testing Utilities; do
100+
cat doc/data/o2_prs.json | jq ".repository.pullRequests.edges[].node | select(.files.edges[].node.path | test(\"$x\")) | del(.files) | select(.state == \"MERGED\" and .mergedAt >= \"${MERGED_AFTER}\")" > /tmp/$x_prs.json
101+
if [ ! X`jq -s length /tmp/$x_prs.json` = X0 ]; then
102+
cat $f | jq -r '"- [#\(.number)](https://github.com/AliceO2Group/AliceO2/pull/\(.number)) \(.mergedAt | split("T")[0]): \(.title) by [@\(.author.login)](https://github.com/\(.author.login))"' | sort -u >> /tmp/$x_prs.md
103+
fi
104+
done
105+
done
106+
# Here we do the merging by iterating on the subsystems adding
107+
# an header for each and removing the duplicates.
108+
cat << EOF > CHANGELOG.md
109+
# Changes since ${MERGED_AFTER}
110+
111+
EOF
112+
113+
for x in Algorithm Analysis Common DataFormats Detectors EventVisualisation Examples Framework Generators Steer Testing Utilities; do
114+
cat << EOF >> CHANGELOG.md
115+
## Changes in $x
116+
EOF
117+
cat /tmp/$x_prs.md | sort -k3 | uniq >> CHANGELOG.md
118+
done
119+
- name: Commit and push if changed
120+
run: |-
121+
git add CHANGELOG.md doc/data
122+
git diff
123+
git config --global user.email "github-action-bot@example.com"
124+
git config --global user.name "GitHub Action Bot"
125+
git commit -m "Updated README" -a || echo "No changes to commit"
126+
git push

0 commit comments

Comments
 (0)