Skip to content
This repository was archived by the owner on Jun 22, 2024. It is now read-only.

Commit c8c9ea2

Browse files
Attempt to auto-generate GitHub release notes in CircleCI
1 parent 77e715e commit c8c9ea2

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

.circleci/config.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ jobs:
168168
echo 'export BRANCH=4.1.3' >> $BASH_ENV # find a better place to control this.
169169
source $BASH_ENV
170170
echo BRANCH="$BRANCH"
171-
171+
echo "Generate release notes"
172+
apt-get update -y && apt-get install python3-venv
173+
go get github.com/github-release/github-release
174+
export GITHUB_TOKEN=$(sh get-access-token.sh | tail -n 1)
175+
GITHUB_USER=seleniumhq-community GITHUB_REPO=docker-seleniarm ~/go/bin/github-release release --tag seleniarm-v4.1.3-20220409 --name seleniarm-v4.1.3-20220409 --description "Test Test"
172176
- run: |
173177
echo "Check if branch is deployable (contains [deploy] in commit msg on $DEPLOY_BRANCH"
174178
echo "Job name = " $CIRCLE_JOB

get-access-token.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import time
2+
from cryptography.hazmat.backends import default_backend
3+
import jwt
4+
import os
5+
import requests
6+
import logging
7+
8+
github_app_id = os.environ.get('GITHUB_APP_ID')
9+
github_installation_id = os.environ.get('GITHUB_INSTALLATION_ID')
10+
private_key = os.environ.get('GITHUB_APP_PEM')
11+
private_key = private_key.replace("\\n", "\n")
12+
13+
14+
time_since_epoch_in_seconds = int(time.time())
15+
16+
payload = {
17+
# issued at time
18+
'iat': time_since_epoch_in_seconds,
19+
# JWT expiration time (10 minute maximum)
20+
'exp': time_since_epoch_in_seconds + (10 * 60),
21+
# GitHub App's identifier
22+
'iss': github_app_id
23+
}
24+
25+
actual_jwt = jwt.encode(payload, private_key, algorithm='RS256')
26+
27+
headers = {"Authorization": "Bearer " + actual_jwt,
28+
"Accept": "application/vnd.github.v3+json"}
29+
30+
resp = requests.post('https://api.github.com/app/installations/' + github_installation_id + '/access_tokens', headers=headers)
31+
32+
print(resp.json()['token'])

get-access-token.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
python3 -m venv release_sandbox
4+
. release_sandbox/bin/activate
5+
if [ -z "$VIRTUAL_ENV" ]; then
6+
echo "Virtual environment not activated."
7+
exit 1
8+
fi
9+
10+
pip3 install cryptography
11+
pip3 install requests
12+
pip3 install PyJWT
13+
14+
GITHUB_APP_ID=$SELENIARM_GITHUB_APP_ID
15+
GITHUB_INSTALLATION_ID=$SELENIARM_GITHUB_INSTALLATION_ID
16+
GITHUB_APP_PEM="$SELENIARM_GITHUB_APP_PEM"
17+
18+
python3 get-access-token.py

0 commit comments

Comments
 (0)