|
1 | | -name: pre-release helm chart |
2 | | - |
3 | | -on: |
4 | | - pull_request: |
5 | | - branches: [ "main" ] |
6 | | - #types: [ closed ] |
7 | | - types: [ opened, reopened, synchronize ] |
8 | | - |
9 | | -env: |
10 | | - HELM_VERSION: v3.15.2 |
11 | | - |
12 | | -jobs: |
13 | | - pre-release: |
14 | | - #if: github.event.pull_request.merged == true |
15 | | - runs-on: ubuntu-latest |
16 | | - |
17 | | - steps: |
18 | | - - name: checkout code |
19 | | - uses: actions/checkout@v4 |
20 | | - with: |
21 | | - fetch-depth: 0 # ensure the full history is fetched so we can compare changes |
22 | | - |
23 | | - - uses: azure/setup-helm@v4 |
24 | | - with: |
25 | | - version: ${{ env.HELM_VERSION }} |
26 | | - |
27 | | - - name: install github cli |
28 | | - run: | |
29 | | - sudo apt-get update |
30 | | - sudo apt-get install -y gh |
31 | | -
|
32 | | - - name: install yq |
33 | | - uses: mikefarah/yq@master |
34 | | - |
35 | | -# - name: setup upterm session |
36 | | -# uses: lhotari/action-upterm@v1 |
37 | | - |
38 | | - - name: check if 'release-apply' label exists |
39 | | - id: check_label |
40 | | - run: | |
41 | | - PR_NUMBER=${{ github.event.pull_request.number }} |
42 | | - LABELS=$(gh pr view $PR_NUMBER --json labels --jq '.labels[].name') |
43 | | - echo "Labels: $LABELS" |
44 | | - if echo "$LABELS" | grep -q "release-apply"; then |
45 | | - echo "Label 'release-apply' found." |
46 | | - # PRs with label "release-label" are created at the end of this workflow and we don't want infinite loops |
47 | | - echo "The pull request is merged and has the 'release-apply' label. Nothing to do. Exiting with success" |
48 | | - echo "continue=false" >>$GITHUB_OUTPUT |
49 | | - exit 0 |
50 | | - else |
51 | | - echo "Label 'release-apply' not found." |
52 | | - echo "continue=true" >>$GITHUB_OUTPUT |
53 | | - fi |
54 | | - env: |
55 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
56 | | - |
57 | | - - name: check for changes in helm-chart directory |
58 | | - id: check_changes |
59 | | - run: | |
60 | | - git fetch --all |
61 | | - # check for changes between HEAD and previous commit in a specific directory |
62 | | - if ! git diff --quiet HEAD~ -- ./helm-chart/eoapi/; then |
63 | | - echo "Changes detected in the ./helm-chart/eoapi/ directory." |
64 | | - echo "continue=true" >> $GITHUB_OUTPUT |
65 | | - else |
66 | | - echo "No changes detected in the ./helm-chart/eoapi directory. Exiting." |
67 | | - echo "continue=false" >> $GITHUB_OUTPUT |
68 | | - exit 0 |
69 | | - fi |
70 | | -
|
71 | | - - name: determine version increment |
72 | | - if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true' |
73 | | - id: determine-version |
74 | | - run: | |
75 | | - PR_TITLE=$(echo "${{ github.event.pull_request.title }}" | tr '[:upper:]' '[:lower:]') |
76 | | - if [[ "$PR_TITLE" =~ "major:" ]]; then |
77 | | - echo "version_type=major" >> $GITHUB_ENV |
78 | | - elif [[ "$PR_TITLE" =~ "minor:" ]]; then |
79 | | - echo "version_type=minor" >> $GITHUB_ENV |
80 | | - else |
81 | | - echo "version_type=patch" >> $GITHUB_ENV |
82 | | - fi |
83 | | - echo "Version increment type: ${{ env.version_type }}" |
84 | | -
|
85 | | - - name: bump chart versions |
86 | | - if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true' |
87 | | - id: bump-version |
88 | | - run: | |
89 | | - cd helm-chart/eoapi |
90 | | - VERSION_TYPE=${{ env.version_type }} |
91 | | -
|
92 | | - CURRENT_VERSION=$(grep '^version:' Chart.yaml | awk '{print $2}') |
93 | | - # strip double quotes |
94 | | - CURRENT_VERSION=${CURRENT_VERSION#\"} |
95 | | - CURRENT_VERSION=${CURRENT_VERSION%\"} |
96 | | -
|
97 | | - CURRENT_APP_VERSION=$(grep '^appVersion:' Chart.yaml | awk '{print $2}') |
98 | | - # strip double quotes |
99 | | - CURRENT_APP_VERSION=${CURRENT_APP_VERSION#\"} |
100 | | - CURRENT_APP_VERSION=${CURRENT_APP_VERSION%\"} |
101 | | -
|
102 | | - IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION" |
103 | | - IFS='.' read -r -a APP_VERSION_PARTS <<< "$CURRENT_APP_VERSION" |
104 | | -
|
105 | | - if [[ "$VERSION_TYPE" == "major" ]]; then |
106 | | - NEW_VERSION="$((VERSION_PARTS[0] + 1)).0.0" |
107 | | - # appVersion does not need to follow semvar |
108 | | - NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))" |
109 | | - elif [[ "$VERSION_TYPE" == "minor" ]]; then |
110 | | - NEW_VERSION="${VERSION_PARTS[0]}.$((VERSION_PARTS[1] + 1)).0" |
111 | | - # appVersion does not need to follow semvar |
112 | | - NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))" |
113 | | - else |
114 | | - NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$((VERSION_PARTS[2] + 1))" |
115 | | - # appVersion does not need to follow semvar |
116 | | - NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))" |
117 | | - fi |
118 | | -
|
119 | | - # export so strenv picks them up |
120 | | - export NEW_VERSION |
121 | | - export NEW_APP_VERSION |
122 | | -
|
123 | | - yq -i '.version = strenv(NEW_VERSION)' Chart.yaml |
124 | | - yq -i '.appVersion = strenv(NEW_APP_VERSION)' Chart.yaml |
125 | | -
|
126 | | - echo "new_version=$NEW_VERSION" >> $GITHUB_ENV |
127 | | - echo "New version: $NEW_VERSION" |
128 | | - echo "New app version: $NEW_APP_VERSION" |
129 | | -
|
130 | | - - uses: actions/github-script@v6 |
131 | | - if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true' |
132 | | - with: |
133 | | - script: | |
134 | | - github.rest.issues.addLabels({ |
135 | | - owner: context.repo.owner, |
136 | | - repo: context.repo.repo, |
137 | | - issue_number: context.issue.number, |
138 | | - labels: ['release-apply'] |
139 | | - }) |
140 | | -
|
141 | | - - name: commit chart version bump |
142 | | - if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true' |
143 | | - run: | |
144 | | - TAG="v${{ env.new_version }}" |
145 | | - git config --global user.name "${{ github.actor }}" |
146 | | - git config --global user.email "${{ github.actor }}@users.noreply.github.com" |
147 | | - git fetch origin |
148 | | - git checkout ${{ github.head_ref }} |
149 | | - git add -A |
150 | | - git commit -m "release version to v${{ env.new_version }}" |
151 | | - # only tag main branch in manual release |
152 | | - # git tag "v${{ env.new_version }}" |
153 | | - git push origin ${{ github.head_ref }} |
154 | | - env: |
155 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
156 | | - |
157 | | -# - name: create pr |
| 1 | +#name: pre-release helm chart |
| 2 | +# |
| 3 | +#on: |
| 4 | +# pull_request: |
| 5 | +# branches: [ "main" ] |
| 6 | +# #types: [ closed ] |
| 7 | +# types: [ opened, reopened, synchronize ] |
| 8 | +# |
| 9 | +#env: |
| 10 | +# HELM_VERSION: v3.15.2 |
| 11 | +# |
| 12 | +#jobs: |
| 13 | +# pre-release: |
| 14 | +# #if: github.event.pull_request.merged == true |
| 15 | +# runs-on: ubuntu-latest |
| 16 | +# |
| 17 | +# steps: |
| 18 | +# - name: checkout code |
| 19 | +# uses: actions/checkout@v4 |
| 20 | +# with: |
| 21 | +# fetch-depth: 0 # ensure the full history is fetched so we can compare changes |
| 22 | +# |
| 23 | +# - uses: azure/setup-helm@v4 |
| 24 | +# with: |
| 25 | +# version: ${{ env.HELM_VERSION }} |
| 26 | +# |
| 27 | +# - name: install github cli |
| 28 | +# run: | |
| 29 | +# sudo apt-get update |
| 30 | +# sudo apt-get install -y gh |
| 31 | +# |
| 32 | +# - name: install yq |
| 33 | +# uses: mikefarah/yq@master |
| 34 | +# |
| 35 | +## - name: setup upterm session |
| 36 | +## uses: lhotari/action-upterm@v1 |
| 37 | +# |
| 38 | +# - name: check if 'release-apply' label exists |
| 39 | +# id: check_label |
| 40 | +# run: | |
| 41 | +# PR_NUMBER=${{ github.event.pull_request.number }} |
| 42 | +# LABELS=$(gh pr view $PR_NUMBER --json labels --jq '.labels[].name') |
| 43 | +# echo "Labels: $LABELS" |
| 44 | +# if echo "$LABELS" | grep -q "release-apply"; then |
| 45 | +# echo "Label 'release-apply' found." |
| 46 | +# # PRs with label "release-label" are created at the end of this workflow and we don't want infinite loops |
| 47 | +# echo "The pull request is merged and has the 'release-apply' label. Nothing to do. Exiting with success" |
| 48 | +# echo "continue=false" >>$GITHUB_OUTPUT |
| 49 | +# exit 0 |
| 50 | +# else |
| 51 | +# echo "Label 'release-apply' not found." |
| 52 | +# echo "continue=true" >>$GITHUB_OUTPUT |
| 53 | +# fi |
| 54 | +# env: |
| 55 | +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | +# |
| 57 | +# - name: check for changes in helm-chart directory |
| 58 | +# id: check_changes |
| 59 | +# run: | |
| 60 | +# git fetch --all |
| 61 | +# # check for changes between HEAD and previous commit in a specific directory |
| 62 | +# if ! git diff --quiet HEAD~ -- ./helm-chart/eoapi/; then |
| 63 | +# echo "Changes detected in the ./helm-chart/eoapi/ directory." |
| 64 | +# echo "continue=true" >> $GITHUB_OUTPUT |
| 65 | +# else |
| 66 | +# echo "No changes detected in the ./helm-chart/eoapi directory. Exiting." |
| 67 | +# echo "continue=false" >> $GITHUB_OUTPUT |
| 68 | +# exit 0 |
| 69 | +# fi |
| 70 | +# |
| 71 | +# - name: determine version increment |
| 72 | +# if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true' |
| 73 | +# id: determine-version |
| 74 | +# run: | |
| 75 | +# PR_TITLE=$(echo "${{ github.event.pull_request.title }}" | tr '[:upper:]' '[:lower:]') |
| 76 | +# if [[ "$PR_TITLE" =~ "major:" ]]; then |
| 77 | +# echo "version_type=major" >> $GITHUB_ENV |
| 78 | +# elif [[ "$PR_TITLE" =~ "minor:" ]]; then |
| 79 | +# echo "version_type=minor" >> $GITHUB_ENV |
| 80 | +# else |
| 81 | +# echo "version_type=patch" >> $GITHUB_ENV |
| 82 | +# fi |
| 83 | +# echo "Version increment type: ${{ env.version_type }}" |
| 84 | +# |
| 85 | +# - name: bump chart versions |
| 86 | +# if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true' |
| 87 | +# id: bump-version |
| 88 | +# run: | |
| 89 | +# cd helm-chart/eoapi |
| 90 | +# VERSION_TYPE=${{ env.version_type }} |
| 91 | +# |
| 92 | +# CURRENT_VERSION=$(grep '^version:' Chart.yaml | awk '{print $2}') |
| 93 | +# # strip double quotes |
| 94 | +# CURRENT_VERSION=${CURRENT_VERSION#\"} |
| 95 | +# CURRENT_VERSION=${CURRENT_VERSION%\"} |
| 96 | +# |
| 97 | +# CURRENT_APP_VERSION=$(grep '^appVersion:' Chart.yaml | awk '{print $2}') |
| 98 | +# # strip double quotes |
| 99 | +# CURRENT_APP_VERSION=${CURRENT_APP_VERSION#\"} |
| 100 | +# CURRENT_APP_VERSION=${CURRENT_APP_VERSION%\"} |
| 101 | +# |
| 102 | +# IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION" |
| 103 | +# IFS='.' read -r -a APP_VERSION_PARTS <<< "$CURRENT_APP_VERSION" |
| 104 | +# |
| 105 | +# if [[ "$VERSION_TYPE" == "major" ]]; then |
| 106 | +# NEW_VERSION="$((VERSION_PARTS[0] + 1)).0.0" |
| 107 | +# # appVersion does not need to follow semvar |
| 108 | +# NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))" |
| 109 | +# elif [[ "$VERSION_TYPE" == "minor" ]]; then |
| 110 | +# NEW_VERSION="${VERSION_PARTS[0]}.$((VERSION_PARTS[1] + 1)).0" |
| 111 | +# # appVersion does not need to follow semvar |
| 112 | +# NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))" |
| 113 | +# else |
| 114 | +# NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$((VERSION_PARTS[2] + 1))" |
| 115 | +# # appVersion does not need to follow semvar |
| 116 | +# NEW_APP_VERSION="${APP_VERSION_PARTS[0]}.${APP_VERSION_PARTS[1]}.$((APP_VERSION_PARTS[2] + 1))" |
| 117 | +# fi |
| 118 | +# |
| 119 | +# # export so strenv picks them up |
| 120 | +# export NEW_VERSION |
| 121 | +# export NEW_APP_VERSION |
| 122 | +# |
| 123 | +# yq -i '.version = strenv(NEW_VERSION)' Chart.yaml |
| 124 | +# yq -i '.appVersion = strenv(NEW_APP_VERSION)' Chart.yaml |
| 125 | +# |
| 126 | +# echo "new_version=$NEW_VERSION" >> $GITHUB_ENV |
| 127 | +# echo "New version: $NEW_VERSION" |
| 128 | +# echo "New app version: $NEW_APP_VERSION" |
| 129 | +# |
| 130 | +# - uses: actions/github-script@v6 |
158 | 131 | # if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true' |
159 | | -# id: create_pr |
160 | | -# uses: peter-evans/create-pull-request@v6 |
161 | 132 | # with: |
162 | | -# token: ${{ secrets.GITHUB_TOKEN }} |
163 | | -# commit-message: 'release eoapi chart to v${{ env.new_version }}' |
164 | | -# title: 'release v${{ env.new_version }} for ${{ github.ref }}@${{ github.sha }}' |
165 | | -# body: | |
166 | | -# this PR contains the version bumps for the eoapi chart v${{ env.new_version }} |
167 | | -# base: main |
168 | | -# branch: apply-${{ github.head_ref }} |
169 | | -# labels: release-apply |
| 133 | +# script: | |
| 134 | +# github.rest.issues.addLabels({ |
| 135 | +# owner: context.repo.owner, |
| 136 | +# repo: context.repo.repo, |
| 137 | +# issue_number: context.issue.number, |
| 138 | +# labels: ['release-apply'] |
| 139 | +# }) |
| 140 | +# |
| 141 | +# - name: commit chart version bump |
| 142 | +# if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true' |
| 143 | +# run: | |
| 144 | +# TAG="v${{ env.new_version }}" |
| 145 | +# git config --global user.name "${{ github.actor }}" |
| 146 | +# git config --global user.email "${{ github.actor }}@users.noreply.github.com" |
| 147 | +# git fetch origin |
| 148 | +# git checkout ${{ github.head_ref }} |
| 149 | +# git add -A |
| 150 | +# git commit -m "release version to v${{ env.new_version }}" |
| 151 | +# # only tag main branch in manual release |
| 152 | +# # git tag "v${{ env.new_version }}" |
| 153 | +# git push origin ${{ github.head_ref }} |
| 154 | +# env: |
| 155 | +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 156 | +# |
| 157 | +## - name: create pr |
| 158 | +## if: steps.check_label.outputs.continue == 'true' && steps.check_changes.outputs.continue == 'true' |
| 159 | +## id: create_pr |
| 160 | +## uses: peter-evans/create-pull-request@v6 |
| 161 | +## with: |
| 162 | +## token: ${{ secrets.GITHUB_TOKEN }} |
| 163 | +## commit-message: 'release eoapi chart to v${{ env.new_version }}' |
| 164 | +## title: 'release v${{ env.new_version }} for ${{ github.ref }}@${{ github.sha }}' |
| 165 | +## body: | |
| 166 | +## this PR contains the version bumps for the eoapi chart v${{ env.new_version }} |
| 167 | +## base: main |
| 168 | +## branch: apply-${{ github.head_ref }} |
| 169 | +## labels: release-apply |
0 commit comments