Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust update-release-list #288

Merged
merged 2 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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