|
83 | 83 | message: "Please apply one of the following labels to the PR: 'patch', 'minor', 'major'." |
84 | 84 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
85 | 85 |
|
86 | | - prepare-release: |
87 | | - needs: ["check-labels", "comment"] |
88 | | - |
89 | | - runs-on: ubuntu-latest |
90 | | - |
91 | | - steps: |
92 | | - - uses: actions/checkout@v3 |
93 | | - with: |
94 | | - fetch-depth: 0 |
95 | | - |
96 | | - - id: bump |
97 | | - uses: zwaldowski/match-label-action@v4 |
98 | | - with: |
99 | | - allowed: major,minor,patch |
100 | | - |
101 | | - - name: Get changed files |
102 | | - id: changed-files |
103 | | - uses: tj-actions/[email protected] |
104 | | - |
105 | | - |
106 | | - # prepare yaml parser |
107 | | - - uses: actions/setup-go@v4 |
108 | | - - name: Install yq |
109 | | - run: | |
110 | | - go install github.com/mikefarah/yq/v4@latest |
111 | | - yq --version |
112 | | -
|
113 | | - - uses: actions/checkout@v3 |
114 | | - with: |
115 | | - ref: ${{ github.head_ref }} |
116 | | - |
117 | | - - name: Update versions |
118 | | - shell: bash |
119 | | - run: | |
120 | | - declare -A changedCharts |
121 | | -
|
122 | | - for file in ${{ steps.changed-files.outputs.all_changed_and_modified_files }}; do |
123 | | -
|
124 | | - echo "$file was changed" |
125 | | - baseFolder=$(cut -d'/' -f1 <<< "$file") |
126 | | - if [ $baseFolder = "charts" ] && [ $file != "charts/README.md" ]; then |
127 | | - chartName=$(cut -d'/' -f2 <<< "$file") |
128 | | - changedCharts[$chartName]=$chartName |
129 | | - fi |
130 | | - done |
131 | | -
|
132 | | - for c in "${changedCharts[@]}"; do |
133 | | - # get version from chart yaml |
134 | | - version=$(yq e '.version' "charts/$c/Chart.yaml") |
135 | | - major=$(cut -d'.' -f1 <<< "$version") |
136 | | - minor=$(cut -d'.' -f2 <<< "$version") |
137 | | - patch=$(cut -d'.' -f3 <<< "$version") |
138 | | -
|
139 | | - prType=${{ steps.bump.outputs.match }} |
140 | | - echo Update version $version with type $prType |
141 | | - if [ $prType = "major" ]; then |
142 | | - echo Update major |
143 | | - major=$((major+1)) |
144 | | - minor=0 |
145 | | - patch=0 |
146 | | - elif [ $prType = "minor" ]; then |
147 | | - echo Update minor |
148 | | - minor=$((minor+1)) |
149 | | - patch=0 |
150 | | - elif [ $prType = "patch" ]; then |
151 | | - echo Update patch |
152 | | - patch=$((patch+1)) |
153 | | - fi |
154 | | - echo Update version to $major.$minor.$patch for $c |
155 | | - yq e -i '.version = "'$major.$minor.$patch'"' charts/$c/Chart.yaml |
156 | | - done |
157 | | -
|
158 | | - - name: Commit files |
159 | | - continue-on-error: true |
160 | | - run: | |
161 | | - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" |
162 | | - git config --local user.name "github-actions[bot]" |
163 | | - git status |
164 | | - echo commit |
165 | | - git commit -m "Update helm chart versions" -a |
166 | | - echo status update |
167 | | - git status |
168 | | -
|
169 | | - - name: Push changes |
170 | | - continue-on-error: true |
171 | | - uses: ad-m/github-push-action@master |
172 | | - with: |
173 | | - branch: ${{ github.head_ref }} |
0 commit comments