Skip to content

Commit

Permalink
Merge pull request #288 from k-takata/adjust-update-release-list
Browse files Browse the repository at this point in the history
Adjust update-release-list
  • Loading branch information
k-takata authored Oct 14, 2022
2 parents fa162b8 + cbf5603 commit e86c2c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/update-release-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
# branches: [master]
# types: [completed]

permissions:
contents: write # to update wiki

env:
# Account for committing
USER_NAME: "vim-win32-installer CI"
Expand All @@ -24,11 +27,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
path: main

- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: "${{ github.repository }}.wiki"
path: wiki
Expand Down
19 changes: 12 additions & 7 deletions scripts/update-release-list.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

gh_releases_url = f'https://api.github.com/repos/{GITHUB_REPOSITORY}/releases'

rel_name_pat = re.compile(r'^\* \[(v\d+\.\d+\.\d+)\]')


# Get information of GitHub release
# see: https://docs.github.com/en/rest/reference/repos#releases
Expand Down Expand Up @@ -41,7 +43,7 @@ def get_latest_rel():
rel = ''
with open(files[-1]) as f:
for l in f:
m = re.match(r'^\* \[(v\d+\.\d+\.\d+)\]', l)
m = rel_name_pat.match(l)
if m:
rel = m.group(1)
if rel == '':
Expand All @@ -58,9 +60,7 @@ def get_new_rels(rels_info, latest_rel):
return rels


def write_new_rels(new_rels, latest_rel):
latest_file = sorted(glob.glob('Releases-in-*.md'))[-1]

def read_latest_rel(latest_file):
lines = []
last_y = ''
last_m = ''
Expand All @@ -71,20 +71,25 @@ def write_new_rels(new_rels, latest_rel):
last_y = m1.group(1)
last_m = m1.group(2)
else:
m2 = re.match(r'^\* \[(v\d+\.\d+\.\d+)\]', l)
m2 = rel_name_pat.match(l)
if m2.group(1) == latest_rel:
lines += [l]
break
lines += [l]
return last_y, last_m, lines


def write_new_rels(new_rels, latest_rel):
latest_file = sorted(glob.glob('Releases-in-*.md'))[-1]
last_y, last_m, lines = read_latest_rel(latest_file)

print('New releases: ', end='')
f = open(latest_file, 'w')
for i, rel in enumerate(new_rels):
pub_at = rel['published_at']
if not pub_at:
pub_at = rel['created_at']
y = pub_at[:4]
m = pub_at[5:7]
y, m = pub_at.split('-')[:2]
if y != last_y:
f.writelines(lines)
f.close()
Expand Down

0 comments on commit e86c2c7

Please sign in to comment.