forked from MegaMek/megamek
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (74 loc) · 2.9 KB
/
update-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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# This workflow updates the MM Maven Repo on push to master
name: Update Maven Repo
on:
push:
branches: [ master ]
paths:
- 'megamek/src/**'
- 'megamek/i18n/**'
- 'megamek/resources/**'
jobs:
update_maven_repo:
runs-on: ${{ matrix.os }}
# Run this job once for each combination in the matrix below.
strategy:
matrix:
os: [ ubuntu-latest ] # For Maven Repository Update running on *nix is sufficient
java-distribution: [ temurin ]
java-version: [ 17 ]
steps:
# Put the MM repo in a subfolder to make updating the Maven repo easier
- uses: actions/checkout@v3
with:
path: megamek
# Setup the requested Java Distribution and Version from the matrix
- name: Set up ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
distribution: ${{ matrix.java-distribution }}
java-version: ${{ matrix.java-version }}
# Make sure we can execute the Gradle wrapper
- name: Grant execute permission for gradlew (*nix or MacOS)
working-directory: megamek
run: chmod +x gradlew
if: runner.os != 'Windows'
# Create the actual maven repo bits with Gradle
- name: Publish Maven Repo with Gradle
working-directory: megamek
run: ./gradlew publishPublishMMLibraryPublicationToMavenRepository
# Get the current Maven repo contents
- name: Checkout Maven Repo
if: github.repository == 'MegaMek/megamek'
uses: actions/checkout@v3
with:
repository: MegaMek/mavenrepo
path: mavenrepo
# Create an update
- name: Copy Maven Outputs to Repo
if: github.repository == 'MegaMek/megamek'
working-directory: megamek/megamek/build/mavenrepo/
run: |
cp -r . ../../../../mavenrepo/
# In case we run into an issue, use git status to help us understand what happened.
- name: Inspect git status output
if: github.repository == 'MegaMek/megamek'
working-directory: mavenrepo
run: |
git status
# Add the changes under the username and email of the user who pushed the code
- name: Commit changes to the Maven Repo
if: github.repository == 'MegaMek/megamek'
working-directory: mavenrepo
run: |
git add .
git config user.email ${{ github.event.pusher.email }}
git config user.name ${{ github.event.pusher.name }}
git commit -m "MegaMek ${{ github.event.after }}" -m "${{ github.event.compare }}"
# Use an SSH deploy key (with write privs) to update the maven repo
- name: Setup SSH and Push changes to the Maven Repo
if: github.repository == 'MegaMek/megamek'
working-directory: mavenrepo
run: |
eval "$(ssh-agent -s)"
ssh-add - <<< "${{ secrets.MAVEN_REPO_DEPLOY_KEY }}"
git push "git@github.com:MegaMek/mavenrepo.git" HEAD:master