-
Notifications
You must be signed in to change notification settings - Fork 4
50 lines (42 loc) · 1.6 KB
/
update_setupcfg.yaml
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
name: Sync Codemeta with Setup
on:
push:
paths:
- codemeta.json
jobs:
sync-codemeta:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install jq for JSON parsing
run: sudo apt-get install -y jq
- name: Parse and update setup.cfg
run: |
# Extract values from codemeta.json
NAME=$(jq -r '.name' codemeta.json)
VERSION=$(jq -r '.version' codemeta.json)
AUTHORS=$(jq -r '[.author[] | .givenName + " " + .familyName] | join(", ")' codemeta.json)
AUTHOR_EMAILS=$(jq -r '[.author[] | .email // empty] | join(", ")' codemeta.json)
DESCRIPTION=$(jq -r '.description' codemeta.json)
URL=$(jq -r '.codeRepository // .url' codemeta.json)
# Update setup.cfg fields
sed -i "s/^name = .*/name = $NAME/" setup.cfg
sed -i "s/^version = .*/version = $VERSION/" setup.cfg
sed -i "s/^author = .*/author = $AUTHORS/" setup.cfg
sed -i "s/^author_email = .*/author_email = $AUTHOR_EMAILS/" setup.cfg
sed -i "s/^description = .*/description = $DESCRIPTION/" setup.cfg
sed -i "s|^url = .*|url = $URL|" setup.cfg
- name: Commit changes
run: |
if ! git diff --quiet; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add setup.cfg
git commit -m "Sync setup.cfg with codemeta.json changes"
git push
fi