Skip to content

Commit

Permalink
Merge pull request #71 from niccoloraspa/main
Browse files Browse the repository at this point in the history
Add workflow to automatically update installer
  • Loading branch information
niccoloraspa authored Jun 4, 2024
2 parents 8ce00e8 + c33902d commit 0862618
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ jobs:
fail-fast: false

steps:
-
-
name: Checkout Repository
uses: actions/checkout@v3
-
-
name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
-
-
name: Run Installer
env:
TERM: xterm
Expand All @@ -40,7 +40,7 @@ jobs:
--network ${{ matrix.network }} \
--home ${{ runner.temp }}/.osmosisd \
--moniker osmosis \
--overwrite
--overwrite
-
name: Run osmosisd
run: |
Expand Down
120 changes: 120 additions & 0 deletions .github/workflows/update-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
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.

0 comments on commit 0862618

Please sign in to comment.