-
Notifications
You must be signed in to change notification settings - Fork 21
131 lines (127 loc) · 5.84 KB
/
maven_deploy_snapshot_dev.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
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Make branch snapshot and deploy
on:
push:
branches-ignore:
- main
- 'release/**'
jobs:
publish:
if: github.repository == 'eclipse-store/store'
runs-on: ubuntu-latest
steps:
- id: install-secret-key
name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.ORG_GPG_PRIVATE_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- uses: actions/checkout@v3
- name: Set up Java for publishing to Maven Central Snapshot Repository
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-passphrase: PASSPHRASE
- name: Prepare suffix
run: |
function prepareSuffix() {
local branch=$1
local result=${branch//\//_}
result=${result//#/}
local maxLength=10
if (( ${#result} > maxLength )); then
result=${result:0:maxLength}
fi
local hashFromContent=$(echo -n "$branch" | md5sum | cut -f1 -d" ")
echo "${result}-${hashFromContent:0:10}"
}
suffix=$(prepareSuffix ${GITHUB_REF#refs/heads/})
echo "Suffix: $suffix"
echo "SUFFIX=$suffix" >> $GITHUB_ENV
- name: Update project version
run: |
currentVersion=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
currentVersionWithoutSnapshot=${currentVersion%-SNAPSHOT}
newVersion="${currentVersionWithoutSnapshot}-$SUFFIX-SNAPSHOT"
mvn versions:set -DnewVersion=$newVersion --batch-mode
BRANCH_NAME=${{ github.ref }}
REPO_OWNER="eclipse-serializer"
REPO_NAME="serializer"
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/branches/$BRANCH_NAME)
if [ $RESPONSE -eq 200 ]; then
mvn versions:set-property -Dproperty=eclipse.serializer.version -DnewVersion=$newVersion
else
echo "Branch does not exist in serializer repository, skipping serializer version change"
fi
- name: Make a snapshot
run: mvn -Pdeploy -Pproduction --no-transfer-progress --batch-mode clean deploy -U
env:
MAVEN_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}
#java 17 build
- uses: actions/checkout@v3
- name: Set up Java for publishing to Maven Central Snapshot Repository
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-passphrase: PASSPHRASE
- name: Prepare suffix
run: |
function prepareSuffix() {
local branch=$1
local result=${branch//\//_}
result=${result//#/}
local maxLength=10
if (( ${#result} > maxLength )); then
result=${result:0:maxLength}
fi
local hashFromContent=$(echo -n "$branch" | md5sum | cut -f1 -d" ")
echo "${result}-${hashFromContent:0:10}"
}
suffix=$(prepareSuffix ${GITHUB_REF#refs/heads/})
echo "Suffix: $suffix"
echo "SUFFIX=$suffix" >> $GITHUB_ENV
- name: Update project version java 17
run: |
currentVersion=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
currentVersionWithoutSnapshot=${currentVersion%-SNAPSHOT}
newVersion="${currentVersionWithoutSnapshot}-$SUFFIX-SNAPSHOT"
mvn versions:set -DnewVersion=$newVersion --batch-mode
BRANCH_NAME=${{ github.ref }}
REPO_OWNER="eclipse-serializer"
REPO_NAME="serializer"
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/branches/$BRANCH_NAME)
if [ $RESPONSE -eq 200 ]; then
mvn versions:set-property -Dproperty=eclipse.serializer.version -DnewVersion=$newVersion
else
echo "Branch does not exist in serializer repository, skipping serializer version change"
fi
- name: Make a snapshot java 17
run: |
mvn -pl integrations/spring-boot3 clean install -am -B
mvn -pl integrations/spring-boot3-console clean install -am -B
mvn -P production -pl storage/rest/client-app clean install -am -B
mvn -P production -pl storage/rest/client-app-standalone-assembly clean install -am -B
mvn -P production -pl storage/rest/service-springboot clean install -am -B
- name: Deploy module build with java 17
run: |
mvn -Pdeploy -pl integrations/spring-boot3 deploy
mvn -Pdeploy -pl integrations/spring-boot3-console deploy
mvn -Pdeploy -Pproduction -pl storage/rest/client-app deploy
mvn -Pdeploy -Pproduction -pl storage/rest/client-app-standalone-assembly deploy
mvn -Pdeploy -Pproduction -pl storage/rest/service-springboot deploy
env:
MAVEN_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}