diff --git a/.github/workflows/polkadot_version.yaml b/.github/workflows/polkadot_version.yaml new file mode 100644 index 0000000..0a4e540 --- /dev/null +++ b/.github/workflows/polkadot_version.yaml @@ -0,0 +1,56 @@ +name: Check Polkadot and Cumulus Update + +on: + schedule: + - cron: '0 0 * * *' # Runs at midnight UTC every day + +jobs: + update-version: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + pip install pyyaml requests + + - name: Check for updates in Polkadot and replace version if needed + id: check-update-polkadot + run: python scripts/extract_version.py group_vars/polkadot.yaml default_client_version paritytech polkadot true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check for updates in Cumulus and replace version if needed + id: check-update-cumulus + run: python scripts/extract_version.py group_vars/cumulus.yaml default_client_version paritytech cumulus true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Git config + if: steps.check-update-polkadot.outputs.current_version != steps.check-update-polkadot.outputs.latest_release || steps.check-update-cumulus.outputs.current_version != steps.check-update-cumulus.outputs.latest_release + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Commit updated YAML files + if: steps.check-update-polkadot.outputs.current_version != steps.check-update-polkadot.outputs.latest_release || steps.check-update-cumulus.outputs.current_version != steps.check-update-cumulus.outputs.latest_release + run: | + git add group_vars/polkadot.yaml group_vars/cumulus.yaml + git commit -m "Update Polkadot and Cumulus versions" + git push + + - name: Create Pull Request for Polkadot and Cumulus Update + if: steps.check-update-polkadot.outputs.current_version != steps.check-update-polkadot.outputs.latest_release || steps.check-update-cumulus.outputs.current_version != steps.check-update-cumulus.outputs.latest_release + uses: repo-sync/pull-request@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + pr_title: "Update Polkadot and Cumulus versions" + pr_body: "Automatically updated by GitHub Actions." + pr_label: "automated-pr" diff --git a/group_vars/cumulus.yaml b/group_vars/cumulus.yaml index c380991..ac7fd7c 100644 --- a/group_vars/cumulus.yaml +++ b/group_vars/cumulus.yaml @@ -1,6 +1,6 @@ --- default_client_name: polkadot-v -default_client_version: 1.7.0 +default_client_version: 1.7.1 default_download_base_url: "https://github.com/paritytech/polkadot-sdk/releases/download/" default_download_url: "{{ default_download_base_url }}{{ default_client_name }}{{ default_client_version }}/polkadot-parachain" diff --git a/host_vars/pso16.yaml b/host_vars/pso16.yaml index 7ab1d6c..b86d661 100644 --- a/host_vars/pso16.yaml +++ b/host_vars/pso16.yaml @@ -12,7 +12,6 @@ default_telemetry_name: "Rotko Networks - {{ host_name.split('.')[0] }} {{ defau default_public_dns: "{{ host_name }}" default_network: "paseo" default_chain_spec: "{{ default_base_path }}/paseo.raw.json" -#default_chain_spec_dl_url: "https://raw.githubusercontent.com/paseo-network/runtimes/8cb10b1404f3e1ec79aa72f88d182f6a3f38b3a3/chain-specs/paseo.raw.json" # default_chain_spec_dl_url: "https://raw.githubusercontent.com/paseo-network/runtimes/main/chain-specs/paseo.raw.json" default_chain_spec_dl_url: "https://raw.githubusercontent.com/paseo-network/runtimes/fixed-chain-spec/chain-specs/paseo.raw.json" default_database: paritydb diff --git a/scripts/extract_version.py b/scripts/extract_version.py new file mode 100644 index 0000000..9fa23c0 --- /dev/null +++ b/scripts/extract_version.py @@ -0,0 +1,39 @@ +# extract_version.py +import sys +import requests +import yaml + +def extract_current_version(yaml_file, version_key): + with open(yaml_file, 'r') as file: + data = yaml.safe_load(file) + return data[version_key] + +def replace_version(yaml_file, version_key, new_version): + with open(yaml_file, 'r') as file: + data = yaml.safe_load(file) + data[version_key] = new_version + with open(yaml_file, 'w') as file: + yaml.dump(data, file) + +def get_latest_github_release(owner, repo): + url = f"https://api.github.com/repos/{owner}/{repo}/releases/latest" + response = requests.get(url) + response.raise_for_status() # Ensure to raise an error for a bad response + return response.json()['tag_name'] + +if __name__ == "__main__": + yaml_file = sys.argv[1] + version_key = sys.argv[2] + owner = sys.argv[3] + repo = sys.argv[4] + should_update = sys.argv[5] == 'true' # Expects 'true' or 'false' + + current_version = extract_current_version(yaml_file, version_key) + latest_release = get_latest_github_release(owner, repo) + + print(f"::set-output name=current_version::{current_version}") + print(f"::set-output name=latest_release::{latest_release}") + + if should_update and current_version != latest_release: + replace_version(yaml_file, version_key, latest_release) + print("Version updated.")