-
Notifications
You must be signed in to change notification settings - Fork 54
251 lines (221 loc) · 9.3 KB
/
publish-new-release.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
#################################################################################
# Copyright (c) 2021,2023 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: "Publish new release"
on:
pull_request:
branches:
- releases
- support/*
types:
- closed
jobs:
# Gate: Check release version presence
release-version:
name: Determine release version
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
steps:
- name: Extract version from branch name (for release branches)
if: startsWith(github.event.pull_request.head.ref, 'release/')
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#release/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Extract version from branch name (for hotfix branches)
if: startsWith(github.event.pull_request.head.ref, 'hotfix/')
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#hotfix/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Output release version
id: release-version
run: |
echo "RELEASE_VERSION=${{ env.RELEASE_VERSION }}" >> $GITHUB_OUTPUT
# Release: Maven Artifacts
maven-release:
name: Publish extension's release version to maven repository
needs: [ release-version ]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: github.event.pull_request.merged == true && needs.release-version.outputs.RELEASE_VERSION
steps:
- name: Export RELEASE_VERSION env
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
# Set-Up
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-java
# Import GPG Key
- uses: ./.github/actions/import-gpg-key
name: "Import GPG Key"
with:
gpg-private-key: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
# publish releases
- name: Publish version
env:
OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
OSSRH_USER: ${{ secrets.ORG_OSSRH_USERNAME }}
run: |-
echo "Publishing Version $RELEASE_VERSION to Sonatype/MavenCentral"
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --no-parallel -Pversion=$RELEASE_VERSION -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase="${{ secrets.ORG_GPG_PASSPHRASE }}"
docker-release:
name: Publish Docker images
runs-on: ubuntu-latest
needs: [ release-version ]
permissions:
contents: write
if: github.event.pull_request.merged == true && needs.release-version.outputs.RELEASE_VERSION
strategy:
fail-fast: false
matrix:
variant: [ { dir: edc-controlplane, img: edc-runtime-memory },
{ dir: edc-controlplane, img: edc-controlplane-postgresql-hashicorp-vault },
{ dir: edc-controlplane, img: edc-controlplane-postgresql-azure-vault },
{ dir: edc-dataplane, img: edc-dataplane-azure-vault },
{ dir: edc-dataplane, img: edc-dataplane-hashicorp-vault } ]
steps:
- uses: actions/checkout@v4
- name: Export RELEASE_VERSION env
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
- uses: ./.github/actions/publish-docker-image
name: Publish ${{ matrix.variant.img }}
with:
docker_tag: ${{ env.RELEASE_VERSION }}
rootDir: ${{ matrix.variant.dir }}/${{ matrix.variant.img }}
imagename: ${{ matrix.variant.img }}
docker_user: ${{ secrets.DOCKER_HUB_USER }}
docker_token: ${{ secrets.DOCKER_HUB_TOKEN }}
do_push: 'true'
# Release: Helm Charts
helm-release:
name: Publish new helm release
needs: [ release-version ]
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
pages: write
if: github.event.pull_request.merged == true && needs.release-version.outputs.RELEASE_VERSION
steps:
- name: Export RELEASE_VERSION env
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Helm
uses: azure/[email protected]
with:
version: v3.8.1
- name: Package helm, update index.yaml and push to gh-pages
run: |
# Prepare git env
git config user.name "eclipse-tractusx-bot"
git config user.email "[email protected]"
# Package all charts
find charts -name Chart.yaml -not -path "./edc-tests/*" | xargs -n1 dirname | xargs -n1 helm package -u -d helm-charts
git checkout gh-pages || git checkout -b gh-pages
git pull --rebase origin gh-pages
# Generate helm repo index.yaml
helm repo index . --merge index.yaml --url https://${GITHUB_REPOSITORY_OWNER}.github.io/${GITHUB_REPOSITORY#*/}/
# Commit and push to gh-pages
git add index.yaml helm-charts
git commit -s -m "Release ${{ env.RELEASE_VERSION }}"
git push origin gh-pages
# Release: GitHub tag & release; Merges back releases into main; Starts a new development cycle;
github-release:
name: Publish new github release
needs: [ release-version, maven-release, docker-release, helm-release ]
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
pages: write
pull-requests: write
if: github.event.pull_request.merged == true && needs.release-version.outputs.RELEASE_VERSION
steps:
- name: Export RELEASE_VERSION env
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
# 0 to fetch the full history due to upcoming merge of releases into main branch
fetch-depth: 0
- name: Create Release Tag
id: create_release_tag
run: |
# Prepare git env
git config user.name "eclipse-tractusx-bot"
git config user.email "[email protected]"
# informative
git branch -a
git tag
# Create & push tag
git tag --force ${{ env.RELEASE_VERSION }}
git push --force origin ${{ env.RELEASE_VERSION }}
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
tag: ${{ env.RELEASE_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
makeLatest: true
removeArtifacts: true
- uses: ./.github/actions/setup-java
- name: Merge releases back into main and set new snapshot version
if: github.event.pull_request.base.ref == 'releases'
run: |
# Prepare git env
git config user.name "eclipse-tractusx-bot"
git config user.email "[email protected]"
# Merge releases into main
git checkout main && git merge -X theirs releases --no-commit --no-ff
# Extract release version
IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<"${{ env.RELEASE_VERSION }}"
INC=0
# Compute new snapshot version, do not increment snapshot on non-final releases, e.g. -rc1
if [ -z $SNAPSHOT ]; then
# snapshot
echo "${{ env.RELEASE_VERSION }} is a final release version, increase patch for next snapshot"
INC=1
else
echo "${{ env.RELEASE_VERSION }} is not a final release version (contains \"$SNAPSHOT\"), will not increase patch"
fi
VERSION="$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$((RELEASE_VERSION_PATCH+$INC))-SNAPSHOT"
SNAPSHOT_VERSION=$VERSION
# Persist the "version" in the gradle.properties
sed -i "s/version=.*/version=$SNAPSHOT_VERSION/g" gradle.properties
# Commit and push to origin main
git add gradle.properties
git commit --message "Introduce new snapshot version $SNAPSHOT_VERSION"
git push origin main
publish-to-swaggerhub:
name: "Publish OpenAPI spec to Swaggerhub"
permissions:
contents: read
needs: [ release-version ]
uses: ./.github/workflows/publish-swaggerhub.yaml
with:
downstream-version: ${{ needs.release-version.outputs.RELEASE_VERSION }}
secrets: inherit