-
Notifications
You must be signed in to change notification settings - Fork 61
211 lines (189 loc) · 6.88 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
---
name: "Publish new release"
on:
pull_request:
branches:
- main
- 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 "::set-output name=RELEASE_VERSION::${{ env.RELEASE_VERSION }}"
# 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
-
name: Checkout
uses: actions/checkout@v3.3.0
-
name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '11'
distribution: 'temurin'
cache: 'gradle'
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v5
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Publish release version
run: |
echo "Publishing Version $(grep -e "version" gradle.properties | cut -f2 -d"=") to Github Packages"
./gradlew publishAllPublicationsToGithubPackagesRepository
env:
#REPO: ${{ github.repository }}
REPO: "catenax-ng/product-edc"
GITHUB_PACKAGE_USERNAME: ${{ secrets.TEMP_GHPKG_USER }}
GITHUB_PACKAGE_PASSWORD: ${{ secrets.TEMP_GHPKG_PASSWORD }}
# 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
-
name: Checkout
uses: actions/checkout@v3.3.0
with:
fetch-depth: 0
-
name: Install Helm
uses: azure/setup-helm@v3.5
with:
version: v3.8.1
-
name: Package helm, update index.yaml and push to gh-pages
run: |
# Prepare git env
git config user.name "GitHub actions"
git config user.email noreply@github.com
# 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 main into develop; Starts a new development cycle;
github-release:
name: Publish new github release
needs: [ release-version ]
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
-
name: Checkout
uses: actions/checkout@v3.3.0
with:
# 0 to fetch the full history due to upcoming merge of main into develop branch
fetch-depth: 0
-
name: Create Release Tag
id: create_release_tag
run: |
# Prepare git env
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
# 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
id: create_release
uses: thomaseizinger/create-release@1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target_commitish: ${{ github.event.pull_request.merge_commit_sha }}
tag_name: ${{ env.RELEASE_VERSION }}
name: ${{ env.RELEASE_VERSION }}
draft: false
prerelease: false
-
name: Set up JDK 11
uses: actions/setup-java@v3.11.0
with:
java-version: '11'
distribution: 'temurin'
cache: 'gradle'
-
name: Merge main back into develop and set new snapshot version
if: github.event.pull_request.base.ref == 'main'
run: |
# Prepare git env
git config user.name "GitHub actions"
git config user.email noreply@github.com
# Merge main into develop
git checkout develop && git merge -X theirs main --no-commit --no-ff
# Extract release version
IFS=. read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH<<<"${{ env.RELEASE_VERSION }}"
# Compute new snapshot version
VERSION="$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$((RELEASE_VERSION_PATCH+1))-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 develop
git add gradle.properties
git commit --message "Introduce new snapshot version $SNAPSHOT_VERSION"
git push origin develop