-
Notifications
You must be signed in to change notification settings - Fork 4
63 lines (54 loc) · 1.84 KB
/
build-java-sdk.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
---
name: Build java sdk
on:
workflow_dispatch:
inputs:
branch:
description: 'The branch checkout'
required: false
type: string
default: 'main'
jobs:
java-sdk-release:
name: Build java sdk and publish to GitHub Packages
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Get the current version
id: vars
run: |
git log -n 5
COMMIT_HASH_SHORT=$(git rev-parse --short HEAD)
echo $COMMIT_HASH_SHORT
CURRENT_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
echo $CURRENT_VERSION
JAVA_SDK_VERSION=$CURRENT_VERSION-$COMMIT_HASH_SHORT
echo "java-sdk-version=$JAVA_SDK_VERSION" >> $GITHUB_OUTPUT
- name: Bump version in pom.xml files
run: |
echo "java-sdk-version: ${{ steps.vars.outputs.java-sdk-version }}"
./mvnw -q versions:set -DnewVersion=${{ steps.vars.outputs.java-sdk-version }} -DprocessAllModules
- name: Build and publish SDK
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: |
./mvnw -B deploy -DskipTests