Bump ImmortalWRT Version #92
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
# File: .github/workflows/immortalwrt-checker.yml | |
# Description: Bump ImmortalWRT Version using GitHub Actions | |
# | |
# Copyright (c) 2024-2025 SuperKali <[email protected]> | |
# | |
# This is free software, licensed under the MIT License. | |
# See /LICENSE for more information. | |
name: Bump ImmortalWRT Version | |
on: | |
schedule: | |
- cron: '0 */23 * * *' | |
workflow_dispatch: | |
jobs: | |
check-and-bump: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq | |
- name: Get the latest ImmortalWRT version | |
id: get_latest_version | |
run: | | |
latest_version=$(curl -s https://api.github.com/repos/immortalwrt/immortalwrt/tags | jq -r '.[0].name' | sed 's/^v//') | |
if [ -z "$latest_version" ]; then | |
echo "Error: Failed to fetch the latest version." >&2 | |
exit 1 | |
fi | |
echo "latest_version=$latest_version" >> $GITHUB_ENV | |
echo "Latest version: $latest_version" | |
- name: Check files for REPO_BRANCH updates | |
id: check_repo_branch_files | |
run: | | |
if [ -z "${{ env.latest_version }}" ]; then | |
echo "Error: latest_version is not set." >&2 | |
exit 1 | |
fi | |
files_to_update=() | |
for file in .github/workflows/immortalwrt-*-nightly.yml; do | |
if [ -f "$file" ]; then | |
file_version=$(grep -m 1 'REPO_BRANCH:' "$file" | awk -F': ' '{if (NF > 1) {gsub(/^ +| +$/, "", $2); print $2}}') | |
if [ "$file_version" != "${{ env.latest_version }}" ]; then | |
echo "File $file needs update: $file_version -> ${{ env.latest_version }}" | |
files_to_update+=("$file") | |
else | |
echo "File $file is up-to-date." | |
fi | |
else | |
echo "Warning: File $file does not exist." | |
fi | |
done | |
if [ ${#files_to_update[@]} -eq 0 ]; then | |
echo "No REPO_BRANCH updates needed." | |
echo "repo_branch_needs_update=false" >> $GITHUB_ENV | |
else | |
echo "Files to update for REPO_BRANCH: ${files_to_update[@]}" | |
echo "repo_branch_needs_update=true" >> $GITHUB_ENV | |
echo "files_to_update=$(IFS=,; echo "${files_to_update[*]}")" >> $GITHUB_ENV | |
fi | |
- name: Update files with new REPO_BRANCH | |
if: env.repo_branch_needs_update == 'true' | |
run: | | |
IFS=',' read -r -a files <<< "${{ env.files_to_update }}" | |
for file in "${files[@]}"; do | |
sed -i "s/REPO_BRANCH: .*/REPO_BRANCH: ${{ env.latest_version }}/" "$file" | |
echo "Updated REPO_BRANCH in $file to ${{ env.latest_version }}." | |
done | |
- name: Check CONFIG_VERSION_REPO in .config | |
id: check_config_repo | |
run: | | |
latest_repo="https://downloads.immortalwrt.org/releases/${{ env.latest_version }}" | |
current_repo=$(grep -oP '^CONFIG_VERSION_REPO=\K.*' config/nightly/.config) | |
if [ "$current_repo" != "\"$latest_repo\"" ]; then | |
echo "CONFIG_VERSION_REPO in .config needs update: $current_repo -> $latest_repo" | |
echo "config_repo_needs_update=true" >> $GITHUB_ENV | |
else | |
echo "CONFIG_VERSION_REPO in .config is up-to-date." | |
echo "config_repo_needs_update=false" >> $GITHUB_ENV | |
fi | |
- name: Update CONFIG_VERSION_REPO in .config | |
if: env.config_repo_needs_update == 'true' | |
run: | | |
latest_repo="https://downloads.immortalwrt.org/releases/${{ env.latest_version }}" | |
sed -i 's|^CONFIG_VERSION_REPO=.*|CONFIG_VERSION_REPO="'"$latest_repo"'"|g' config/nightly/.config | |
echo "Updated CONFIG_VERSION_REPO in .config to $latest_repo." | |
- name: Check VERSION in scripts/update-script.sh | |
id: check_version_script | |
run: | | |
current_version=$(grep -oP '^VERSION=\K.*' scripts/update-script.sh) | |
if [ "$current_version" != "${{ env.latest_version }}" ]; then | |
echo "VERSION in scripts/update-script.sh needs update: $current_version -> ${{ env.latest_version }}" | |
echo "version_needs_update=true" >> $GITHUB_ENV | |
else | |
echo "VERSION in scripts/update-script.sh is up-to-date." | |
echo "version_needs_update=false" >> $GITHUB_ENV | |
fi | |
- name: Update VERSION in scripts/update-script.sh | |
if: env.version_needs_update == 'true' | |
run: | | |
sed -i "s/^VERSION=.*/VERSION=${{ env.latest_version }}/" scripts/update-script.sh | |
echo "Updated VERSION in scripts/update-script.sh to ${{ env.latest_version }}." | |
- name: Create a pull request | |
if: env.repo_branch_needs_update == 'true' || env.config_repo_needs_update == 'true' || env.version_needs_update == 'true' | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
branch: bump-immortalwrt-${{ env.latest_version }} | |
commit-message: 'Bump ImmortalWRT to version v${{ env.latest_version }}' | |
title: 'Bump ImmortalWRT to version v${{ env.latest_version }}' | |
body: | | |
This pull request updates the ImmortalWRT version to **v${{ env.latest_version }}**. | |
Changes included: | |
- Updated `REPO_BRANCH` in the following files: | |
${{ env.files_to_update }} | |
- Updated `CONFIG_VERSION_REPO` in `.config`. | |
- Updated `VERSION` in `scripts/update-script.sh`. | |
Labels: bump, immortalwrt, nightly, v${{ env.latest_version }} | |
labels: bump, immortalwrt, nightly, v${{ env.latest_version }} | |
- name: Delete workflow runs | |
uses: Mattraks/[email protected] | |
with: | |
retain_days: 0 | |
keep_minimum_runs: 3 |