Skip to content

Commit 1b9a6d8

Browse files
committed
Implement a release in CI
Workflow release will be run when a new tag is pushed.
1 parent af2e620 commit 1b9a6d8

File tree

5 files changed

+66
-4
lines changed

5 files changed

+66
-4
lines changed

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Generate commit logs
33

44
on:
55
push:
6+
tags-ignore:
7+
- "*"
68
pull_request:
79
schedule:
810
- cron: "42 10 * * 1"

.github/workflows/release.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Releases
3+
4+
on:
5+
push:
6+
tags:
7+
- "*"
8+
9+
jobs:
10+
releases:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
env:
15+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
16+
GH_TAG: ${{ github.ref_name }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Generating commit logs
20+
run: |
21+
cd commits && ./generate.sh -t 0
22+
LOGS_DIR="output-$(date +%Y)-$(date +%W)"
23+
mv output $LOGS_DIR
24+
tar -czf maria-stats.tgz $LOGS_DIR
25+
- name: Generating pull requests stats
26+
run: |
27+
# calculate week-numbers
28+
WEEK_NUMBER=$(date +%W)
29+
YEAR=$(date +%Y)
30+
TILL="${YEAR}-W${WEEK_NUMBER}"
31+
FROM="${YEAR}-W1"
32+
cd pull-requests && ./get_prs.py -v "$FROM" "$TILL"
33+
mv prs*.csv prs.csv
34+
- name: Generating release body (TODO maybe overly complex)
35+
run: |
36+
sed -i "s/_TAG_/${GH_TAG}/g" .release_template.md
37+
- uses: ncipollo/release-action@v1
38+
with:
39+
artifacts: "commits/maria-stats.tgz,pull-requests/prs.csv"
40+
bodyFile: ".release_template.md"

.release_template.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# A metrics snapshot up to _TAG_
2+
3+
The output files include:
4+
5+
```
6+
people-*.csv - breakdown of commits by individual
7+
organisations-*.csv - breakdown of commits by organisations
8+
categories-*.csv - breakdown of commits by category
9+
prs.csv - breakdown of pull request statistics
10+
```
11+
12+
The `maria-stats.tgz` file contains the commit results for the following repositories:
13+
14+
- <https://github.com/mariadb-corporation/libmarias3>
15+
- <https://github.com/mariadb-corporation/mariadb-columnstore-engine>
16+
- <https://github.com/mariadb-corporation/mariadb-connector-c>
17+
- <https://github.com/mariadb/mariadb-docker>
18+
- <https://github.com/mariadb/mariadb_kernel>
19+
20+
The `prs.csv` file is just for the MariaDB Server tree.

pull-requests/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This tool gets the PR counts for 2022 and stores them in `prs-<START>..<END>.csv`. There is rate-limit handling built in because some calls are only allowed to do 30 requests per minute. It will also pause and retry upon 500 server errors.
66

7-
To execute this you will need a GitHub token from <https://github.com/settings/tokens/new> and set this as the environment variable `GITHUB_TOKEN`. You need to provide a date range using week numbers. For example, to generate a 2022 report:
7+
To execute this you will need a GitHub token from <https://github.com/settings/tokens/new> and set this as the environment variable `GH_TOKEN`. You need to provide a date range using week numbers. For example, to generate a 2022 report:
88

99
```
1010
./get_prs.py 2022-W1 2022-W52
@@ -22,7 +22,7 @@ This generates a list of pull requests that require attention. Options are:
2222
* `-s` - sort order, `longest` sorts the final output by the longest time since the last response, `shortest` sorts by the shortest time since the last response. By default it will be unsorted, so ordered by the report type option.
2323
* `-v` - verbose, add verbose output to the console.
2424

25-
As with `get_prs.py`, you will require the `GITHUB_TOKEN` environment variable.
25+
As with `get_prs.py`, you will require the `GH_TOKEN` environment variable.
2626

2727
## plot_prs.py
2828

pull-requests/pr_github.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import json
66
import re
77

8-
GITHUB_TOKEN = os.environ['GITHUB_TOKEN']
8+
GH_TOKEN = os.environ['GH_TOKEN']
99

10-
auth_header = {'Authorization': 'token ' + GITHUB_TOKEN}
10+
auth_header = {'Authorization': 'token ' + GH_TOKEN}
1111

1212

1313
def get_data(url, verbose):

0 commit comments

Comments
 (0)