-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* modify vName * update python version * update python script * update python script * run script with params * format toml file * update script * commit changes in base branch * setup git config * update development and release version names
- Loading branch information
Showing
3 changed files
with
93 additions
and
47 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,13 @@ on: | |
workflow_dispatch: | ||
# Inputs the workflow accepts. | ||
inputs: | ||
version_name: | ||
description: 'Release version name' | ||
release_version_name: | ||
description: 'New release version name' | ||
required: true | ||
type: string | ||
|
||
development_version_name: | ||
description: 'Development version name' | ||
required: true | ||
type: string | ||
|
||
|
@@ -20,9 +25,38 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
# override vName with new version | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12.1 | ||
|
||
- name: setup git config | ||
run: | | ||
# setup the username and email. | ||
git config user.name "GitHub Actions Bot" | ||
git config user.email "<[email protected]>" | ||
- name: Run Python script to update base branch version | ||
run: python scripts/updateVersionName.py ${{ inputs.development_version_name }} | ||
|
||
- name: Commit and Push Changes | ||
run: | | ||
git add . | ||
git commit -m "Update version to ${{ inputs.development_version_name }}" | ||
git push | ||
# override vName with new version | ||
- name: Create release branch | ||
run: git checkout -b release/${{ inputs.version_name }} | ||
run: git checkout -b release/${{ inputs.release_version_name }} | ||
|
||
- name: Run Python script to update release branch version | ||
run: python scripts/updateVersionName.py ${{ inputs.release_version_name }} | ||
|
||
- name: Push | ||
run: git push origin release/${{ inputs.version_name }} | ||
run: | | ||
git add . | ||
git commit -m "Update version to ${{ inputs.release_version_name }}" | ||
git push origin release/${{ inputs.release_version_name }} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import sys | ||
|
||
def load_toml(file_path): | ||
# Read the TOML file and parse it manually | ||
with open(file_path, 'r') as file: | ||
lines = file.readlines() | ||
|
||
data = {} | ||
current_section = None | ||
|
||
for line in lines: | ||
line = line.strip() | ||
if line.startswith('[') and line.endswith(']'): | ||
current_section = line[1:-1] | ||
data[current_section] = {} | ||
elif '=' in line and current_section: | ||
key, value = line.split('=', 1) | ||
data[current_section][key.strip()] = value.strip() | ||
|
||
return data | ||
|
||
def save_toml(file_path, data, newVersion): | ||
# Write the data back to the TOML file | ||
with open(file_path, 'w') as file: | ||
for section, section_data in data.items(): | ||
file.write(f'[{section}]\n') | ||
for key, value in section_data.items(): | ||
# Check if the key is 'vName' and update the value with quotes | ||
if section == 'versions' and key == 'vName': | ||
value = f'"{newVersion}"' | ||
file.write(f'{key} = {value}\n') | ||
|
||
|
||
file_path = 'gradle/libs.versions.toml' | ||
data = load_toml(file_path) | ||
|
||
if len(sys.argv) > 1: | ||
newVersion = sys.argv[1] | ||
# Update the 'vName' value in the data dictionary | ||
data['versions']['vName'] = newVersion | ||
save_toml(file_path, data, newVersion) | ||
print("File updated successfully!") | ||
else: | ||
print("No new version provided. To update the version, pass the new version as a command-line argument.") |