Skip to content

Commit c2cc1bb

Browse files
committed
Add automatic version updates
1 parent f88e997 commit c2cc1bb

9 files changed

Lines changed: 82 additions & 0 deletions

File tree

.github/workflows/update_apps.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Update apps
2+
3+
on:
4+
schedule:
5+
- cron: '40 13 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Run update checker
17+
run: |
18+
bash tools/updates.sh
19+
20+
- name: Commit changes
21+
run: |
22+
current_date=$(date +'%d/%m/%Y, %H:%M')
23+
git config --global user.email "actions@github.com"
24+
git config --global user.name "GitHub Actions"
25+
git add -A
26+
git commit -m "Update $(cat updates_list.txt)"
27+
28+
- name: Push changes
29+
run: |
30+
git push https://${{ secrets.GH_TOKEN }}@github.com/techguy16/LinStore.git
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
curl -s https://api.github.com/repos/betterscratch/desktop/releases/latest | grep browser_download_url |\
3+
grep deb | awk -F"/" '{print $9}' | awk -F"-" '{print $4}' | sed 's/.deb"//'
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
curl -s "https://gitlab.com/api/v4/projects/44042130/releases" | tr '{},[]' '\n' | grep -x '"direct_asset_url":.*linux-arm64-package.tar.xz"' -m1 | sed 's+.*/packages/generic/librewolf/++g ; s+/.*++g'
3+
4+
# From Pi-Apps
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
git ls-remote https://github.com/techguy16/LinuxPatcher | awk '{print $1}' | head -n1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
curl -s https://api.github.com/repos/modrinth/code/releases/latest | grep "\"name\"" | awk '{print $2}' | sed 's/\"v//' | sed 's/"\,//'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
curl -s https://api.github.com/repos/prismlauncher/PrismLauncher/releases/latest | grep ".AppImage\"" | grep "browser_download_url" | awk '{print $2}' | awk -F"/" '{print $8}'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
curl -s https://repo.protonvpn.com/debian/dists/stable/main/binary-all/ | grep protonvpn-stable-release_ | tail -n1 | awk -F'>' '{print $2}' | awk -F'_' '{print $2}'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
curl -s https://api.github.com/repos/microsoft/vscode/releases/latest | grep tag_name | awk '{print $2}' | sed 's/\"//g' | sed "s/,//"

tools/updates.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
APPS_DIR="apps"
4+
WORKFLOWS_DIR=".github/workflows/updates"
5+
rm -r updates_list.txt
6+
7+
for dir in "$APPS_DIR"/*/; do
8+
folder_name=$(basename "$dir")
9+
for install_file in "$dir"/install*; do
10+
[[ -f "$install_file" ]] || continue
11+
old_version=$(grep -E '^VERSION=' "$install_file" | cut -d'=' -f2 | sed 's/"//g')
12+
if [[ ! -z "$old_version" ]]; then
13+
workflow_script="$WORKFLOWS_DIR/$folder_name.sh"
14+
workflow_script=$(echo "$workflow_script" | tr ' ' '\ ')
15+
16+
if [ -e "$workflow_script" ]; then
17+
new_version=$(bash "$workflow_script" 2>/dev/null || echo "$old_version")
18+
else
19+
new_version="$old_version"
20+
fi
21+
22+
if [[ "$new_version" == "$old_version" ]]; then
23+
./api info "No update required for $folder_name"
24+
else
25+
./api info "$folder_name - $(basename "$install_file"): old version=$old_version, new version=$new_version"
26+
if [ ! -e updates_list.txt ]; then
27+
echo -n "$folder_name" >> updates_list.txt
28+
elif ! grep "$folder_name" updates_list.txt &>/dev/null; then
29+
echo -n ", $folder_name" >> updates_list.txt
30+
fi
31+
sed -i "s/VERSION=${old_version}/VERSION=${new_version}/" "$install_file"
32+
sed -i "s/VERSION=\"$old_version\"/VERSION=\"$new_version\"/" "$install_file"
33+
fi
34+
fi
35+
done
36+
done

0 commit comments

Comments
 (0)