-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (113 loc) · 4.43 KB
/
bump-versions.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
121
122
123
124
125
126
127
128
name: Bump App Version
on:
workflow_call:
inputs:
releaseType:
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 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: gregziegan/fetch-latest-release@v2.0.0
- name: Get Chart.yaml appVersion
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' && ! inputs.version }}
id: environmentchartyaml
uses: rmeneely/get-yaml-value@v1
with:
infile: deployments/production-charts/Chart.yaml
varlist: appVersion
- name: Check if package.json exists
id: packagejsonfile
uses: andstor/file-existence-action@v3
with:
files: "package.json"
- name: Get package.json version
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' }}"
[Version]$b = "${{ steps.environmentchartyaml.outputs.values || steps.chartyaml.outputs.values || '0.0.0' }}"
[Version]$c = "${{ steps.latestrelease.outputs.tag_name || '0.0.0' }}"
$versions = [array]($a,$b,$c)
$v = [version]($versions | Sort-Object -Descending | Select-Object -First 1)
if ( "${{ inputs.releaseType }}" -match "major") {
$release = [version]::New($v.Major+1,0,0)
}
elseif ( "${{ inputs.releaseType }}" -match "minor" ) {
$release = [version]::New($v.Major,$v.Minor+1,0)
}
elseif ( "${{ inputs.releaseType }}" -match "patch" ) {
$release = [version]::New($v.Major,$v.Minor,$v.Build+1)
}
echo "release=$release" >> $env:GITHUB_ENV
echo "Bumping version to $release"
- name: Update version in package.json
if: steps.packagejsonfile.outputs.files_exists == 'true'
uses: jacobtomlinson/gha-find-replace@v3
with:
find: '"version": .*'
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: ${{ 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: ${{ 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: ${{ inputs.version || env.release }}"
body: |
Updating version to ${{ inputs.version || env.release }} in:
- `**/Charts.yaml`
- `**/package.json`
labels: |
${{ inputs.releaseType }}
- name: Auto Approve Version Update PR
uses: hmarr/auto-approve-action@v4.0.0
with:
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
github-token: ${{ secrets.PAT_ACTION_CI }}