-
Notifications
You must be signed in to change notification settings - Fork 30
168 lines (148 loc) · 5.73 KB
/
release_with_jars.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Create release (draft)
# Workflow is triggered when any pom-file is updated in master-branch
# If both pom-files have the same version number it
# - builds NeqSim-jars both in Java 8 and Java 11
# - creates a new release and uploads the jars as artifacts
# - makes a new branch in neqsimpython and updates the jar-files used there.
on:
workflow_dispatch:
push:
branches:
- master
- main
- release/*
paths:
- 'pom*.xml'
jobs:
get_versions:
name: Get version numbers from pom-files
runs-on: ubuntu-latest
outputs:
version_8: ${{ steps.java-8-fix.outputs.version }}
version: ${{ steps.java.outputs.version }}
steps:
- name: Check out neqsim java project
uses: actions/checkout@v4
- name: Get version number for pomJava8.xml
id: java-8
uses: JActions/[email protected]
with:
pom: ./pomJava8.xml
- name: Get version number for pom.xml
id: java
uses: JActions/[email protected]
with:
pom: ./pom.xml
- name: Fix java 8 version number
id: java-8-fix
run: echo "version=$(echo ${{ steps.java-8.outputs.version }} | cut -f 1 -d "-")" >> $GITHUB_OUTPUT
compile_java_8:
name: Build Neqsim ${{ needs.get_versions.outputs.version_8 }} with java 8
needs: get_versions
if: ${{ needs.get_versions.outputs.version_8 == needs.get_versions.outputs.version }}
runs-on: ubuntu-latest
steps:
- name: Check out neqsim java project
uses: actions/checkout@v4
- name: Set up JDK 8 environment
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
- name: Build java 8 version of Neqsim ${{ needs.get_versions.outputs.version_8 }} with Maven
run: mvn -B package --file pomJava8.xml
- name: Copy jar file to staging
run: mkdir staging && cp target/neqsim*Java8.jar staging
- uses: actions/upload-artifact@v3
with:
name: jarfiles
path: staging
compile_java_11:
name: Build Neqsim ${{ needs.get_versions.outputs.version }} with java 11
needs: get_versions
if: ${{ needs.get_versions.outputs.version_8 == needs.get_versions.outputs.version }}
runs-on: ubuntu-latest
steps:
- name: Check out neqsim java project
uses: actions/checkout@v4
- name: Set up JDK 11 environment
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: Build java 11 version with Maven
run: mvn -B package --file pom.xml
- name: Copy jar file to staging
run: mkdir staging && cp target/neqsim*.jar staging
- uses: actions/upload-artifact@v3
with:
name: jarfiles
path: staging
compile_java_21:
name: Build Neqsim ${{ needs.get_versions.outputs.version }} with java 21
needs: get_versions
if: ${{ needs.get_versions.outputs.version_8 == needs.get_versions.outputs.version }}
runs-on: ubuntu-latest
steps:
- name: Check out neqsim java project
uses: actions/checkout@v4
- name: Set up JDK 21 environment
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'maven'
- name: Build java 21 version with Maven
run: mvn -B package --file pomJava21.xml
- name: Rename files
run: cd target && find . -type f -name "neqsim-*.jar" -exec sh -c 'mv -f $0 ${0%.jar}-Java21.jar' {} \; && cd ..
- name: Copy jar file to staging
run: mkdir staging && cp target/neqsim*Java21.jar staging
- uses: actions/upload-artifact@v3
with:
name: jarfiles
path: staging
create_release:
name: Create release v${{ needs.get_versions.outputs.version_8 }}
runs-on: ubuntu-latest
needs: [get_versions, compile_java_8, compile_java_11]
steps:
- name: Download jar files from artifacts
uses: actions/[email protected]
with:
name: jarfiles
- name: Create release v${{ needs.get_versions.outputs.version_8 }}
uses: ncipollo/[email protected]
with:
name: NeqSim ${{ needs.get_versions.outputs.version_8 }}
tag: v${{ needs.get_versions.outputs.version_8 }}
draft: true
generateReleaseNotes: true
skipIfReleaseExists: true
artifactErrorsFailBuild: true
artifacts: "*.jar"
artifactContentType: application/java-archive
# # Needs to delete the old jars manually
# - run: mkdir lib && cp *.jar lib/
# - run: cd lib && mkdir libj8 && mv *Java8.jar libj8/ && cd ..
# - name: Create release branch in neqsimpython repo
# uses: GuillaumeFalourd/[email protected]
# with:
# repository_owner: Equinor
# repository_name: neqsimpython
# new_branch_name: NeqSim-jars-updated-${{ needs.get_versions.outputs.version_8 }}
# ssh_deploy_key: ${{ secrets.SSH_DEPLOY_KEY }}
# - name: Push directory to another repository
# uses: cpina/[email protected]
# env:
# SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
# with:
# source-directory: 'lib'
# destination-github-username: 'equinor'
# destination-repository-name: 'neqsimpython'
# user-email: [email protected]
# target-branch: NeqSim-jars-updated-${{ needs.get_versions.outputs.version_8 }}
# target-directory: neqsim/lib
# commit_message: 'chore: updated jar-files'