mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 04:31:13 +00:00
Final Implementation of Changelog V2 (#6050)
* Updated the release drafter to process the released changelog for OpenBB Platform * Update release drafter configuration * Add OpenBB Documentation Changes and Create Release * Update process_changelog.py path in draft-release.yml * Update release-drafter version and save changelog * Copy changelog with python * Update draft-release.yml to save Changelog * Update draft-release.yml * Encode and save Changelog to Base64 * Update Changelog saving method * Update Changelog format * Update CHANGELOG.md with release notes * Fix draft release workflow * Add cat command to print CHANGELOG.md * Add platform-drafter.yml and update release-drafter.yml and draft-release.yml * Commented out config-name in release-drafter step * Update branch name validation and process_changelog.py * Refactor process_changelog.py to improve readability and maintainability * Refactor process_changelog.py to handle file I/O errors and remove duplicate PR entries --------- Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
This commit is contained in:
3
.github/labeler.yml
vendored
3
.github/labeler.yml
vendored
@@ -15,6 +15,9 @@ labels:
|
||||
- label: "bug"
|
||||
branch: "^hotfix/.*"
|
||||
|
||||
- label: "bug"
|
||||
branch: "^bugfix/.*"
|
||||
|
||||
- label: "docs"
|
||||
branch: "^docs/.*"
|
||||
|
||||
|
||||
48
.github/platform-drafter.yml
vendored
Normal file
48
.github/platform-drafter.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
name-template: 'OpenBB Platform v$NEXT_MINOR_VERSION'
|
||||
tag-template: 'v$NEXT_MINOR_VERSION'
|
||||
categories:
|
||||
- title: 🦋 OpenBB Platform Enhancements
|
||||
labels:
|
||||
- 'platform'
|
||||
- 'v4'
|
||||
- title: 🐛 OpenBB Platform Bug Fixes
|
||||
labels:
|
||||
- 'bug'
|
||||
- title: 📚 OpenBB Documentation Changes
|
||||
labels:
|
||||
- 'docs'
|
||||
include-labels:
|
||||
- 'platform'
|
||||
- 'v4'
|
||||
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
|
||||
change-title-escapes: '\<*_&'
|
||||
exclude-contributors:
|
||||
- 'jmaslek'
|
||||
- 'DidierRLopes'
|
||||
- 'deeleeramone'
|
||||
- 'hjoaquim'
|
||||
- 'jose-donato'
|
||||
- 'luqmanbello'
|
||||
- 'montezdesousa'
|
||||
- 'tehcoderer'
|
||||
- 'colin99d'
|
||||
- 'piiq'
|
||||
- 'andrewkenreich'
|
||||
- 'IgorWounds'
|
||||
- 'minhhoang1023'
|
||||
|
||||
template: |
|
||||
## Thank you and welcome to our new contributors 🔥
|
||||
$CONTRIBUTORS
|
||||
|
||||
## What's new 🎉
|
||||
|
||||
## What's changed 🚀
|
||||
$CHANGES
|
||||
|
||||
We are proud of our community contributors and staunch supporters of open-source ecosystems.
|
||||
Help us promote our community by tagging `@openbb_finance` on X with a link to your pull request,
|
||||
and join our Discord server to chat about your contribution! We want to hear about your experience!
|
||||
|
||||
### Links 🦋
|
||||
[Website](https://openbb.co/), [Twitter](https://twitter.com/openbb_finance), [Linkedin](https://www.linkedin.com/company/openbb-finance), [Instagram](https://www.instagram.com/openbb.finance/), [Reddit](https://www.reddit.com/r/openbb/), [Discord](https://discord.com/invite/xPHTuHCmuV)
|
||||
5
.github/release-drafter.yml
vendored
5
.github/release-drafter.yml
vendored
@@ -8,6 +8,11 @@ categories:
|
||||
- title: 🐛 OpenBB Platform Bug Fixes
|
||||
labels:
|
||||
- 'bug'
|
||||
- title: 📚 OpenBB Documentation Changes
|
||||
labels:
|
||||
- 'docs'
|
||||
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
|
||||
change-title-escapes: '\<*_&'
|
||||
exclude-contributors:
|
||||
- 'jmaslek'
|
||||
- 'DidierRLopes'
|
||||
|
||||
2
.github/workflows/branch-name-check.yml
vendored
2
.github/workflows/branch-name-check.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
||||
- name: Check branch name for develop PRs
|
||||
if: ${{ steps.branch-name-check.outputs.target-branch == 'develop' }}
|
||||
run: |
|
||||
if [[ "${{ steps.branch-name-check.outputs.source-branch }}" =~ ^(main|feature/.*|docs/.*|hotfix/.*|release/[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]+)?)$ ]]; then
|
||||
if [[ "${{ steps.branch-name-check.outputs.source-branch }}" =~ ^(main|feature/.*|docs/.*|hotfix/.*|bugfix/.*|release/[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]+)?)$ ]]; then
|
||||
echo "Branch name is valid"
|
||||
else
|
||||
echo "Invalid branch name. Branches must follow the GitFlow naming convention to be allowed to merge into the develop branch."
|
||||
|
||||
42
.github/workflows/draft-release.yml
vendored
42
.github/workflows/draft-release.yml
vendored
@@ -1,11 +1,49 @@
|
||||
name: Release Drafter
|
||||
|
||||
on: workflow_dispatch
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_pr_number:
|
||||
description: 'Release PR Number'
|
||||
required: true
|
||||
default: ''
|
||||
tag:
|
||||
description: 'Tag for release (manual input)'
|
||||
required: true
|
||||
default: ''
|
||||
|
||||
jobs:
|
||||
update_release_draft:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: release-drafter/release-drafter@v5.21.0
|
||||
- name: 📟 Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 📝 Release Drafter
|
||||
id: release-drafter
|
||||
uses: release-drafter/release-drafter@v6.0.0
|
||||
# with:
|
||||
# config-name: platform-drafter.yml
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: 💾 Save Changelog
|
||||
run: |
|
||||
cat << 'EOF' > CHANGELOG.md
|
||||
${{ steps.release-drafter.outputs.body }}
|
||||
EOF
|
||||
|
||||
- name: 🧬 Process Changelog
|
||||
run: |
|
||||
python process_changelog.py CHANGELOG.md ${{ github.event.inputs.release_pr_number }}
|
||||
cat CHANGELOG.md
|
||||
|
||||
- name: 🛫 Create Release
|
||||
uses: mikepenz/action-gh-release@v1
|
||||
with:
|
||||
body_path: "CHANGELOG.md"
|
||||
tag_name: ${{ github.event.inputs.tag }}
|
||||
prerelease: false
|
||||
draft: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
82
process_changelog.py
Normal file
82
process_changelog.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# process_changelog.py
|
||||
import logging
|
||||
import re
|
||||
import sys
|
||||
|
||||
# Set up basic configuration for logging
|
||||
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
|
||||
|
||||
|
||||
def process_changelog(file_path, release_pr_number):
|
||||
# Attempt to open and read the file content
|
||||
try:
|
||||
with open(file_path) as file: # Default mode is 'r' for read
|
||||
lines = file.readlines()
|
||||
except OSError as e: # Catching file I/O errors
|
||||
logging.error(f"Failed to open or read file: {e}")
|
||||
return
|
||||
|
||||
pr_occurrences = {} # Dictionary to track occurrences of PR numbers
|
||||
|
||||
# Iterate through each line to find PR numbers
|
||||
for i, line in enumerate(lines):
|
||||
match = re.search(r"\(#(\d+)\)", line) # Regex to find PR numbers
|
||||
if match:
|
||||
pr_number = int(match.group(1))
|
||||
# Add line index to the list of occurrences for the PR number
|
||||
if pr_number not in pr_occurrences:
|
||||
pr_occurrences[pr_number] = []
|
||||
pr_occurrences[pr_number].append(i)
|
||||
|
||||
# Set of indices to remove: includes all but last occurrence of each PR number
|
||||
to_remove = {
|
||||
i
|
||||
for pr, indices in pr_occurrences.items()
|
||||
if len(indices) > 1
|
||||
for i in indices[:-1]
|
||||
}
|
||||
# Also remove any PR entries less than or equal to the specified release PR number
|
||||
to_remove.update(
|
||||
i
|
||||
for pr, indices in pr_occurrences.items()
|
||||
for i in indices
|
||||
if pr <= release_pr_number
|
||||
)
|
||||
|
||||
# Filter out lines marked for removal
|
||||
processed_lines = [line for i, line in enumerate(lines) if i not in to_remove]
|
||||
|
||||
# Final sweep: Ensure no missed duplicates, keeping only the last occurrence
|
||||
final_lines = []
|
||||
seen_pr_numbers = set() # Track seen PR numbers to identify duplicates
|
||||
for line in reversed(
|
||||
processed_lines
|
||||
): # Start from the end to keep the last occurrence
|
||||
match = re.search(r"\(#(\d+)\)", line)
|
||||
if match:
|
||||
pr_number = int(match.group(1))
|
||||
if pr_number in seen_pr_numbers:
|
||||
continue # Skip duplicate entries
|
||||
seen_pr_numbers.add(pr_number)
|
||||
final_lines.append(line)
|
||||
final_lines.reverse() # Restore original order
|
||||
|
||||
# Write the processed lines back to the file
|
||||
try:
|
||||
with open(file_path, "w") as file:
|
||||
file.writelines(final_lines)
|
||||
except OSError as e: # Handling potential write errors
|
||||
logging.error(f"Failed to write to file: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Ensure correct command line arguments
|
||||
if len(sys.argv) < 3:
|
||||
logging.error(
|
||||
"Usage: python process_changelog.py <changelog_file> <release_pr_number>"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
file_path = sys.argv[1]
|
||||
release_pr_number = int(sys.argv[2])
|
||||
process_changelog(file_path, release_pr_number)
|
||||
Reference in New Issue
Block a user