Skip to content

enable usage of own GitHub images #367 #232

enable usage of own GitHub images #367

enable usage of own GitHub images #367 #232

name: Automatically bump version on netbootxyz 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 netbootxyz/webapp') }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
lfs: "true"
fetch-depth: 0
- name: "Retrieve version & increment it"
id: version
run: |
set -e
echo "Starting version increment process..."
configFiles=$(find netboot-xyz -name 'config.yaml' -print0 | xargs -r0 echo)
if [[ -z "$configFiles" ]]; then
echo "❌ Error: No config.yaml files found!"
exit 1
fi
echo "Found config files: $configFiles"
for configfile in $configFiles; do
echo "--------------------------------------------"
echo "Processing: $configfile"
if [ ! -f "$configfile" ]; then
echo "❌ Error: $configfile not found!"
exit 1
fi
if [ ! -r "$configfile" ]; then
echo "❌ Error: $configfile is not readable! Trying to fix permissions..."
chmod +r "$configfile" || { echo "❌ Failed to fix permissions!"; exit 1; }
fi
OLD_VERSION=$(grep -E '^[[:space:]]*version:[[:space:]]+[0-9]+\.[0-9]+\.[0-9]+' "$configfile" | head -1 | awk '{print $2}')
if [[ -z "$OLD_VERSION" ]]; then
echo "❌ Error: Could not extract a valid version from $configfile"
cat "$configfile"
exit 1
fi
echo "Extracted OLD_VERSION: '$OLD_VERSION'"
IFS='.' read -r major minor patch <<< "$OLD_VERSION"
if [[ -z "$major" || -z "$minor" || -z "$patch" ]]; then
echo "❌ Error: Failed to parse version components from '$OLD_VERSION'."
exit 1
fi
((patch++))
NEW_VERSION="$major.$minor.$patch"
echo "Updating $configfile from version $OLD_VERSION to $NEW_VERSION"
sed -i "s/^version: $OLD_VERSION/version: $NEW_VERSION/" "$configfile" || {
echo "❌ Error: Failed to update version in $configfile"
exit 1
}
echo "✅ Successfully updated $configfile to version $NEW_VERSION"
done
echo "🎉 Version increment process completed successfully!"
- name: "Update Changelog"
id: changelog
run: |
set -e
echo "🔄 Starting changelog version increment process..."
repo_url="https://api.github.com/repos/netbootxyz/webapp"
response=$(curl -s "$repo_url/releases")
latest_version=$(echo "$response" | grep -oP '"tag_name": "\K[^"]+' | sed -n '1p')
echo "✅ Latest version from repo: $latest_version"
files=$(find netboot-xyz -name "CHANGELOG.md" -exec grep -l "# Changelog" {} \;)
if [[ -z "$files" ]]; then
echo "❌ Error: No CHANGELOG.md files found!"
exit 1
fi
echo "Found changelog files: $files"
while IFS= read -r file; do
echo "Processing: $file"
current_version=$(grep -oP "^## \K\d+\.\d+\.\d+" "$file" | sort -rV | head -n1)
if [[ -z "$current_version" ]]; then
echo "⚠️ No valid version found in $file"
continue
fi
echo "Found current version: $current_version"
IFS='.' read -r major minor patch <<< "$current_version"
((patch++))
new_version="$major.$minor.$patch"
if ! sed -i "/# Changelog/a \\## $new_version\\n- Automatically updated netboot-xyz to version $latest_version\\n" "$file"; then
echo "❌ Error while writing changelog entry to $file"
exit 1
fi
echo "✅ Successfully updated $file with version $new_version"
done <<< "$files"
echo "🎉 Changelog update process completed successfully!"
- name: Commit & Push
uses: actions-js/push@v1.5
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
force: true
message: "Increment addon version due to netboot-xyz update"