-
Notifications
You must be signed in to change notification settings - Fork 3
176 lines (162 loc) · 5.58 KB
/
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
name: Release
on:
push:
tags:
- 'v1.*.*'
workflow_dispatch:
inputs:
skipPublish:
description: 'Skip publishing docker images?'
required: true
default: true
type: boolean
tag:
description: 'Custom release tag value.'
required: true
type: string
# global env vars, available in all jobs and steps
env:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
MAVEN_OPTS: '-Xmx4g'
jobs:
# resolves tag value
# outputs the resolved release tag value in the release-tag output var
resolve-tag:
name: Resolve tag
runs-on: ubuntu-latest
outputs:
release-tag: ${{ steps.resolve_tag.outputs.tag }}
steps:
- uses: actions/checkout@v3
- name: Set reference
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Resolve tag
id: resolve_tag
run: |
TAG=${{ inputs.tag != null && inputs.tag || steps.vars.outputs.tag }}
echo "Resolved tag for the release $TAG"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
# creates a new release if it's not existing
# outputs the upload URL in the release-upload-url output var
create-release:
name: Create release
needs: resolve-tag
runs-on: ubuntu-latest
outputs:
release-upload-url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{needs.resolve-tag.outputs.release-tag}}
release_name: Release ${{needs.resolve-tag.outputs.release-tag}}
draft: false
prerelease: true
# publishes the docker image
publish-docker:
name: Publish docker image
needs: resolve-tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: maven
- run: echo "JAVA_17=$JAVA_HOME" >> $GITHUB_ENV
- name: Setup Maven
run: |
mkdir -p ~/.m2
cat <<EOF > ~/.m2/settings.xml
<settings>
<servers>
<server>
<id>artifactory-snapshots</id>
<username>${ARTIFACTORY_USERNAME}</username>
<password>${ARTIFACTORY_PASSWORD}</password>
</server>
<server>
<id>artifactory-releases</id>
<username>${ARTIFACTORY_USERNAME}</username>
<password>${ARTIFACTORY_PASSWORD}</password>
</server>
</servers>
</settings>
EOF
- name: Install APIs
run: |
JAVA_HOME=$JAVA_17 ./mvnw -B -ntp versions:set -DremoveSnapshot versions:commit
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# build and push images to Docker hub
# if input.skipPublish is true we are still having tasks for building images without push
# this enables build docker check without pushing
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push
if: ${{ !inputs.skipPublish }}
run: |
JAVA_HOME=$JAVA_17 ./mvnw -B -ntp clean package -DskipTests -Dquarkus.container-image.build=true -Dquarkus.container-image.push=true -Dquarkus.container-image.tag=${{needs.resolve-tag.outputs.release-tag}}
- name: Build without push
if: ${{ inputs.skipPublish }}
run: |
JAVA_HOME=$JAVA_17 ./mvnw -B -ntp clean package -DskipTests -Dquarkus.container-image.build=true -Dquarkus.container-image.tag=${{needs.resolve-tag.outputs.release-tag}}
# creates a PR for bumping the versions to the next snapshot
# only executed if we have created the new release
create-pr:
name: Version upgrade PR
needs: [create-release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: maven
- name: Setup Maven
run: |
mkdir -p ~/.m2
cat <<EOF > ~/.m2/settings.xml
<settings>
<servers>
<server>
<id>artifactory-snapshots</id>
<username>${ARTIFACTORY_USERNAME}</username>
<password>${ARTIFACTORY_PASSWORD}</password>
</server>
<server>
<id>artifactory-releases</id>
<username>${ARTIFACTORY_USERNAME}</username>
<password>${ARTIFACTORY_PASSWORD}</password>
</server>
</servers>
</settings>
EOF
- name: Update version numbers
run: |
./mvnw -B -ntp release:update-versions -DautoVersionSubmodules=true versions:commit
./mvnw -B -ntp xml-format:xml-format fmt:format
- name: Rev Version
if: success()
uses: peter-evans/create-pull-request@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit-message: "Bumping version for next release"
title: "Bumping version for next release"
branch-suffix: "short-commit-hash"
base: "main"