generated from P3TERX/Actions-OpenWrt
-
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (125 loc) · 5.59 KB
/
immortalwrt-checker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# 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