diff --git a/.github/workflows/octez_version.yml b/.github/workflows/octez_version.yml index d7f51f1..a0c2eb3 100644 --- a/.github/workflows/octez_version.yml +++ b/.github/workflows/octez_version.yml @@ -17,5 +17,19 @@ jobs: uses: actions/checkout@v2 - name: Install python-requests run: sudo apt-get install python3-requests - - name: python3 octez_version.py - run: python3 octez_version.py \ No newline at end of file + + - name: Check the latest Octez release + run: python3 octez_version.py + + - name: Create a PR for new version + if: success() + run: | + export OCTEZ_VERSION=$(cat octez_version) + cd ../interface + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git checkout -b octez-$OCTEZ_VERSION + git add . + git commit -m "Update Octez binaries to $OCTEZ_VERSION" + git push origin octez-$OCTEZ_VERSION + gh pr create --title "Update Octez binaries to $OCTEZ_VERSION" --body "This PR updates the Octez binaries to the latest version $OCTEZ_VERSION" --base master --head octez-$OCTEZ_VERSION \ No newline at end of file diff --git a/octez_version.py b/octez_version.py index 832f3c7..cedc115 100644 --- a/octez_version.py +++ b/octez_version.py @@ -12,7 +12,6 @@ def run(*args, **kwargs): 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}') @@ -20,22 +19,18 @@ def main(): print(f'Latest version: {latest_version}') if current_version == latest_version: - return + print('Octez version is up to date.') + exit(1) if not env.get("GITHUB_ACTIONS"): print("This script is intended to be run in a GitHub Action.") - exit(1) + exit(2) 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}') - run('git', 'push', 'origin', f'octez-{latest_version}') - run('gh', 'pr', 'create', '-f', '-B', f'octez-{latest_version}', '-t', f'Update Octez binaries to {latest_version}') - + exit(0) if __name__ == "__main__": main() \ No newline at end of file