Skip to content
Open
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
21 changes: 15 additions & 6 deletions .github/tweak_changelogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

RELEASE_VERSION="$1"

# Delete until and including the first line containing "<!-- Release notes generated"
sed -i '1,/^<!-- Release notes generated/d' temp_change.md
if grep -q "<!-- Release notes generated" temp_change.md; then
# Delete up to and including the first line containing "<!-- Release notes generated"
sed -i '1,/^<!-- Release notes generated/d' temp_change.md
else
# Otherwise, delete up to and including the first line containing "--" (The release metadata)
sed -i '1,/--/d' temp_change.md
fi

# Check if there is more than one non-empty line (the full changelog line) before we continue
if [ $(grep -c '^[[:space:]]*[^[:space:]]' temp_change.md) -le 1 ]; then
Expand All @@ -19,12 +24,12 @@ sed -i 's/\r//g' temp_change.md CHANGELOG.md changelog.txt
sed -i '1h;1d;$!H;$!d;G' temp_change.md
# Convert "**Full Changelog**: URL" format to markdown link format "[Full Changelog](URL)"
sed -i -re 's/\*\*Full Changelog\*\*: (.*)/\[Full Changelog\]\(\1\)\n/' temp_change.md
# Delete everything from "## New Contributors" line to the end of file
# Delete everything from "## New Contributors" line to the end of the file
sed -i '/## New Contributors/,$d' temp_change.md
# Convert GitHub changelog entries to markdown format
# "* description by (@username1, @username2) in #1310, #1311" → "- description #1310, #1311 (@username1, @username2)"
sed -i -re 's/^\*\s(.*)\sby\s\(?(@[^)]*[^) ])\)?\s+in\s+(.*)/- \1 \3 (\2)/' temp_change.md
# Convert @usernames to github links
# Convert @usernames to GitHub links
# "(@username1, @username2)" → "([username1](https://github.com/username1), [username2](https://github.com/username2))"
sed -i -re 's/@([a-zA-Z0-9_-]+)/[\1](https:\/\/github.com\/\1)/g' temp_change.md
# Convert full PR URLs to linked format
Expand All @@ -43,13 +48,17 @@ cp temp_change.md changelog_temp.txt
cat CHANGELOG.md | sed '1d' >> temp_change.md
# Create new CHANGELOG.md with header containing version and date, followed by processed changes
printf "# Changelog\n\n## [$RELEASE_VERSION](https://github.com/PathOfBuildingCommunity/PathOfBuilding-PoE2/tree/$RELEASE_VERSION) ($(date +'%Y/%m/%d'))\n\n" | cat - temp_change.md > CHANGELOG.md

# Delete up to and including the line containing "## What's Changed"
sed -i "1,/## What's Changed/d" changelog_temp.txt

# Convert changelog entries from markdown link format to simplified "* description (username)" format
# First remove all PR links
sed -i -re 's/( \()?\[\\#[0-9]+\]\([^)]*\),? ?\)?//g' changelog_temp.txt
# Remove markdown link formatting from usernames in parentheses
sed -i -re 's/\[([^]]*)\]\(https:\/\/github\.com\/[^)]*\)/\1/g' changelog_temp.txt
# Create new changelog format: add version header, remove lines 2-3, format section headers, remove ## headers with following line, prepend to existing changelog
echo "VERSION[${RELEASE_VERSION#v}][$(date +'%Y/%m/%d')]" | cat - changelog_temp.txt | sed '2,3d' | sed -re 's/^### (.*)/\n--- \1 ---/' | sed -e '/^##.*/,+1 d' | cat - changelog.txt > changelog_new.txt
# Create new changelog format: add version header, format section headers, prepend to existing changelog
echo "VERSION[${RELEASE_VERSION#v}][$(date +'%Y/%m/%d')]" | cat - changelog_temp.txt | sed -re 's/^### (.*)/\n--- \1 ---/' | cat - changelog.txt > changelog_new.txt
mv changelog_new.txt changelog.txt

