Skip to content

⬆️ Update ghcr.io/hassio-addons/base-python Docker tag to v14.0.4 #153

⬆️ Update ghcr.io/hassio-addons/base-python Docker tag to v14.0.4

⬆️ Update ghcr.io/hassio-addons/base-python Docker tag to v14.0.4 #153

---
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"