This commit is contained in:
2026-04-13 16:15:46 +01:00
commit 3187bb5502
14 changed files with 521 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail
: "${FILE:?FILE is required}"
: "${COMMIT_MESSAGE:?COMMIT_MESSAGE is required}"
git config user.name "gitea actions"
git config user.email "actions@localhost"
# schedule runs can checkout a detached HEAD, so create a throwaway branch
branch="automation/update-$(date +%s)"
git switch -C "$branch"
git add "$FILE"
if git diff --cached --quiet; then
echo "No staged changes for ${FILE}; skipping commit"
exit 0
fi
git commit -m "$COMMIT_MESSAGE"
for attempt in 1 2 3 4 5; do
if git push origin HEAD:main; then
echo "Pushed to main"
exit 0
fi
echo "Push failed (attempt ${attempt}); rebasing on origin/main and retrying"
git fetch origin main
git rebase origin/main
sleep 2
done
echo "Failed to push update after retries"
exit 1
+72
View File
@@ -0,0 +1,72 @@
#!/usr/bin/env bash
set -euo pipefail
: "${FILE:?FILE is required}"
: "${LATEST_RELEASE_URL:?LATEST_RELEASE_URL is required}"
: "${DOWNLOAD_URL_TEMPLATE:?DOWNLOAD_URL_TEMPLATE is required}"
if command -v python >/dev/null 2>&1; then
PYTHON_BIN=python
elif command -v python3 >/dev/null 2>&1; then
PYTHON_BIN=python3
else
echo "python is required but was not found"
exit 1
fi
version_strip_prefix="${LATEST_VERSION_STRIP_PREFIX:-v}"
release_tag_template="${RELEASE_TAG_TEMPLATE:-{version}}"
release_tag_template="${release_tag_template//$'\r'/}"
current_version=$($PYTHON_BIN - <<'PY'
import re
import os
p=os.environ["FILE"]
s=open(p).read()
m=re.search(r'version\s*=\s*"([^"]+)";', s)
print(m.group(1) if m else "")
PY
)
latest_version=$(curl -fsSLI -o /dev/null -w '%{url_effective}' "$LATEST_RELEASE_URL" \
| sed -E 's#.*/##')
if [ -n "$version_strip_prefix" ]; then
latest_version="${latest_version#${version_strip_prefix}}"
fi
echo "current=$current_version"
echo "latest=$latest_version"
if [ -z "$latest_version" ] || [ "$latest_version" = "$current_version" ]; then
echo "updated=false" >> "$GITHUB_OUTPUT"
exit 0
fi
download_url="${DOWNLOAD_URL_TEMPLATE//\{version\}/$latest_version}"
new_hash=$(nix store prefetch-file --json "$download_url" | "$PYTHON_BIN" -c 'import json,sys; print(json.load(sys.stdin)["hash"])')
export LATEST_VERSION="$latest_version"
export NEW_HASH="$new_hash"
"$PYTHON_BIN" - <<'PY'
import os
import re
p=os.environ["FILE"]
s=open(p).read()
s=re.sub(r'version\s*=\s*"[^"]+"', f'version = "{os.environ["LATEST_VERSION"]}"', s, count=1)
s=re.sub(r'hash\s*=\s*"[^"]+"', f'hash = "{os.environ["NEW_HASH"]}"', s, count=1)
open(p,"w").write(s)
PY
release_tag="${release_tag_template//\{version\}/$latest_version}"
release_tag="${release_tag#\{}"
release_tag="${release_tag%\}}"
release_tag="${release_tag#\'}"
release_tag="${release_tag%\'}"
release_url="${LATEST_RELEASE_URL%/latest}/tag/${release_tag}"
echo "updated=true" >> "$GITHUB_OUTPUT"
echo "version=$latest_version" >> "$GITHUB_OUTPUT"
echo "previous_version=$current_version" >> "$GITHUB_OUTPUT"
echo "release_url=$release_url" >> "$GITHUB_OUTPUT"
+44
View File
@@ -0,0 +1,44 @@
name: handy update
on:
schedule:
- cron: "10 3 * * *" # UTC
workflow_dispatch:
jobs:
update-handy:
runs-on: ubuntu-latest
concurrency:
group: handy-update
cancel-in-progress: false
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: check latest handy release and update file
id: update
env:
FILE: modules/pkgs/handy.nix
LATEST_RELEASE_URL: https://github.com/cjpais/Handy/releases/latest
DOWNLOAD_URL_TEMPLATE: https://github.com/cjpais/Handy/releases/download/v{version}/Handy_{version}_amd64.AppImage
RELEASE_TAG_TEMPLATE: v{version}
shell: bash
run: bash .gitea/scripts/update-appimage-nix.sh
- name: commit and push to main
if: steps.update.outputs.updated == 'true'
shell: bash
run: |
set -euo pipefail
version="${{ steps.update.outputs.version }}"
FILE="modules/pkgs/handy.nix" \
COMMIT_MESSAGE="update handy to ${version}" \
bash .gitea/scripts/commit-update-main.sh
+44
View File
@@ -0,0 +1,44 @@
name: helium update
on:
schedule:
- cron: "0 3 * * *" # UTC
workflow_dispatch:
jobs:
update-helium:
runs-on: ubuntu-latest
concurrency:
group: helium-update
cancel-in-progress: false
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: check latest helium release and update file
id: update
env:
FILE: modules/pkgs/helium.nix
LATEST_RELEASE_URL: https://github.com/imputnet/helium-linux/releases/latest
DOWNLOAD_URL_TEMPLATE: https://github.com/imputnet/helium-linux/releases/download/{version}/helium-{version}-x86_64.AppImage
RELEASE_TAG_TEMPLATE: '{version}'
shell: bash
run: bash .gitea/scripts/update-appimage-nix.sh
- name: commit and push to main
if: steps.update.outputs.updated == 'true'
shell: bash
run: |
set -euo pipefail
version="${{ steps.update.outputs.version }}"
FILE="modules/pkgs/helium.nix" \
COMMIT_MESSAGE="update helium to ${version}" \
bash .gitea/scripts/commit-update-main.sh
+44
View File
@@ -0,0 +1,44 @@
name: t3code update
on:
schedule:
- cron: "30 3 * * *" # UTC
workflow_dispatch:
jobs:
update-t3code:
runs-on: ubuntu-latest
concurrency:
group: t3code-update
cancel-in-progress: false
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: check latest t3code release and update file
id: update
env:
FILE: modules/pkgs/t3code.nix
LATEST_RELEASE_URL: https://github.com/pingdotgg/t3code/releases/latest
DOWNLOAD_URL_TEMPLATE: https://github.com/pingdotgg/t3code/releases/download/v{version}/T3-Code-{version}-x86_64.AppImage
RELEASE_TAG_TEMPLATE: v{version}
shell: bash
run: bash .gitea/scripts/update-appimage-nix.sh
- name: commit and push to main
if: steps.update.outputs.updated == 'true'
shell: bash
run: |
set -euo pipefail
version="${{ steps.update.outputs.version }}"
FILE="modules/pkgs/t3code.nix" \
COMMIT_MESSAGE="update t3code to ${version}" \
bash .gitea/scripts/commit-update-main.sh
+44
View File
@@ -0,0 +1,44 @@
name: zen browser update
on:
schedule:
- cron: "20 3 * * *" # UTC
workflow_dispatch:
jobs:
update-zen-browser:
runs-on: ubuntu-latest
concurrency:
group: zen-browser-update
cancel-in-progress: false
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: check latest zen browser release and update file
id: update
env:
FILE: modules/pkgs/zen-browser.nix
LATEST_RELEASE_URL: https://github.com/zen-browser/desktop/releases/latest
DOWNLOAD_URL_TEMPLATE: https://github.com/zen-browser/desktop/releases/download/{version}/zen-x86_64.AppImage
RELEASE_TAG_TEMPLATE: '{version}'
shell: bash
run: bash .gitea/scripts/update-appimage-nix.sh
- name: commit and push to main
if: steps.update.outputs.updated == 'true'
shell: bash
run: |
set -euo pipefail
version="${{ steps.update.outputs.version }}"
FILE="modules/pkgs/zen-browser.nix" \
COMMIT_MESSAGE="update zen browser to ${version}" \
bash .gitea/scripts/commit-update-main.sh