Update Installer #175
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: Compare versions | |
id: compare_versions | |
run: | | |
compare_versions() { | |
local v1=$1 | |
local v2=$2 | |
if [[ $v1 == $v2 ]]; then | |
echo "COMPARE_RESULT=0" >> $GITHUB_ENV | |
return | |
fi | |
local IFS=. | |
local i | |
local version1=($v1) | |
local version2=($v2) | |
for ((i=0; i<${#version1[@]}; i++)); do | |
if [[ ${version1[i]} -gt ${version2[i]} ]]; then | |
echo "COMPARE_RESULT=1" >> $GITHUB_ENV | |
return | |
fi | |
if [[ ${version1[i]} -lt ${version2[i]} ]]; then | |
echo "COMPARE_RESULT=2" >> $GITHUB_ENV | |
return | |
fi | |
done | |
echo "COMPARE_RESULT=0" >> $GITHUB_ENV | |
} | |
compare_versions ${{ env.NETWORK_VERSION }} ${{ env.FILE_VERSION }} | |
- name: Generate branch name | |
if: env.COMPARE_RESULT == 1 | |
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.COMPARE_RESULT == 1 | |
run: | | |
sed -i "s/${{ env.VERSION_VAR }} = \".*\"/${{ env.VERSION_VAR }} = \"${{ env.NETWORK_VERSION }}\"/" i.py | |
- name: Create Pull Request | |
if: env.COMPARE_RESULT == 1 | |
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 | |
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: Compare versions | |
id: compare_versions | |
run: | | |
compare_versions() { | |
local v1=$1 | |
local v2=$2 | |
if [[ $v1 == $v2 ]]; then | |
echo "COMPARE_RESULT=0" >> $GITHUB_ENV | |
return | |
fi | |
local IFS=. | |
local i | |
local version1=($v1) | |
local version2=($v2) | |
for ((i=0; i<${#version1[@]}; i++)); do | |
if [[ ${version1[i]} -gt ${version2[i]} ]]; then | |
echo "COMPARE_RESULT=1" >> $GITHUB_ENV | |
return | |
fi | |
if [[ ${version1[i]} -lt ${version2[i]} ]]; then | |
echo "COMPARE_RESULT=2" >> $GITHUB_ENV | |
return | |
fi | |
done | |
echo "COMPARE_RESULT=0" >> $GITHUB_ENV | |
} | |
compare_versions ${{ env.NETWORK_VERSION }} ${{ env.FILE_VERSION }} | |
- name: Generate branch name | |
if: env.COMPARE_RESULT == 1 | |
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.COMPARE_RESULT == 1 | |
run: | | |
sed -i "s/${{ env.VERSION_VAR }} = \".*\"/${{ env.VERSION_VAR }} = \"${{ env.NETWORK_VERSION }}\"/" i.py | |
- name: Create Pull Request | |
if: env.COMPARE_RESULT == 1 | |
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. |