Skip to content

Commit

Permalink
feat(workflow): improve PR creation
Browse files Browse the repository at this point in the history
  • Loading branch information
s0up4200 committed Oct 21, 2024
1 parent 5968c5c commit f5d9113
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/update_release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ jobs:
- name: Run update script
id: update_script
run: python update_release_notes.py
run: |
python update_release_notes.py
echo "version=$(python update_release_notes.py --get-version)" >> $GITHUB_OUTPUT
- name: Commit files
run: |
Expand All @@ -35,11 +37,18 @@ jobs:
- name: Push changes
run: git push origin ${{ steps.update_script.outputs.branch }}

- name: Fetch latest autobrr release
id: fetch_release
run: |
LATEST_RELEASE=$(curl -s https://api.github.com/repos/autobrr/autobrr/releases/latest)
RELEASE_URL=$(echo $LATEST_RELEASE | jq -r .html_url)
echo "release_url=$RELEASE_URL" >> $GITHUB_OUTPUT
- name: Create Pull Request
uses: repo-sync/pull-request@v2
with:
source_branch: ${{ steps.update_script.outputs.branch }}
destination_branch: "main"
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "Update Release Notes"
pr_body: "Automatically update release notes"
pr_title: "docs: add release notes for v${{ steps.update_script.outputs.version }}"
pr_body: "Automatically update release notes for version ${{ steps.update_script.outputs.version }}. Latest autobrr release: ${{ steps.fetch_release.outputs.release_url }}"
16 changes: 16 additions & 0 deletions update_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import os
import requests
import argparse
import sys
from bs4 import BeautifulSoup
from git import Repo, GitCommandError
from markdownify import markdownify as md
Expand All @@ -13,6 +15,11 @@

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def get_latest_version():
_, url = fetch_latest_release()
version = url.split('/')[-1]
return version

def fetch_latest_release():
url = "https://github.com/autobrr/autobrr/releases/latest"
response = requests.get(url)
Expand Down Expand Up @@ -72,6 +79,15 @@ def git_operations():
return branch

def main():
parser = argparse.ArgumentParser()
parser.add_argument("--get-version", action="store_true", help="Get the latest version number")
args = parser.parse_args()

if args.get-version:
version = get_latest_version()
print(version)
return

git_operations()
html_content, url = fetch_latest_release()
version, release_date, markdown_content = parse_release_data(html_content, url)
Expand Down

0 comments on commit f5d9113

Please sign in to comment.