Skip to content
Closed
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
16 changes: 16 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Read https://github.com/TheSuperHackers/GeneralsGameCode/tree/main/documentation/how_to_write_a_pull_request.md -->
## Change list
<!-- List changes -->
-

## Author(s)
<!-- List additional authors -->

## Fixes Issue(s) <!-- [Optional - Remove if unused] -->
<!-- Closes/Fixes/Resolves an issue (#123) -->

## Updates PR(s) <!-- [Optional - Remove if unused] -->
<!-- Updates/Continues a PR (#234) -->

## Additional Notes <!-- [Optional - Remove if unused] -->
<!-- None changelog related notes -->
62 changes: 62 additions & 0 deletions .github/workflows/changelog-file-generation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Generate Changelog
on:
pull_request:
types: [closed]

workflow_dispatch:
inputs:
pr-number:
description: 'PR number to process'
required: true
type: number

env:
SCRIPTS_PATH: .github/workflows/scripts/changelog_file_generation
CONFIG: pr_changelog_config.yaml

jobs:
process-pr:
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.pull_request.merged)
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ${{ env.SCRIPTS_PATH }}/requirements.txt

- name: Determine PR number
id: pr-number
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "pr_number=${{ github.event.inputs.pr-number }}" >> $GITHUB_OUTPUT
else
echo "pr_number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
fi

- name: Run changelog generator
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPOSITORY: ${{ github.repository }}
run: |
python ${{ env.SCRIPTS_PATH}}/src/generate_pr_yaml.py --pr-number ${{ steps.pr-number.outputs.pr_number }} --config ${{ env.CONFIG }} --force

- name: Commit generated files
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add changelogs/unreleased/*
git commit -m "Add changelog for PR #${{ steps.pr-number.outputs.pr_number }}" || echo "No changes to commit"
git push
47 changes: 47 additions & 0 deletions .github/workflows/pr-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: PR Linter
on:
pull_request:
types: [opened, edited, synchronize, reopened]
workflow_dispatch:
inputs:
pr-number:
description: 'PR number to process'
required: true
type: number

env:
SCRIPTS_PATH: .github/workflows/scripts/changelog_file_generation
CONFIG: pr_changelog_config.yaml

jobs:
validate-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ${{ env.SCRIPTS_PATH }}/requirements.txt

- name: Determine PR number
id: pr-number
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "pr_number=${{ github.event.inputs.pr-number }}" >> $GITHUB_OUTPUT
else
echo "pr_number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
fi

- name: Run PR Linter
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPOSITORY: ${{ github.repository }}
run: |
python ${{ env.SCRIPTS_PATH}}/src/pr_linter.py --pr-number ${{ steps.pr-number.outputs.pr_number }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# PR Changelog Generator Configuration
# ------------------------------------
# Defines how to parse PR content and structure output YAML

# Section Processing Configuration
sections:
# Change List Section
changes:
header: "Change list"
pattern: "^(\\w+): (.+)"
yaml_key: "changes"
processor: "key_value"
example: "- fix: Description of change"
required: true
allowed_keywords:
- fix
- feat
- breaking
- build
- ci
- balance
- performance
- docs
- test

# Authors Section
authors:
header: "Author\\(s\\)"
pattern: "@?(\\w+)"
yaml_key: "authors"
default: "$pr_creator"
example: "@username"
merge_with: ["$pr_creator"]
processor: "flat_list"

# Labels Section
fixes_issues:
header: "Fixes Issue\\(s\\)"
pattern: "([Cc]loses|[Ff]ixes|[Rr]esolves) (#?\\d+)"
yaml_key: "fixes_issues"
example: "- closes #123 or - fixes https://github.com/.../issues/456"
processor: "structured_links"
link_type: "issue"

# Linked PRs Section
updates_prs:
header: "Updates PR\\(s\\)"
pattern: "([Uu]pdates|[Cc]ontinues) (#?\\d+)"
yaml_key: "updates_prs"
example: "- Updates #2"
processor: "structured_links"
link_type: "pr"

# Title Processing Configuration
title_processing:
scope_pattern: "^\\[([\\w\/]+)\\]" # Pattern to extract scopes from title
scope_key: "affects" # YAML key for extracted scopes
clean_title: true # Whether to remove scopes from final title
example: "[GEN] short description, or [GEN/ZH] short description" # Example title format
allowed_scopes: # Validate title prefixes
- GEN
- ZH
- GITHUB
- BUILD
- AI
- ART
- AUDIO

# Output Configuration
output:
required_keys: # Mandatory keys in final YAML
- "date"
- "title"
- "changes"
filename_template: "$pr_number_$clean_title.yaml" # Output filename pattern
directory: "changelogs/unreleased" # Output directory for YAML files
order: # Order of keys in final YAML
- date
- title
- affects
- changes
- labels
- links
- authors
- fixes_issues
- updates_prs
Binary file not shown.
Loading
Loading