-
Notifications
You must be signed in to change notification settings - Fork 23
53 lines (45 loc) · 1.87 KB
/
deploy-java.yml
File metadata and controls
53 lines (45 loc) · 1.87 KB
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
name: Deploy to GitHub Maven
on:
push:
paths:
- 'integrations/java/pom.xml'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Verify version change
id: get_version
run: |
echo "VERSION=$(mvn -f integrations/java/pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
echo "VERSION: $VERSION"
- name: Check if version changed
id: version_check
run: |
git fetch origin main
LAST_VERSION=$(git show origin/main:integrations/java/pom.xml | grep -m1 '<version>' | sed -E 's/.*<version>([^<]+)<\/version>.*/\1/')
echo "LAST_VERSION: $LAST_VERSION"
if [ -z "$LAST_VERSION" ] || [ "$LAST_VERSION" == "$VERSION" ]; then
echo "Version did not change or no previous version found. Skipping deployment."
exit 0
fi
- name: Build and deploy
if: steps.version_check.outputs.LAST_VERSION != steps.get_version.outputs.VERSION || steps.version_check.outputs.LAST_VERSION == ''
run: |
echo "<settings><servers><server><id>github</id><username>${{ github.actor }}</username><password>${{ github.token }}</password></server></servers></settings>" > ~/.m2/settings.xml
mvn -f integrations/java/pom.xml deploy \
-DskipTests \
-DaltDeploymentRepository=github::default::https://maven.pkg.github.com/${{ github.repository }}