generated from hms-networks/sc-java-maven-starter-project
-
Notifications
You must be signed in to change notification settings - Fork 3
70 lines (60 loc) · 2.63 KB
/
release-push-maven-repo.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
# HMS Networks; Americas
# Maven Release Push Action for Maven-based Ewon ETK Project Releases
# Version: 3.0.0
# Date: February 8, 2024
#
# This action is configured to automatically run when a release
# tag is created in the following syntax: `v*`.
name: Release (Push to Maven Repo)
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0
jobs:
push-maven-repo:
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
with:
path: './project'
- name: Set Up JDK
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: 16
cache: 'maven'
- name: Compile Java Files With Maven
run: mvn package -f ./project/pom.xml
- name: Get Maven release information
run: |
echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -f ./project/pom.xml)" >> $GITHUB_ENV
echo "RELEASE_ARTIFACT_ID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout -f ./project/pom.xml)" >> $GITHUB_ENV
- name: Configure Maven Repo deploy key
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.MAVEN_REPO_SSH_PRIVATE_KEY }}
- name: Clone SC Maven repo
uses: actions/checkout@v2
with:
repository: 'hms-networks/sc-java-maven-repo'
fetch-depth: '0'
ref: 'main'
ssh-key: ${{ secrets.MAVEN_REPO_SSH_PRIVATE_KEY }}
path: './mavenRepo'
- name: Add artifacts to SC Maven repo
run: |
cd ./project
mvn install:install-file -Dfile=./target/${{ env.RELEASE_ARTIFACT_ID }}-${{ env.RELEASE_VERSION }}.jar -DpomFile=./pom.xml -Dpackaging=jar -DlocalRepositoryPath=../mavenRepo
mvn install:install-file -Dfile=./target/${{ env.RELEASE_ARTIFACT_ID }}-${{ env.RELEASE_VERSION }}-sources.jar -DpomFile=./pom.xml -Dpackaging=jar -Dclassifier=sources -DlocalRepositoryPath=../mavenRepo
mvn install:install-file -Dfile=./target/${{ env.RELEASE_ARTIFACT_ID }}-${{ env.RELEASE_VERSION }}-javadoc.jar -DpomFile=./pom.xml -Dpackaging=jar -Dclassifier=javadoc -DlocalRepositoryPath=../mavenRepo
cd ../
- name: Commit and Push to SC Maven repo
run: |
cd ./mavenRepo
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Add ${{ env.RELEASE_ARTIFACT_ID }} v${{ env.RELEASE_VERSION }}"
git pull --rebase
git push