Update Installer #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Installer | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs every day at midnight | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
update-testnet-version: | |
runs-on: ubuntu-latest | |
env: | |
RPC_URL: https://rpc.testnet.osmosis.zone/abci_info | |
VERSION_VAR: TESTNET_VERSION | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Check current version from RPC | |
run: | | |
RESPONSE=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" ${{ env.RPC_URL }}) | |
NETWORK_VERSION=$(echo $RESPONSE | jq -r '.result.response.version') | |
echo "NETWORK_VERSION=$NETWORK_VERSION" >> $GITHUB_ENV | |
- name: Get current version from file | |
run: | | |
FILE_VERSION=$(grep '${{ env.VERSION_VAR }}' i.py | cut -d'"' -f2 | head -n 1) | |
echo "FILE_VERSION=$FILE_VERSION" >> $GITHUB_ENV | |
- name: Validate version format | |
run: | | |
if [[ ! ${{ env.NETWORK_VERSION }} =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?$ ]]; then | |
echo "Version ${{ env.NETWORK_VERSION }} does not match the format X.Y.Z or X.Y.Z-rcN" | |
exit 1 | |
fi | |
- name: Generate branch name | |
run: | | |
RANDOM_ID=$(openssl rand -hex 6) | |
BRANCH_NAME="UPDATE-${{ env.VERSION_VAR }}-TO-${{ env.NETWORK_VERSION }}-$RANDOM_ID" | |
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | |
- name: Update version if different | |
if: env.NETWORK_VERSION != env.FILE_VERSION | |
run: | | |
sed -i "s/${{ env.VERSION_VAR }} = \".*\"/${{ env.VERSION_VAR }} = \"${{ env.NETWORK_VERSION }}\"/" i.py | |
- name: Create Pull Request | |
if: env.NETWORK_VERSION != env.FILE_VERSION | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: Update ${{ env.VERSION_VAR }} version to ${{ env.NETWORK_VERSION }} | |
base: main | |
branch: ${{env.BRANCH_NAME}} | |
title: Update ${{ env.VERSION_VAR }} version to ${{ env.NETWORK_VERSION }} | |
body: | | |
This PR updates the ${{ env.VERSION_VAR }} version to ${{ env.NETWORK_VERSION }}. | |
🤖 This PR was autogenerated. | |
update-mainnet-version: | |
runs-on: ubuntu-latest | |
env: | |
RPC_URL: https://rpc.osmosis.zone/abci_info | |
VERSION_VAR: MAINNET_VERSION | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Check current version from RPC | |
run: | | |
RESPONSE=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" ${{ env.RPC_URL }}) | |
NETWORK_VERSION=$(echo $RESPONSE | jq -r '.result.response.version') | |
echo "NETWORK_VERSION=$NETWORK_VERSION" >> $GITHUB_ENV | |
- name: Get current version from file | |
id: get_file_version | |
run: | | |
FILE_VERSION=$(grep '${{ env.VERSION_VAR }}' i.py | cut -d'"' -f2 | head -n 1) | |
echo "FILE_VERSION=$FILE_VERSION" >> $GITHUB_ENV | |
- name: Validate version format | |
run: | | |
if [[ ! ${{ env.NETWORK_VERSION }} =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?$ ]]; then | |
echo "Version ${{ env.NETWORK_VERSION }} does not match the format X.Y.Z or X.Y.Z-rcN" | |
exit 1 | |
fi | |
- name: Generate branch name | |
run: | | |
RANDOM_ID=$(openssl rand -hex 6) | |
BRANCH_NAME="UPDATE-${{ env.VERSION_VAR }}-TO-${{ env.NETWORK_VERSION }}-$RANDOM_ID" | |
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | |
- name: Update version if different | |
if: env.NETWORK_VERSION != env.FILE_VERSION | |
run: | | |
sed -i "s/${{ env.VERSION_VAR }} = \".*\"/${{ env.VERSION_VAR }} = \"${{ env.NETWORK_VERSION }}\"/" i.py | |
- name: Create Pull Request | |
if: env.NETWORK_VERSION != env.FILE_VERSION | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: Update ${{ env.VERSION_VAR }} version to ${{ env.NETWORK_VERSION }} | |
base: main | |
branch: ${{env.BRANCH_NAME}} | |
title: Update ${{ env.VERSION_VAR }} version to ${{ env.NETWORK_VERSION }} | |
body: | | |
This PR updates the ${{ env.VERSION_VAR }} version to ${{ env.NETWORK_VERSION }}. | |
🤖 This PR was autogenerated. |