-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow to verify the changelog snippets (#6139)
- Loading branch information
Showing
5 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,49 @@ | ||
name: Create changelog | ||
|
||
on: | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- "changelog/snippets/*.md" | ||
push: | ||
|
||
branches: | ||
- deploy/fafdevelop | ||
|
||
jobs: | ||
verify: | ||
name: Verify | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: | | ||
changelog/snippets | ||
- name: Verify the changelog snippets | ||
working-directory: changelog/snippets # script assumes it is in this directory | ||
run: | | ||
./verify.sh | ||
bundle: | ||
name: Bundle | ||
runs-on: ubuntu-latest | ||
needs: [verify] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: | | ||
changelog/snippets | ||
- name: Create the changelog | ||
working-directory: changelog/snippets # script assumes it is in this directory | ||
working-directory: changelog/snippets # script assumes it is in this directory | ||
run: | | ||
./combine.sh | ||
- name: Add the changelog as an artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: changelog | ||
path: | | ||
changelog/snippets/changelog.md | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- (#6139, 6138, 6137) Generate the changelog based on changelog snippets | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/bash | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Copyright (c) 2024 FAForever | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
# ----------------------------------------------------------------------------- | ||
|
||
# ----------------------------------------------------------------------------- | ||
#region Verify that the script has everything it needs. | ||
|
||
# The primary check is whether we launched the script from the correct | ||
# directory. The active directory should always be '(...)/fa/changelog/snippets' | ||
|
||
if ! ls *.md >/dev/null 2>&1; then | ||
echo "No Markdown files found to verify. Are you looking in the wrong directory?" | ||
exit 1 | ||
fi | ||
|
||
#endregion | ||
|
||
# ----------------------------------------------------------------------------- | ||
#region Verify the snippets whether they match the convention | ||
|
||
# Function to process snippets file names | ||
is_valid_filename() { | ||
local filename="$1" | ||
|
||
# Pattern to match: starts with 'fix', 'graphics', etc., | ||
# followed by a dot, then 1 to 5 digits, and ends with '.md' | ||
if [[ "$filename" =~ ^(fix|graphics|performance|ai|features|other|performance|balance)\.[0-9]{1,5}\.md$ ]]; then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
|
||
for file in *.md; do | ||
if is_valid_filename "$file"; then | ||
echo " - Verified: $file" | ||
else | ||
echo "Invalid format: $file" | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "All snippets are formatted correctly." | ||
|
||
#endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters