generated from smatechnologies/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 2
159 lines (135 loc) · 5.22 KB
/
ci.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
# Workflow triggering
on:
push:
branches:
- master
tags:
- 'v*'
name: OpCon CLI
jobs:
###########
# PACKAGE #
###########
Job_Package:
runs-on: ubuntu-latest
name: Package
steps:
# Checkout the code
- name: Code checkout
uses: actions/checkout@master
# Prepare the environment with Java 11
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: 11
# Build the maven project, output into ./opcon-cli-dist/
- name: Build
run: mvn clean package
####################################
# Create Windows Distribution File #
####################################
# Download the latest GA OpenJDK JRE 11 from AdoptOpenJDK for Windows x64
- name: Get Java 11 JRE for Windows x64
run: curl -L "https://api.adoptopenjdk.net/v3/binary/latest/11/ga/windows/x64/jre/hotspot/normal/adoptopenjdk" --output java.zip
# Extract Windows JRE
- name: Extract JRE into Java
run: 7z x java.zip -o./opcon-cli-dist/
# Prepare the Windows distribution folder for Zip
- name: Create Windows Folder
run: |
mkdir OpConCLI_Windows
mv opcon-cli-dist/jdk-* OpConCLI_Windows/java
cp opcon-cli-dist/opconcli.exe OpConCLI_Windows/
cp opcon-cli-dist/EncryptValue.exe OpConCLI_Windows/
cp opcon-cli-dist/Connector.config OpConCLI_Windows/
# Zip the folder that contains all binaries and configuration to run on Windows (including Java)
- name: Zip Windows Folder
uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./OpConCLI_Windows.zip ./OpConCLI_Windows
# Upload the OpConCLI_Windows.zip file as artifact
- uses: actions/upload-artifact@v4
with:
name: OpConCLI_Windows.zip
path: ./OpConCLI_Windows.zip
##################################
# Create Linux Distribution File #
##################################
# Download the latest GA OpenJDK JRE 11 from AdoptOpenJDK for Linux x64
- name: Get Java 11 JRE for Linux x64
run: curl -L "https://api.adoptopenjdk.net/v3/binary/latest/11/ga/linux/x64/jre/hotspot/normal/adoptopenjdk" --output java.tar.gz
# Extract Linux JRE
- name: Extract JRE into Java
run: tar xvzf java.tar.gz -C ./opcon-cli-dist
# Prepare the Linux distribution folder for Zip
- name: Create Linux Folder
run: |
mkdir OpConCLI_Linux
mv opcon-cli-dist/jdk-* OpConCLI_Linux/java
chmod a+x opcon-cli-dist/opconcli
cp opcon-cli-dist/opconcli OpConCLI_Linux/
chmod a+x opcon-cli-dist/EncryptValue
cp opcon-cli-dist/EncryptValue OpConCLI_Linux/
cp opcon-cli-dist/Connector.config OpConCLI_Linux/
cp opcon-cli-dist/opcon.command.api.jar OpConCLI_Linux/
# tar.gz the folder that contains all binaries and configuration to run on Linux (including Java)
- name: Zip Linux Folder
run: tar -cvzf ./OpConCLI_Linux.tar.gz ./OpConCLI_Linux
# Upload the OpConCLI_Linux.tar.gz file as artifact
- uses: actions/upload-artifact@v4
with:
name: OpConCLI_Linux.tar.gz
path: ./OpConCLI_Linux.tar.gz
#########################
# RELEASE | TAG CREATED #
#########################
Job_Release:
# Release - only ran when pushing new Tag starting with 'v'
if: startsWith(github.ref, 'refs/tags/v')
name: Release
needs: job_Package
runs-on: ubuntu-latest
steps:
- name: Download Windows Package
uses: actions/download-artifact@v4
with:
name: OpConCLI_Windows.zip
path: ./
- name: Download Linux Package
uses: actions/download-artifact@v4
with:
name: OpConCLI_Linux.tar.gz
path: ./
# Create a new release out of the Tag being pushed
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
# Upload the Windows Zip distribution to the newly created Release
- name: Upload Windows Release Asset
id: upload_release_asset_win
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: OpConCLI_Windows.zip
asset_name: OpConCLI_Windows.zip
asset_content_type: application/zip
# Upload the Windows Zip distribution to the newly created Release
- name: Upload Linux Release Asset
id: upload_release_asset_linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: OpConCLI_Linux.tar.gz
asset_name: OpConCLI_Linux.tar.gz
asset_content_type: application/gzip