# Normalize line endings to CRLF for all output files to ensure consistent checksums with Windows
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/release-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# These checks are run for PRs preparing a release
name: Release Check
on:
pull_request:
types:
- opened
- synchronize
# ready_for_review is needed for the workaround described at https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#workarounds-to-trigger-further-workflow-runs
- ready_for_review
branches:
- 'dev'
paths:
- 'manifest.xml'
- 'changelog.txt' # To detect if this is a release PR
workflow_dispatch:
jobs:
check_manifest:
runs-on: ubuntu-latest
steps:
- name: Set line endings
run: git config --global core.autocrlf true
- name: Checkout
uses: actions/checkout@v4
- name: Update manifest
run: python3 update_manifest.py --quiet --in-place
- name: Check if the generated manifest is different
run: git diff --exit-code manifest.xml
- name: Check if the manifest version is correct
if: startsWith(github.head_ref, 'release-')
run: |
MANIFEST_VERSION=$(grep -o '<Version number="[^"]*' manifest.xml | sed 's/<Version number="//')
BRANCH_VERSION=$(echo ${{ github.head_ref }} | sed 's/release-//')
if [ "$MANIFEST_VERSION" != "$BRANCH_VERSION" ]; then
echo "Manifest version ($MANIFEST_VERSION) does not match branch version ($BRANCH_VERSION)"
exit 1
fi
20 changes: 16 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,42 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Set line endings
run: git config --global core.autocrlf true
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
with:
ref: 'dev'
- name: Generate Release notes
if: ${{ github.event.inputs.releaseNoteUrl == '' }}
run: >
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token;
gh release view $(basename $(gh release create v${{ github.event.inputs.releaseVersion }} --title "Release ${{ github.event.inputs.releaseVersion }}" --draft --generate-notes)) > temp_change.md
gh release view $(basename $(gh release create --target dev v${{ github.event.inputs.releaseVersion }} --title "Release ${{ github.event.inputs.releaseVersion }}" --draft --generate-notes)) > temp_change.md
- name: Use existing Release notes
if: ${{ github.event.inputs.releaseNoteUrl != '' }}
run: >
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token;
gh release view $(basename ${{ github.event.inputs.releaseNoteUrl }}) > temp_change.md
# The initial draft release must target dev for the changelog generation, but the final release should use the last commit on master to avoid tagging a wrong commit
- name: Change release target to master
run: |
gh release edit v${{ github.event.inputs.releaseVersion }} --target master
- name: Tweak changelogs
run: |
# Remove carriage returns to be able to run the script
sed -i 's/\r$//' .github/tweak_changelogs.sh
chmod +x .github/tweak_changelogs.sh
.github/tweak_changelogs.sh "v${{ github.event.inputs.releaseVersion }}"
- name: Update manifest version
run: |
sed -ri "s/<Version number=\"([^\"]*)\"/<Version number=\"${{ github.event.inputs.releaseVersion }}\"/g" manifest.xml
Comment on lines +43 to +45
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this step you can run python3 update_manifest.py --quiet --in-place --set-version ${{ github.event.inputs.releaseVersion }}

- name: Update manifest.xml
run: python3 update_manifest.py --quiet --in-place
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v7
with:
draft: true
# draft: always-true is needed for the workaround described at https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#workarounds-to-trigger-further-workflow-runs
draft: always-true
title: Release ${{ github.event.inputs.releaseVersion }}
branch: release-${{ github.event.inputs.releaseVersion }}
body: |
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/sync-release-to-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Sync Release to Master

on:
pull_request:
types: [closed]
branches:
- dev

jobs:
sync-release-to-master:
# Checks that the push to dev was from a pull request whose head branch started with 'release-'.
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release-')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0

- name: Configure bot user
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- name: Merge fast-forward dev into master
run: |
git merge ${{ github.sha }} --ff-only
git push
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
branches: [ dev ]
pull_request:
branches: [ dev ]
types:
- opened
- synchronize
- ready_for_review
workflow_dispatch:
jobs:
run_tests:
Expand Down