Skip to content

Commit

Permalink
[DEVOPS-464] Add version input to bump versions workflow (#130)
Browse files Browse the repository at this point in the history
<!-- Please make sure you read the contribution guidelines and then fill
out the blanks below.

Please format the PR title appropriately based on the type of change:
  [JIRA-XXX]: <description>
-->

## Description

- Add version input to bump versions workflow to add in the option for a
specific version rather than relying solely on bumping the version to
the next major/minor/patch release.

## Related Links

<!-- List any links related to this pull request here

Replace "JIRA-XXX" with the your Jira issue key -->

- Jira Issue: DEVOPS-464
- Working test: 

![image](https://github.com/Andrews-McMeel-Universal/reusable_workflows/assets/111298136/63721d69-87bf-4065-8248-1c9988881d48)
---

![image](https://github.com/Andrews-McMeel-Universal/reusable_workflows/assets/111298136/988bdce8-9f5e-41e4-b98d-5298c0a7d20f)
  • Loading branch information
ebronson68 authored Jun 13, 2024
1 parent e6590f7 commit 80891c4
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/bump-versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,46 @@ on:
workflow_call:
inputs:
releaseType:
required: true
required: false
type: string
description: Type of release
environmentCharts:
required: false
type: string
description: Set to true if the repository has separate Helm chart directories for each environment
default: 'false'
version:
required: false
type: string
description: The version to bump to. If not provided, the next version will be calculated based on the latest release
secrets:
PAT_ACTION_CI:
required: false

jobs:
bump-version:
name: Bump Versions to next ${{ inputs.releaseType }}
name: Bump Version - ${{ inputs.version || inputs.releaseType }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get latest release
if: ${{ ! inputs.version }}
id: latestrelease
continue-on-error: true
uses: thebritican/fetch-latest-release@v2.0.0

- name: Get Chart.yaml appVersion
if: inputs.environmentCharts == 'false'
if: ${{ inputs.environmentCharts == 'false' && ! inputs.version }}
id: chartyaml
uses: rmeneely/get-yaml-value@v1
with:
infile: deployments/charts/Chart.yaml
varlist: appVersion

- name: Get Environment Chart.yaml appVersion
if: inputs.environmentCharts == 'true'
if: ${{ inputs.environmentCharts == 'true' && ! inputs.version }}
id: environmentchartyaml
uses: rmeneely/get-yaml-value@v1
with:
Expand All @@ -52,14 +57,15 @@ jobs:
files: "package.json"

- name: Get package.json version
if: steps.packagejsonfile.outputs.files_exists == 'true'
if: ${{ steps.packagejsonfile.outputs.files_exists == 'true' && ! inputs.version }}
id: packagejson
uses: notiz-dev/github-action-json-property@v0.2.0
with:
path: "package.json"
prop_path: "version"

- name: Gets next semantic release
if: ${{ ! inputs.version }}
shell: pwsh
run: |
[Version]$a = "${{ steps.packagejson.outputs.prop || '0.0.0' }}"
Expand Down Expand Up @@ -87,29 +93,29 @@ jobs:
uses: jacobtomlinson/gha-find-replace@v3
with:
find: '"version": .*'
replace: '"version": "${{ env.release }}",'
replace: '"version": "${{ inputs.version || env.release }}",'
regex: true
include: "**package.json"

- name: Update version in Chart.yaml
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "appVersion: .*"
replace: "appVersion: ${{ env.release }}"
replace: "appVersion: ${{ inputs.version || env.release }}"
regex: true
include: "**Chart.yaml"

- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
commit-message: "⬆️ Version bump: ${{ env.release }}"
branch: maintenance/bump-version/${{ env.release }}
commit-message: "⬆️ Version bump: ${{ inputs.version || env.release }}"
branch: maintenance/bump-version/${{ inputs.version || env.release }}
committer: AMU Automations <amu_deploy@amuniversal.com>
delete-branch: true
title: "⬆️ Version bump: ${{ env.release }}"
title: "⬆️ Version bump: ${{ inputs.version || env.release }}"
body: |
Updating version to ${{ env.release }} in:
Updating version to ${{ inputs.version || env.release }} in:
- `**/Charts.yaml`
- `**/package.json`
labels: |
Expand Down

0 comments on commit 80891c4

Please sign in to comment.