Skip to content

Commit

Permalink
ci: Generate changelog for Studio on release
Browse files Browse the repository at this point in the history
  • Loading branch information
psyGamer committed Oct 27, 2024
1 parent 5cfe393 commit 56e4927
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/Build.CelesteStudio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ jobs:
run: sed -i "s/-dev/-$(git rev-parse --short HEAD)/" Studio/CelesteStudio/Studio.cs
if: ${{ inputs.build-cfg == 'Debug' }}

- name: Download changelog
uses: actions/download-artifact@v4
with:
pattern: changelog-studio
if: ${{ inputs.build-cfg == 'Release' }}
- name: Move changelog into Assets
run: mv changelog-studio/studio_changelog.md Studio/CelesteStudio/Assets/Changelog.md
if: ${{ inputs.build-cfg == 'Release' }}

- name: Publish x64
run: dotnet publish Studio/CelesteStudio.WPF -c ${{ inputs.build-cfg }} -r win-x64 --output build-x64

Expand Down
66 changes: 55 additions & 11 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,61 @@ on:
- "v*.*.*"

jobs:
generate-changelog:
runs-on: ubuntu-latest

steps:
- name: Setup Python
uses: actions/[email protected]
with:
python-version: 3.12.6
- name: Setup Python environment
run: |
python -m venv .venv
source .venv/bin/activate
pip install requests
- name: Generate release-changelog
run: |
source .venv/bin/activate
python Scripts/generate_release.py "$(git log -1 --pretty=%B)" version_info.txt gamebanana_changelog.json github_changelog.md studio_changelog.md
env:
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ github.token }}

- name: Upload version information
uses: actions/upload-artifact@v4
with:
name: changelog-version
path: version_info.txt
- name: Upload GameBanana changelog
uses: actions/upload-artifact@v4
with:
name: changelog-gamebanana
path: gamebanana_changelog.json
- name: Upload GitHub changelog
uses: actions/upload-artifact@v4
with:
name: changelog-github
path: github_changelog.md
- name: Upload Studio changelog
uses: actions/upload-artifact@v4
with:
name: changelog-studio
path: studio_changelog.md


build-studio:
uses: ./.github/workflows/Build.CelesteStudio.yml
with:
build-cfg: Release
needs: generate-changelog

release:
runs-on: ubuntu-latest
needs: build-studio
needs:
- build-studio
- generate-changelog

steps:
- name: Checkout
Expand Down Expand Up @@ -61,20 +108,17 @@ jobs:
run: |
dotnet build CelesteTAS-EverestInterop -c Release -p:DefineConstants=INSTALL_STUDIO -p:UseSymlinks=false
- name: Download changelogs
uses: actions/download-artifact@v4
with:
pattern: changelog-*

- name: Setup Python environment
run: |
python -m venv .venv
source .venv/bin/activate
pip install requests selenium
- name: Generate release-changelog
run: |
source .venv/bin/activate
python Scripts/generate_release.py "$(git log -1 --pretty=%B)" version_info.txt gamebanana_changelog.json github_changelog.md
env:
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ github.token }}

- name: Prepare releases
run: |
# Version GameBanana .zip without v prefix
Expand All @@ -89,7 +133,7 @@ jobs:
- name: Upload GameBanana release
run: |
source .venv/bin/activate
python Scripts/gamebanana_upload.py ${{ env.RELEASE_FILE }} gamebanana_changelog.json version_info.txt
python Scripts/gamebanana_upload.py ${{ env.RELEASE_FILE }} changelog-gamebanana/gamebanana_changelog.json changelog-version/version_info.txt
env:
GAMEBANANA_USERNAME: AutomaticRelease
GAMEBANANA_PASSWORD: ${{ secrets.GAMEBANANA_PASSWORD }}
Expand All @@ -101,7 +145,7 @@ jobs:
uses: softprops/action-gh-release@v1
with:
name: ${{ env.RELEASE_TITLE }}
body_path: github_changelog.md
body_path: changelog-github/github_changelog.md
files: |
CelesteTAS.zip
CelesteStudio-windows-x64.zip
Expand Down
5 changes: 5 additions & 0 deletions Scripts/generate_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def main():
version_info_file = sys.argv[2]
gb_changelog_file = sys.argv[3]
gh_changelog_file = sys.argv[4]
studio_changelog_file = sys.argv[5]

# Find CelesteTAS / Studio version
celestetas_version = re.search(r"CelesteTAS\s+(v[\d.]+)", commit_message).group(1)
Expand Down Expand Up @@ -136,6 +137,10 @@ def main():
break # No more pages left
break

# Only include release notes (and not commit details) in Studio changelog
with open(studio_changelog_file, "w") as f:
f.write("\n".join(gh_markdown))

# Generate commit details
gh_markdown.append("<details>")
gh_markdown.append("<summary><h3>Commit Details</h3></summary>")
Expand Down

0 comments on commit 56e4927

Please sign in to comment.