Skip to content

Commit 5943f12

Browse files
aalmiraygunnarmorling
authored andcommitted
👷 #6 Add release configuration and workflows
1 parent 5fcf3bb commit 5943f12

File tree

4 files changed

+206
-2
lines changed

4 files changed

+206
-2
lines changed

.github/workflows/maven.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ jobs:
4545
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
4646
restore-keys: ${{ runner.os }}-m2
4747

48-
- name: 'Build example service'
49-
run: mvn -B clean verify
48+
- name: 'Build'
49+
run: mvn --no-transfer-progress -B --file pom.xml verify

.github/workflows/release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#
2+
# Copyright 2021 The original authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
name: Release
18+
19+
on:
20+
push:
21+
tags:
22+
- v*
23+
24+
jobs:
25+
release:
26+
name: Release
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Version
31+
id: version
32+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}
33+
34+
- name: Checkout
35+
uses: actions/checkout@v2
36+
with:
37+
fetch-depth: 0
38+
39+
- name: Cache Maven
40+
uses: actions/cache@v2
41+
with:
42+
path: ~/.m2/repository
43+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
44+
restore-keys: ${{ runner.os }}-m2
45+
46+
- name: Setup Java
47+
uses: actions/setup-java@v2
48+
with:
49+
java-version: 17
50+
distribution: 'zulu'
51+
server-id: central
52+
server-username: MAVEN_USERNAME
53+
server-password: MAVEN_CENTRAL_TOKEN
54+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
55+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
56+
57+
- name: Release
58+
env:
59+
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
60+
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
61+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
62+
run: |
63+
export GPG_TTY=$(tty)
64+
export MAVEN_OPTS=--illegal-access=permit
65+
mvn --no-transfer-progress -B --file pom.xml \
66+
-Drepository.url=https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git \
67+
-Dmaven.site.skip=true -Drelease=true deploy
68+
69+
- name: Release to GitHub
70+
env:
71+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
run: |
73+
mvn -B --file pom.xml -pl :ossquickstart-aggregator -Pjreleaser jreleaser:release

.github/workflows/trigger.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#
2+
# Copyright 2021 The original authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
name: Trigger
18+
19+
on:
20+
workflow_dispatch:
21+
inputs:
22+
branch:
23+
description: "Branch to release from"
24+
required: true
25+
default: "main"
26+
version:
27+
description: "Release version"
28+
required: true
29+
30+
jobs:
31+
build:
32+
name: Build
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v2
38+
39+
- name: Setup Java
40+
uses: actions/setup-java@v2
41+
with:
42+
java-version: 17
43+
distribution: 'zulu'
44+
45+
- name: Cache Maven
46+
uses: actions/cache@v2
47+
with:
48+
path: ~/.m2
49+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
50+
restore-keys: ${{ runner.os }}-m2
51+
52+
- name: Build
53+
run: mvn --no-transfer-progress -B --file pom.xml verify
54+
55+
tag:
56+
name: Tag
57+
needs: build
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- name: Checkout sources
62+
uses: actions/checkout@v2
63+
with:
64+
# required for triggering release workflow on tagging
65+
token: ${{ secrets.GIT_ACCESS_TOKEN }}
66+
67+
- name: Setup Java
68+
uses: actions/setup-java@v2
69+
with:
70+
java-version: 17
71+
distribution: 'zulu'
72+
73+
- name: Cache Maven
74+
uses: actions/cache@v2
75+
with:
76+
path: ~/.m2
77+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
78+
restore-keys: ${{ runner.os }}-m2
79+
80+
- name: Create tag
81+
run: |
82+
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
83+
BRANCH=${{ github.event.inputs.branch }}
84+
VERSION=${{ github.event.inputs.version }}
85+
echo "Releasing $VERSION from $BRANCH branch"
86+
git checkout $BRANCH
87+
mvn -B versions:set versions:commit -DnewVersion=$VERSION
88+
git config --global user.email "[email protected]"
89+
git config --global user.name "moditect-release-bot"
90+
git commit -a -m "Releasing version $VERSION"
91+
git tag v$VERSION
92+
git push origin $BRANCH
93+
git push origin v$VERSION

pom.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,42 @@
159159
<modules>
160160
<module>oss-quickstart-archetype-simple</module>
161161
</modules>
162+
163+
<profiles>
164+
<profile>
165+
<id>jreleaser</id>
166+
<build>
167+
<plugins>
168+
<plugin>
169+
<groupId>org.jreleaser</groupId>
170+
<artifactId>jreleaser-maven-plugin</artifactId>
171+
<version>0.9.0</version>
172+
<inherited>false</inherited>
173+
<configuration>
174+
<jreleaser>
175+
<release>
176+
<github>
177+
<skipTag>true</skipTag>
178+
<changelog>
179+
<formatted>ALWAYS</formatted>
180+
<format>- {{commitShortHash}} {{commitTitle}}</format>
181+
<contributors>
182+
<format>* {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}</format>
183+
</contributors>
184+
<hide>
185+
<contributors>
186+
<contributor>GitHub</contributor>
187+
<contributor>bot</contributor>
188+
</contributors>
189+
</hide>
190+
</changelog>
191+
</github>
192+
</release>
193+
</jreleaser>
194+
</configuration>
195+
</plugin>
196+
</plugins>
197+
</build>
198+
</profile>
199+
</profiles>
162200
</project>

0 commit comments

Comments
 (0)