⬆️ Update frenck/action-addon-linter action to v2.17.1 #151
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
--- | |
name: Automatically bump version on wikijs updates and changelog | |
permissions: | |
contents: write | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
version: | |
runs-on: ubuntu-latest | |
if: ${{ contains(github.event.head_commit.message, 'Update dependency requarks/wiki') }} # Detect that the wikijs version has been updated | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
lfs: "true" | |
fetch-depth: 0 | |
- name: "Retrieve version & increment it" | |
id: version | |
run: | | |
configFiles=$(find wiki.js -name 'config.yaml' -print0 | xargs -r0 echo) | |
for configfile in $configFiles; do | |
OLD_VERSION=$(cat $configfile | grep 'version: ' | head -1 | sed s/"version: "//) | |
NEW_VERSION=$(echo $OLD_VERSION | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}') | |
sed -i "s/$OLD_VERSION/$NEW_VERSION/g" $configfile | |
echo "Incremented addon $configfile from version $OLD_VERSION to $NEW_VERSION" | |
done | |
- name: "Update Changelog" | |
id: changelog | |
run: | | |
repo_url="https://api.github.com/repos/requarks/wiki" | |
response=$(curl -s "$repo_url/releases") | |
latest_version=$(echo "$response" | grep -oP '"tag_name": "\K[^"]+' | sed -n '1p') | |
find wiki.js -name "CHANGELOG.md" -exec grep -l "# Changelog" {} \; | while read -r file; do | |
current_version=$(grep -oP "^## \K\d+\.\d+\.\d+" "$file" | sort -rV | head -n1) | |
if [ -n "$current_version" ]; then | |
IFS='.' read -r major minor patch <<< "$current_version" | |
((patch++)) | |
new_version="$major.$minor.$patch" | |
echo "Generated new version $new_version" | |
if sed -i "/# Changelog/a \\## $new_version\\n- automatically update wikijs to version $latest_version\n" "$file" ; then | |
echo "Added changelog auto text for $file with new version $new_version and wikijs version $latest_version" | |
else | |
echo "Error while writing changelog auto text for $file with new version $new_version and wikijs version $latest_version" | |
fi | |
else | |
echo "No valid version found in $file" | |
fi | |
done | |
- name: Commit & Push | |
uses: actions-js/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: master | |
force: true | |
message: "Increment addon version due to wikijs update" |