Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github action to auto-update brave-version.txt #17

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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