-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (111 loc) · 4.51 KB
/
release.yml
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Release new version
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # use GITHUB_TOKEN
fetch-depth: 1 # fetch depth is nr of commits
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyriksdagen
pip install cycler
- name: Install jq
uses: dcarbone/install-jq-action@v2
with:
version: 1.7
force: false
- name: 'Check jq'
run: |
jq --version
- name: Get Current pyriksdagen version
run: |
PRD_INFO="$(curl -L https://api.github.com/repos/swerik-project/pyriksdagen/releases/latest)"
PRD_TAG="$(echo $PRD_INFO | jq -r .tag_name)"
echo "PRD_TAG=$PRD_TAG" >> $GITHUB_ENV
- name: Download metadata, get repo version nr, unzip
run: |
PERSONS_INFO="$(curl -L https://api.github.com/repos/swerik-project/riksdagen-persons/releases/latest)"
PERSONS_TAG="$(echo $PERSONS_INFO | jq -r .tag_name)"
echo "PERSONS_TAG=$PERSONS_TAG">> $GITHUB_ENV
curl -LO "$(echo $PERSONS_INFO | jq -r .assets[0].browser_download_url)"
mv persons.zip "persons_$PERSONS_TAG.zip"
unzip persons_$PERSONS_TAG.zip
- name: Upload metadata to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: persons_${{ env.PERSONS_TAG }}.zip
tag: ${{ github.ref }}
- name: Download records, get repo version nr, and unzip
run: |
RECORDS_INFO="$(curl -L https://api.github.com/repos/swerik-project/riksdagen-records/releases/latest)"
RECORDS_TAG="$(echo $RECORDS_INFO | jq -r .tag_name)"
echo "RECORDS_TAG=$RECORDS_TAG" >> $GITHUB_ENV
curl -LO "$(echo $RECORDS_INFO | jq -r .assets[0].browser_download_url)"
mv records.zip "records_$RECORDS_TAG.zip"
unzip records_$RECORDS_TAG.zip
- name: Upload records to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: records_${{ env.RECORDS_TAG }}.zip
tag: ${{ github.ref }}
- name: Calculate and Plot MP coverage
run: |
mkdir test-data
curl -LO https://raw.githubusercontent.com/swerik-project/riksdagen-persons/main/test/data/baseline-n-mps-year.csv
mv baseline-n-mps-year.csv test-data/
curl -LO https://raw.githubusercontent.com/swerik-project/riksdagen-persons/main/test/data/session-dates.csv
mv session-dates.csv test-data/
PYTHONPATH="$PYTHONPATH:." python readme/src/calculate-mp-coverage.py
PYTHONPATH="$PYTHONPATH:." python readme/src/plot-mp-coverage.py -v ${{ env.PERSONS_TAG }}
- name: Estimate and Plot Speaker-Intro mapping
run: |
PYTHONPATH="$PYTHONPATH:." python readme/src/estimate-intro-mapping-accuracy.py -v ${{ env.RECORDS_TAG }} --show False
- name: Generate README
run: |
PYTHONPATH="$PYTHONPATH:." python readme/src/generate-markdown.py -v ${{ github.ref }} -pv ${{ env.PERSONS_TAG }} -rv ${{ env.RECORDS_TAG }} -py ${{ env.PRD_TAG }}
- name: Dump merged metadata
run: |
PYTHONPATH="$PYTHONPATH:." python dumps/src/dump-merged-meta-tables.py
- name: Zip dumps
run: zip -r dumps_${{ github.ref_name }}.zip dumps/dumps
- name: Upload dumps to zip
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dumps_${{ github.ref_name }}.zip
tag: ${{ github.ref }}
- name: Remove Hyyuuggee files
run: |
rm stats/mp-coverage/coverage.csv
- name: Add and Commit generated file
run: |
git status
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add stats/
git commit -m "chore: update version stats"
git add plots/
git commit -m "chore: update version plots"
git add README.md
git commit -m "chore: update README."
git status
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main