-
Notifications
You must be signed in to change notification settings - Fork 7
132 lines (119 loc) · 3.85 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
name: Create Release
on:
push:
branches:
- 'release-*'
env:
REGISTRY: ghcr.io
ALTERNATE_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
IMAGE_NAME: ${{ github.repository }}
SONAR_URL: https://sonarcloud.io
SONAR_ORG: grrolland-github
SONAR_PROJECT_KEY: grrolland_ngx-distributed-shm
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Get tag name
id: get_tag_name
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/heads\/release-/}
##
# Perform Maven Release
#
- uses: actions/checkout@v4
with:
ref: master
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: maven
- name: Configure Git user
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- name: Perform Release
run: mvn -B -Dtag=${GITHUB_REF##*release-} release:prepare release:perform
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
##
# Checkout and Build the Tag
#
- uses: actions/checkout@v4
with:
ref: ${{ steps.get_tag_name.outputs.VERSION }}
- name: Build Tag
run: |
mvn clean \
org.jacoco:jacoco-maven-plugin:prepare-agent \
package \
org.jacoco:jacoco-maven-plugin:report \
sonar:sonar \
-B -e -V \
-Dsonar.host.url=$SONAR_URL \
-Dsonar.token=$SONAR_TOKEN \
-Dsonar.organization=$SONAR_ORG \
-Dsonar.projectKey=$SONAR_PROJECT_KEY \
-Dsonar.sources=src/main \
-Dsonar.junit.reportPaths=target/surefire-reports \
-Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
##
# Publish to Github Docker Registry
#
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
${{ steps.get_tag_name.outputs.VERSION }}
latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
##
# Publish to Alternate Docker Registry
#
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.ALTERNATE_REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta_alt
uses: docker/metadata-action@v5
with:
images: ${{ env.ALTERNATE_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
${{ steps.get_tag_name.outputs.VERSION }}
latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta_alt.outputs.tags }}
labels: ${{ steps.meta_alt.outputs.labels }}
##
# Create a Github Release
#
- uses: ncipollo/release-action@v1
with:
body: Release version ${{ steps.get_tag_name.outputs.VERSION }}
tag: ${{ steps.get_tag_name.outputs.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}