-
Notifications
You must be signed in to change notification settings - Fork 23
120 lines (98 loc) · 4.18 KB
/
update-version.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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.