-
-
Notifications
You must be signed in to change notification settings - Fork 3
147 lines (127 loc) · 5.66 KB
/
maven.yaml
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
141
142
143
144
145
146
147
# This is a basic workflow to help you get started with Actions
name: CI_MAVEN
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
workflow_run:
workflows: ["CI_BUILD", "CI_WEEKLYBUILD"]
branches: [master]
types:
- completed
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
check:
name: Check changed files
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
run_job: ${{ steps.check_files.outputs.run_job || steps.check_nightly_commit.outputs.run_job }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: check files
if: ${{ github.event.workflow.name == 'CI_BUILD' }}
id: check_files
run: |
echo "=============== list changed files ==============="
git diff --name-only HEAD^ HEAD
echo "run_job=false" >> $GITHUB_OUTPUT
echo "========== check paths of changed files =========="
git diff --name-only HEAD^ HEAD > files.txt
while IFS= read -r file
do
echo $file
if [[ $file == ".github/workflows/maven.yaml"* ]]; then
echo "Recreate Maven was requested"
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
if [[ $file == "netreflected/"* ]]; then
echo "This file is under the directory 'netreflected/'."
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
echo "This files are not in a source directory no action required"
done < files.txt
- name: check last nightly commit
if: ${{ github.event.workflow.name == 'CI_WEEKLYBUILD' }}
id: check_nightly_commit
run: |
echo "run_job=false" >> $GITHUB_OUTPUT
echo "========== check commits of changes =========="
git log -1 --pretty=%B HEAD^ HEAD > commit_message.txt
while IFS= read -r comment
do
echo $comment
if [[ $file == "Update sources after nightly build check"* ]]; then
echo "Nighly builds generated siomething"
echo "run_job=true" >> $GITHUB_OUTPUT
break
fi
done < commit_message.txt
# This workflow contains a single job called "build"
build_maven:
needs: check
if: needs.check.outputs.run_job == 'true'
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: '1'
submodules: 'true'
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Install .NET SDKs
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Compile to get local resources
run: dotnet build --no-incremental --configuration Release /p:Platform="Any CPU" src/net/NuReflector.sln
- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.MAVEN_GPG_PRIVATE_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Set up Apache Maven Central
uses: actions/setup-java@v1
with: # running setup-java again overwrites the settings.xml
distribution: temurin
java-version: 11
cache: 'maven'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Install local file to be used within Javadoc plugin of generated POM
run: mvn install:install-file -Dfile=./bin/net6.0/JCOBridge.jar -DgroupId=JCOBridge -DartifactId=JCOBridge -Dversion=2.4.14 -Dpackaging=jar -DgeneratePom=true
- name: Extract net6.0 list
run: echo "NET_6_0_FILE_LIST=$(cat ./netreflected/net6.0.list)" >> $GITHUB_ENV
- name: Publish net6.0 to Apache Maven Central
run: for f in $NET_6_0_FILE_LIST; do mvn --file ./netreflected/$f --no-transfer-progress --batch-mode -Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }} deploy; done
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Extract net462 list
run: echo "NET_461_FILE_LIST=$(cat ./netreflected/net462.list)" >> $GITHUB_ENV
- name: Publish net462 to Apache Maven Central
run: for f in $NET_461_FILE_LIST; do mvn --file ./netreflected/$f --no-transfer-progress --batch-mode -Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }} deploy; done
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}