-
Notifications
You must be signed in to change notification settings - Fork 2
140 lines (125 loc) · 5.32 KB
/
openfire-plugin-build.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
132
133
134
135
136
137
138
139
140
# Version 2023-03-05
name: Java CI
on:
workflow_call:
secrets:
IGNITE_REALTIME_MAVEN_USERNAME:
required: true
IGNITE_REALTIME_MAVEN_PASSWORD:
required: true
jobs:
# Sets output variables for the matrix of java versions to be used in the build job
select_java:
runs-on: ubuntu-latest
outputs:
java: ${{ steps.set-java-targets.outputs.java_matrix }}
steps:
# Checkout Repo
- uses: actions/checkout@v3
- name: Locate plugin.xml
id: locate-plugin-xml
run: |
set -e
if [ -f "src/plugin.xml" ]; then
echo "plugin_xml=src/plugin.xml" >> $GITHUB_OUTPUT
elif [ -f "plugin.xml" ]; then
echo "plugin_xml=plugin.xml" >> $GITHUB_OUTPUT
else
echo "FATAL: Could not locate plugin.xml"
exit 1
fi
- name: Read plugin Java versions
id: get-java-version-from-plugin-xml
uses: mavrosxristoforos/[email protected]
with:
xml-file: ${{ steps.locate-plugin-xml.outputs.plugin_xml }}
xpath: '//minJavaVersion'
zero-nodes-action: 'warn'
- name: Read plugin Openfire versions
id: get-openfire-version-from-plugin-xml
uses: mavrosxristoforos/[email protected]
with:
xml-file: ${{ steps.locate-plugin-xml.outputs.plugin_xml }}
xpath: '//minServerVersion'
zero-nodes-action: 'warn'
- name: Set Java Targets
id: set-java-targets
run: |
set -e
if [ "${{steps.get-java-version-from-plugin-xml.outputs.info}}" == "11" ] || [[ "${{steps.get-openfire-version-from-plugin-xml.outputs.info}}" =~ ^4\.8.*$ ]]; then
echo "java_matrix=[11,17]" >> $GITHUB_OUTPUT
else
echo "java_matrix=[8,11,17]" >> $GITHUB_OUTPUT
fi
build:
runs-on: ubuntu-latest
needs: select_java
strategy:
matrix:
java: ${{fromJson(needs.select_java.outputs.java)}}
steps:
# Checkout Repo
- uses: actions/checkout@v3
- id: get-name
name: Fetch package name
uses: mikefarah/yq@master
with:
cmd: yq -p=xml --xml-skip-proc-inst '.project.artifactId' pom.xml
# Create a variable with this plugin's name
- id: get-id
name: Compute needed variables
run: |
set -x -e
id=${{ steps.get-name.outputs.result }}
echo "id=$id" >> $GITHUB_OUTPUT
echo "id is '$id'"
tag=$(echo ${{ github.ref }} | cut -d '/' -f3)
echo "tag=$tag" >> $GITHUB_OUTPUT
echo "tag is '$tag'"
version=$(echo ${{ github.ref }} | cut -d '/' -f3 | cut -c 2-)
echo "version=$version" >> $GITHUB_OUTPUT
echo "version is '$version'"
rel_id=$(curl -sL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/${{github.repository}}/releases | jq -r --arg TAG "$tag" '.[] | select(.tag_name==$TAG) | .id')
echo "rel_id=$rel_id" >> $GITHUB_OUTPUT
echo "rel_id is '$rel_id'"
- name: Setup JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
- name: Cache Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-java${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-java${{ matrix.java }}-maven-
${{ runner.os }}-
- name: Igniterealtime CI Tooling
run: |
set -e
git clone --depth 1 https://github.com/igniterealtime/ci-tooling.git target/ci-tooling
cp target/ci-tooling/maven-settings-for-openfire-plugins.xml $HOME/.m2/settings.xml
- name: Build with Maven
run: |
set -e
mvn -B package
- name: Conditionally Deploy to Igniterealtime Archiva
id: deploy
if: ${{ contains(github.repository, 'igniterealtime/') && ( ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || contains(github.ref, 'refs/tags/')) && ( matrix.java == '8' || (matrix.java == '11' && needs.select_java.outputs.java == '[11,17]') ) }}
run: |
set -e
mvn -B deploy -Dmaven.resolver.transport=wagon --settings target/ci-tooling/maven-settings-for-openfire-plugins.xml
env:
CI_DEPLOY_USERNAME: ${{ secrets.IGNITE_REALTIME_MAVEN_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.IGNITE_REALTIME_MAVEN_PASSWORD }}
- name: Conditionally Push Artifact to Github Release
uses: actions/upload-release-asset@v1
if: ${{ contains(github.repository, 'igniterealtime/') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && ( matrix.java == '8' || (matrix.java == '11' && needs.select_java.outputs.java == '[11,17]') ) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.get-id.outputs.rel_id }}/assets?name=${{ steps.get-id.outputs.id }}.jar
asset_path: target/${{ steps.get-id.outputs.id }}-openfire-plugin-assembly.jar
asset_name: ${{ steps.get-id.outputs.id }}.jar
asset_content_type: application/java-archive