Skip to content

Commit

Permalink
Add cron job to check for new Octez versions
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Feb 4, 2024
1 parent c6efbf9 commit 9fc4736
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Publish on Docker Hub

on:
push:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Build
name: Publish on GHCR

on:
push:
tags:
- '*'
- 'v*'

jobs:
build:
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/octez_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check Octez version

on:
schedule:
- cron: '0 0 * * *'
# REMOVE
push:
branches:
- aux/octez-version-checker

jobs:
octez_version:
name: Check the latest Octez release
runs-on: ubuntu-latest
steps:
- name: Install python-requests
run: sudo apt-get install python3-requests
- name: make octez_version
run: make octez_version
15 changes: 15 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Tag the current Octez release


on:
push:
branches:
- 'master'

jobs:
build:
name: Force push tag of the current Octez release
runs-on: ubuntu-latest
steps:
- name: make release
run: make release
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TAG=v19.0-1
TAG=`cat octez_version`


build:
Expand All @@ -9,3 +9,6 @@ run:

release:
git tag $(TAG) -f && git push origin $(TAG) --force

octez_version:
python3 octez_version.py
Empty file added octez_version
Empty file.
40 changes: 40 additions & 0 deletions octez_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from pathlib import Path
import requests
from os import environ as env
import subprocess

def run(*args, **kwargs):
print(f"$ {' '.join(args)}")
subprocess.run(args, check=True, **kwargs)


OCTEZ_REPO_URL = 'https://github.com/serokell/tezos-packaging/releases/latest'


def main():

version_file = Path('octez_version')
current_version = version_file.read_text().strip() if version_file.exists() else ''
print(f'Current version: {current_version}')
latest_version = requests.get(OCTEZ_REPO_URL).url.split("/")[-1]
print(f'Latest version: {latest_version}')

if current_version == latest_version:
return

if not env.get("GITHUB_ACTIONS"):
print("This script is intended to be run in a GitHub Action.")
exit(1)

print('Octez version has changed. Updating...')
Path('octez_version').write_text(latest_version)

run('make', 'build')
run('git', 'checkout', '-b', f'octez-{latest_version}')
run('git', 'add', 'octez_version')
run('git', 'commit', '-m', f'Update Octez binaries to {latest_version}')



if __name__ == "__main__":
main()

0 comments on commit 9fc4736

Please sign in to comment.