-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #319 from dhis2/create-start-release-job
Create start release job in develop
- Loading branch information
Showing
3 changed files
with
110 additions
and
5 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
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,87 @@ | ||
name: Release start | ||
|
||
# Controls when the action will run. Workflow runs when manually triggered using the UI | ||
# or API. | ||
on: | ||
workflow_dispatch: | ||
# Inputs the workflow accepts. | ||
inputs: | ||
release_version_name: | ||
description: 'New release version name' | ||
required: true | ||
type: string | ||
|
||
development_version_name: | ||
description: 'Development version name' | ||
required: true | ||
type: string | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
create_branch: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- 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]>" | ||
# override version with new version | ||
- name: Create release branch | ||
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 add . | ||
git commit -m "Update version to ${{ inputs.release_version_name }}" | ||
git push origin release/${{ inputs.release_version_name }} | ||
update_version: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- 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: Create release branch | ||
run: git checkout -b update_version_to${{ inputs.development_version_name }} | ||
|
||
- 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 origin update_version_to${{ inputs.development_version_name }} | ||
- name: create pull request | ||
run: gh pr create -B develop -H update_version_to${{ inputs.development_version_name }} --title 'Merge update_version_to${{ inputs.development_version_name }} into develop' --body 'Created by Github action' | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,21 @@ | ||
import sys | ||
import re | ||
|
||
def update_version_in_gradle(file_path, new_version): | ||
with open(file_path, 'r') as file: | ||
content = file.read() | ||
|
||
# Use regex to find and replace the version value | ||
updated_content = re.sub(r'version\s*=\s*"[0-9.]+-SNAPSHOT"', f'version = "{new_version}"', content) | ||
|
||
with open(file_path, 'w') as file: | ||
file.write(updated_content) | ||
|
||
print("File updated successfully!") | ||
|
||
if len(sys.argv) > 1: | ||
new_version = sys.argv[1] | ||
file_path = 'build.gradle.kts' | ||
update_version_in_gradle(file_path, new_version) | ||
else: | ||
print("No new version provided. To update the version, pass the new version as a command-line argument.") |