Skip to content

Commit

Permalink
Add github action to auto-update brave-version.txt (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
vnznznz committed Mar 19, 2024
1 parent cbc6e17 commit 88bc184
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/brave-update-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Update brave-version.txt

on:
schedule:
- cron: "17 * * * *"

jobs:
build:
runs-on: ubuntu-latest
# only run manually or on schedule, but only for the main repo
if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository == 'webrecorder/browsertrix-browser-base')

steps:
- uses: actions/checkout@v4
- name: Run update script
run: ./update-brave.sh
shell: bash

34 changes: 34 additions & 0 deletions update-brave.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
set -e

current_version=$(cat brave-version.txt)
latest_version=$(\
curl -s https://api.github.com/repos/brave/brave-browser/releases/latest \
| jq '.tag_name' \
| sed -e 's/^"v//' -e 's/\"//')

echo "current version: $current_version"
echo "latest version: $latest_version"

if [ "$current_version" == "$latest_version" ]; then
echo "brave-version.txt is already up to date"
exit 0
fi

latest_version_when_sorted=$(\
printf "${latest_version}\n${current_version}" \
| sort -V \
| tail -n 1)

if [ "$latest_version_when_sorted" != "$latest_version" ]; then
echo "current version is newer than latest version"
exit 1
fi

echo "updating brave-version.txt to $latest_version"

echo $latest_version > brave-version.txt

git add brave-version.txt
git commit --author "Github Actions Webrecorder <info@webrecorder.net>" -m "version: brave version to ${latest_version}"
git push

0 comments on commit 88bc184

Please sign in to comment.