-
Notifications
You must be signed in to change notification settings - Fork 23
266 lines (228 loc) · 9.65 KB
/
release-miw.yml
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# Copyright (c) 2021-2024 Contributors to the Eclipse Foundation
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# SPDX-License-Identifier: Apache-2.0
---
name: Semantic Release - MIW
on:
push:
paths:
- 'miw/src/**'
- 'miw/build.gradle/**'
- 'wallet-commons/src/**'
- 'build.gradle'
- 'gradle.properties'
- 'settings.gradle'
branches:
- main
- develop
pull_request:
paths:
- 'miw/src/**'
- 'miw/build.gradle/**'
- 'wallet-commons/src/**'
- 'build.gradle'
- 'gradle.properties'
- 'settings.gradle'
branches:
- main
- develop
env:
IMAGE_NAMESPACE: "tractusx"
IMAGE_NAME: "managed-identity-wallet"
jobs:
semantic_release:
name: Repository Release
runs-on: ubuntu-latest
permissions:
# see https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
contents: write
pull-requests: write
packages: write
outputs:
next_release: ${{ steps.semantic-release.outputs.next_release }}
will_create_new_release: ${{ steps.semantic-release.outputs.will_create_new_release }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Setup Helm
uses: azure/[email protected]
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
# setup helm-docs as it is needed during semantic-release
- uses: gabe565/setup-helm-docs-action@v1
name: Setup helm-docs
if: github.event_name != 'pull_request'
with:
version: v1.11.3
- name: Run semantic release
id: semantic-release
if: github.event_name != 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
run: |
npx --yes -p @semantic-release/exec -p @semantic-release/changelog -p @semantic-release/git -p @semantic-release/commit-analyzer -p @semantic-release/release-notes-generator semantic-release
- name: Run semantic release (dry run)
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
run: |
npx --yes -p @semantic-release/exec -p @semantic-release/github -p @semantic-release/changelog -p @semantic-release/git -p @semantic-release/commit-analyzer -p @semantic-release/release-notes-generator semantic-release --dry-run
- name: Execute Gradle build
run: ./gradlew build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: build
path: ./miw/build
if-no-files-found: error
retention-days: 1
- name: Upload Helm chart artifact
uses: actions/upload-artifact@v4
with:
name: charts
path: ./charts
if-no-files-found: error
retention-days: 1
- name: Report semantic-release outputs
run: |
echo "::notice::${{ env.next_release }}"
echo "::notice::${{ env.will_create_new_release }}"
- name: Upload jar to GitHub release
if: github.event_name != 'pull_request' && steps.semantic-release.outputs.will_create_new_release == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ steps.semantic-release.outputs.next_release }}
run: |
echo "::notice::Uploading jar to GitHub release"
gh release upload "v$RELEASE_VERSION" ./miw/build/libs/miw-latest.jar
docker:
name: Docker Release
needs: semantic_release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build
path: ./miw/build
- name: Download Helm chart artifact
uses: actions/download-artifact@v4
with:
name: charts
path: ./charts
# Create SemVer or ref tags dependent of trigger event
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}
# Automatically prepare image tags; See action docs for more examples.
# semver patter will generate tags like these for example :1 :1.2 :1.2.3
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{ needs.semantic_release.outputs.next_release }}
type=semver,pattern={{major}},value=${{ needs.semantic_release.outputs.next_release }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.semantic_release.outputs.next_release }}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: DockerHub login
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
# Use existing DockerHub credentials present as secrets
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Push image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./miw/Dockerfile
# https://github.com/peter-evans/dockerhub-description
# Important step to push image description to DockerHub
- name: Update Docker Hub description
if: github.event_name != 'pull_request'
uses: peter-evans/dockerhub-description@v3
with:
# readme-filepath defaults to toplevel README.md, Only necessary if you have a dedicated file with your 'Notice for docker images'
readme-filepath: Docker-hub-notice.md
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
repository: ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}
helm:
name: Helm Release
needs: semantic_release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Helm chart artifact
uses: actions/download-artifact@v4
with:
name: charts
path: ./charts
- name: Install Helm
uses: azure/[email protected]
- name: Add Helm dependency repositories
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Release chart
if: github.event_name != 'pull_request' && needs.semantic_release.outputs.will_create_new_release == 'true'
run: |
# Package MIW chart
helm_package_path=$(helm package -u -d helm-charts ./charts/managed-identity-wallet | grep -o 'to: .*' | cut -d' ' -f2-)
echo "HELM_PACKAGE_PATH=$helm_package_path" >> $GITHUB_ENV
# Commit and push to gh-pages
git add helm-charts
git stash -- helm-charts
git reset --hard
git fetch origin
git checkout gh-pages
git stash pop
# Generate helm repo index.yaml
helm repo index . --merge index.yaml --url https://${GITHUB_REPOSITORY_OWNER}.github.io/${GITHUB_REPOSITORY#*/}/
git add index.yaml
git commit -s -m "Release ${{ needs.semantic_release.outputs.next_release }}"
git push origin gh-pages
- name: Upload chart to GitHub release
if: github.event_name != 'pull_request' && needs.semantic_release.outputs.will_create_new_release == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ needs.semantic_release.outputs.next_release }}
HELM_PACKAGE_PATH: ${{ env.HELM_PACKAGE_PATH }}
run: |
echo "::notice::Uploading chart to GitHub release"
gh release upload "v$RELEASE_VERSION" "$HELM_PACKAGE_PATH"