Skip to content

Commit

Permalink
Automate creation of the changelog (FAForever#6138)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas authored Apr 28, 2024
1 parent c39d041 commit 6544985
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 243 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
name: Changelog
name: Create changelog

on:
workflow_dispatch:
push:

jobs:
create:
name: Bundle changelog
bundle:
name: Bundle
runs-on: ubuntu-latest
steps:
- name: Install tooling
run: apk add bash git findutils

- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: "*.md"
sparse-checkout: |
changelog/snippets
- name: Create the changelog
working-directory: ./changelog/snippets
working-directory: changelog/snippets # script assumes it is in this directory
run: |
"bash ./combine.sh"
./combine.sh
- name: Add the changelog as an artifact
uses: actions/upload-artifact@v4
with:
name: changelog
path: |
changelog.md
changelog/snippets/changelog.md
146 changes: 0 additions & 146 deletions changelog/snippets/changelog.md

This file was deleted.

125 changes: 40 additions & 85 deletions changelog/snippets/combine.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if ! [ -e "$templateHeader" ]; then
fi

templateFooter="sections/template-footer.md"
if ! [ -e "$templateHeader" ]; then
if ! [ -e "$templateFooter" ]; then
echo "No markdown template for the footer found. Are you starting the script from the wrong directory?"
exit 1
fi
Expand Down Expand Up @@ -70,6 +70,12 @@ if ! [ -e "$templateAI" ]; then
exit 1
fi

templatePerformance="sections/template-performance.md"
if ! [ -e "$templatePerformance" ]; then
echo "No markdown template for performance found. Are you starting the script from the wrong directory?"
exit 1
fi

templateOther="sections/template-other.md"
if ! [ -e "$templateOther" ]; then
echo "No markdown template for other changes found. Are you starting the script from the wrong directory?"
Expand All @@ -86,98 +92,47 @@ fi
# -----------------------------------------------------------------------------
#region Combine the changelog snippets into one large changelog

# Function to process snippets
process_snippets() {
local snippet_type="$1"
local template_file="$2"
local output_file="$3"

if ls "$snippet_type".*.md >/dev/null 2>&1; then
echo "Processing $snippet_type snippets"
cat "$template_file" >> "$output_file"
echo "" >> "$output_file"

for file in "$snippet_type".*.md; do
echo " - Processing: $file"
cat "$file" >> "$output_file"
echo "" >> "$output_file"
done

echo ""
echo "" >> "$output_file"
else
echo "No $snippet_type snippets found."
echo ""
fi
}

# Output file name
output="changelog.md"
rm -f "$output"

# Add the initial header
cat "$templateHeader" >>"$output"

# Add bug fixes
if ls fix.*.md >/dev/null 2>&1; then

cat "$templateFix" >>"$output"
echo "" >>"$output"

for file in fix.*.md; do
cat "$file" >>"$output"
echo "" >>"$output"
done

echo "" >>"$output"
fi

# Add balance changes
if ls balance.*.md >/dev/null 2>&1; then

cat "$templateBalance" >>"$output"
echo "" >>"$output"

for file in balance.*.md; do
cat "$file" >>"$output"
echo "" >>"$output"
done

echo "" >>"$output"
fi
process_snippets "fix" "$templateFix" "$output"
process_snippets "balance" "$templateBalance" "$output"
process_snippets "features" "$templateFeatures" "$output"
process_snippets "graphics" "$templateGraphics" "$output"
process_snippets "ai" "$templateAI" "$output"
process_snippets "performance" "$templatePerformance" "$output"
process_snippets "other" "$templateOther" "$output"

# Add features
if ls features.*.md >/dev/null 2>&1; then

cat "$templateFeatures" >>"$output"
echo "" >>"$output"

for file in features.*.md; do
cat "$file" >>"$output"
echo "" >>"$output"
done

echo "" >>"$output"
fi

# Add graphics changes
if ls graphics.*.md >/dev/null 2>&1; then

cat "$templateGraphics" >>"$output"
echo "" >>"$output"

for file in graphics.*.md; do
cat "$file" >>"$output"
echo "" >>"$output"
done

echo "" >>"$output"
fi

# Add AI changes
if ls ai.*.md >/dev/null 2>&1; then

cat "$templateAI" >>"$output"
echo "" >>"$output"

for file in ai.*.md; do
cat "$file" >>"$output"
echo "" >>"$output"
done

echo "" >>"$output"
fi

# Add other changes
if ls other.*.md >/dev/null 2>&1; then

cat "$templateOther" >>"$output"
echo "" >>"$output"

for file in other.*.md; do
cat "$file" >>"$output"
echo "" >>"$output"
done

echo "" >>"$output"
fi

# Add the initial header
# Add the final footer
cat "$templateFooter" >>"$output"

#endregion
2 changes: 0 additions & 2 deletions changelog/snippets/features.6079.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
## Features

- (#6079) Make various structures easier to place to help with base building.
- All Tech 3 Power Generators, Tech 3 Mass Fabricators, Tech 3 Artilleries, Shield Structures, Land Factories and Air Factories:
- MaxGroundVariation: 1.0 --> 1.1
Expand Down

0 comments on commit 6544985

Please sign in to comment.