Skip to content

Commit b823d9c

Browse files
committed
Automate lua release preparation
1 parent 2a8b6ff commit b823d9c

File tree

4 files changed

+130
-20
lines changed

4 files changed

+130
-20
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Permission is hereby granted, free of charge, to any person obtaining a copy
2+
# of this software and associated documentation files (the "Software"), to deal
3+
# in the Software without restriction, including without limitation the rights
4+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5+
# copies of the Software, and to permit persons to whom the Software is
6+
# furnished to do so, subject to the following conditions:
7+
#
8+
# The above copyright notice and this permission notice shall be included in all
9+
# copies or substantial portions of the Software.
10+
#
11+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17+
# SOFTWARE.
18+
19+
name: Prepare release
20+
21+
on:
22+
workflow_dispatch:
23+
push:
24+
25+
jobs:
26+
27+
changelog-develop:
28+
name: Create changelog of FAF Develop
29+
uses: ./.github/workflows/docs-generate-changelog.yaml
30+
with:
31+
reference: develop
32+
33+
34+
release-preparation:
35+
name: Prepare files for patch
36+
runs-on: ubuntu-latest
37+
needs: verify
38+
steps:
39+
40+
- name: Checkout FA repository
41+
uses: actions/checkout@v6
42+
with:
43+
ssh-key: ${{ secrets.SSH_FAFOREVER_MACHINE_USER }}
44+
repository: FAForever/fa
45+
ref: release-automation
46+
47+
- name: Determine next patch version
48+
id: version
49+
run: |
50+
CURRENT_VERSION=$(grep 'Version' lua/version.lua | grep -o '[0-9]\+')
51+
NEXT_VERSION=$((CURRENT_VERSION + 1))
52+
echo "old_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
53+
echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT
54+
55+
- name: Create branch
56+
run: |
57+
BRANCH="changelog${{ steps.version.outputs.version }}"
58+
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
59+
if git ls-remote --heads origin "${{ steps.meta.outputs.branch }}" | grep -q .; then
60+
echo "Branch '${{ steps.meta.outputs.branch }}' already exists. Aborting workflow."
61+
exit 1
62+
fi
63+
git checkout -b "${{ steps.meta.outputs.branch }}"
64+
65+
- name: Create changelog post
66+
working-directory: changelog/snippets
67+
run: |
68+
DATE=$(date +%Y-%m-%d)
69+
FILE="${{ github.workspace }}/docs/_posts/$DATE-${{ steps.version.outputs.version }}.md"
70+
${{ github.workspace }}/.github/workflows/scripts/bash/changelog-combine.sh $FILE
71+
sed -i "s/XYZW/${{ steps.version.outputs.version }}/g" $FILE
72+
73+
- name: Update changelogData.lua
74+
run: |
75+
sed -i -E "s/(last_version = )[0-9]+/\1${{ steps.version.outputs.version }}/" \
76+
lua/ui/lobby/changelogData.lua
77+
78+
- name: Commit changelog
79+
run: |
80+
git config user.name github-actions
81+
git config user.email actions@github.com
82+
83+
git add lua/ui/lobby/changelogData.lua docs/_posts
84+
git commit -m "Add changelog for version ${{ steps.version.outputs.version }}"
85+
86+
- name: Remove snippets
87+
run: |
88+
rm -f changelog/snippets/*.md
89+
git add changelog/snippets
90+
git commit -m "Delete changelog snippets"
91+
92+
- name: Update version number
93+
run: |
94+
sed -i "s/${{ steps.version.outputs.old_version }}/${{ steps.version.outputs.version }}/g" lua/version.lua
95+
sed -i "s/${{ steps.version.outputs.old_version }}/${{ steps.version.outputs.version }}/g" mod_info.lua
96+
97+
git add lua/version.lua mod_info.lua
98+
git commit -m "Bump game version to ${{ steps.version.outputs.version }}"
99+
100+
- name: Push branch
101+
run: |
102+
git push origin "${{ steps.meta.outputs.branch }}"
103+
104+
- name: Create Pull Request
105+
uses: actions/github-script@v7
106+
with:
107+
script: |
108+
const version = "${{ steps.version.outputs.version }}";
109+
const branch = "${{ steps.meta.outputs.branch }}";
110+
111+
await github.rest.pulls.create({
112+
owner: context.repo.owner,
113+
repo: context.repo.repo,
114+
title: `Changelog ${version}`,
115+
head: branch,
116+
base: "develop",
117+
body: `Automated changelog and version bump for game version ${version}.`
118+
});

.github/workflows/scripts/bash/changelog-combine.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ process_snippets() {
120120
# Output file name
121121
output="changelog.md"
122122
if [ "$1" ]; then
123-
output="$1.md"
123+
output="$1"
124124
fi
125125

126126
echo "Writing output to: $output"
Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
11
## Contributors
22

3-
With thanks to the following people who contributed through coding:
4-
5-
<!-- Remove when empty -->
6-
7-
With thanks to the following people who contributed through binary patches:
8-
9-
<!-- Remove when empty -->
10-
11-
With thanks to the following individuals who contributed through model, texture, and effect changes:
12-
13-
<!-- Remove when empty -->
14-
15-
And, last but certainly not least - with thanks to those that took part in constructive discussions:
16-
17-
<!-- Remove when empty -->
3+
With thanks to the following contributors:
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
# Game version XYZW (1st of Month, Year)
1+
---
2+
layout: post
3+
title: XYZW - Game Patch
4+
permalink: changelog/XYZW
5+
---
26

3-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Viverra suspendisse potenti nullam ac. Gravida dictum fusce ut placerat orci nulla. Amet mauris commodo quis imperdiet massa tincidunt nunc pulvinar. Eget nullam non nisi est sit amet. Ipsum dolor sit amet consectetur adipiscing elit pellentesque habitant. Netus et malesuada fames ac turpis egestas maecenas. Enim tortor at auctor urna nunc id cursus. Turpis egestas sed tempus urna et. Pellentesque id nibh tortor id aliquet lectus proin nibh. Amet mattis vulputate enim nulla. Eu turpis egestas pretium aenean pharetra. Facilisi cras fermentum odio eu feugiat pretium nibh ipsum consequat. Facilisi nullam vehicula ipsum a arcu cursus vitae congue.
7+
# Game version XYZW (Month Day, Year)
48

5-
With kind regards,
9+
Your introduction here
610

7-
ABC
11+
With gratitude to all those who contributed to this patch and/or took the time to report issues,
12+
13+
BlackYps
814

0 commit comments

Comments
 (0)