@@ -3,56 +3,51 @@ name: Java CI
3
3
on : [push]
4
4
5
5
jobs :
6
- build :
6
+ prepare :
7
+ runs-on : ubuntu-latest
8
+ outputs :
9
+ DIFF_COMMITS : ${{ steps.prepare_ch.outputs.DIFF_COMMITS }}
10
+
11
+ steps :
12
+ - name : Clone
13
+ uses : actions/checkout@v1
7
14
8
- runs-on : windows-latest
15
+ - name : Prepare commits diff content
16
+ id : prepare_ch
17
+ run : |
18
+ cur_branch="${{ github.ref_name }}"
19
+ git checkout $cur_branch
20
+ git remote add upstream https://github.com/chatty/chatty
21
+ git fetch --all
22
+ git branch $cur_branch --set-upstream-to upstream/master
23
+ status_output=$(git rev-list --count upstream/master..origin/${cur_branch})
24
+ echo "DIFF_COMMITS=$status_output" >> $GITHUB_OUTPUT
9
25
26
+ build :
27
+ needs : prepare
28
+ runs-on : windows-latest
10
29
defaults :
11
30
run :
12
31
shell : cmd
32
+
33
+ outputs :
34
+ new_tag_text : ${{ steps.set_version.outputs.NEW_TAG_TEXT }}
13
35
14
36
steps :
15
- - name : Clone.
37
+ - name : Clone
16
38
uses : actions/checkout@v1
17
39
18
40
- uses : actions/setup-java@main
19
- name : Install Java 17.
41
+ name : Install Java 17
20
42
with :
21
43
distribution : ' adopt'
22
44
java-version : ' 17'
23
- - name : Set up version of Chatty.
24
- run : |
25
- git checkout master
26
- git remote add upstream https://github.com/chatty/chatty
27
- git fetch --all
28
- git branch master --set-upstream-to upstream/master
29
- git status
30
- git status > ch.txt
31
- python version.py
32
- - name : Latest chatty tag.
33
- shell : bash
34
- run : |
35
- curl \
36
- -H "Accept: application/vnd.github.v3+json" \
37
- https://api.github.com/repos/chatty/chatty/releases > latest_chatty.json
38
- - name : Parse JSON.
39
- shell : python
45
+
46
+ - name : Run version.py
40
47
run : |
41
- import json
42
- import os
43
- def writeEnv(key, value):
44
- open(os.environ['GITHUB_ENV'], "a").write(key + '=' + value + '\n');
45
- with open('latest_chatty.json') as json_data:
46
- data = json.load(json_data)[0];
47
- tag_name = str(data['tag_name']);
48
- writeEnv('CHATTY_TAG', tag_name);
49
- tag_text = tag_name.replace('-b', ' Beta ').replace('v', '');
50
- writeEnv('CHATTY_TAG_TEXT', tag_text);
51
- print(tag_name);
52
- print(tag_text);
53
- with open('final_version.txt') as ver_data:
54
- writeEnv('NEW_TAG_TEXT', str(ver_data.read()));
55
- - name : Build with Gradle.
48
+ python version.py "${{ needs.prepare.outputs.DIFF_COMMITS }}"
49
+
50
+ - name : Build with Gradle
56
51
run : |
57
52
gradlew build ^
58
53
&& gradlew release ^
@@ -61,13 +56,139 @@ jobs:
61
56
-PjpackagePath="%java_home%\bin\jpackage.exe" ^
62
57
-PinnosetupPath="%programfiles(x86)%\Inno Setup 6\ISCC.exe" ^
63
58
-PmtPath="%programfiles(x86)%\Windows Kits\10\bin\10.0.22000.0\x64\mt.exe"
64
- - name : Draft release.
59
+
60
+ - name : Upload Windows Artifacts
61
+ uses : actions/upload-artifact@v4.6.2
62
+ with :
63
+ name : windows-artifacts
64
+ path : build/releases/*
65
+
66
+ - name : Get new tag text
67
+ id : set_version
68
+ run : |
69
+ set /p new_tag_text=<final_version.txt
70
+ echo "NEW_TAG_TEXT=%new_tag_text%" >> $GITHUB_OUTPUT
71
+
72
+ build_mac_arm :
73
+ needs : prepare
74
+ runs-on : macos-latest
75
+ defaults :
76
+ run :
77
+ shell : bash
78
+
79
+ steps :
80
+ - name : Clone
81
+ uses : actions/checkout@v1
82
+
83
+ - name : Set up JDK (ARM64)
84
+ uses : actions/setup-java@v3
85
+ with :
86
+ distribution : ' temurin'
87
+ java-version : ' 17'
88
+ architecture : arm64
89
+
90
+ - name : Run version.py
91
+ run : |
92
+ python version.py "${{ needs.prepare.outputs.DIFF_COMMITS }}"
93
+
94
+ - name : Build with Gradle (ARM64)
95
+ run : |
96
+ ./gradlew build && \
97
+ ./gradlew release && \
98
+ ./gradlew releaseMacDmgArm -PjpackagePath=`which jpackage`
99
+
100
+ - name : Upload Mac ARM Artifacts
101
+ uses : actions/upload-artifact@v4.6.2
102
+ with :
103
+ name : mac-arm-artifacts
104
+ path : build/jpackage-mac/*
105
+
106
+ build_mac_intel :
107
+ needs : prepare
108
+ runs-on : macos-latest
109
+ defaults :
110
+ run :
111
+ shell : bash
112
+
113
+ steps :
114
+ - name : Clone
115
+ uses : actions/checkout@v1
116
+
117
+ - name : Set up JDK (x64)
118
+ uses : actions/setup-java@v3
119
+ with :
120
+ distribution : ' temurin'
121
+ java-version : ' 17'
122
+ architecture : x64
123
+
124
+ - name : Run version.py
125
+ run : |
126
+ python version.py "${{ needs.prepare.outputs.DIFF_COMMITS }}"
127
+
128
+ - name : Build with Gradle (x64)
129
+ run : |
130
+ ./gradlew build && \
131
+ ./gradlew release && \
132
+ ./gradlew releaseMacDmgIntel -PjpackagePath=`which jpackage`
133
+
134
+ - name : Upload Mac Intel Artifacts
135
+ uses : actions/upload-artifact@v4.6.2
136
+ with :
137
+ name : mac-intel-artifacts
138
+ path : build/jpackage-mac/*
139
+
140
+ create_release :
141
+ needs : [build, build_mac_arm, build_mac_intel]
142
+ runs-on : ubuntu-latest
143
+
144
+ steps :
145
+ - name : Download Windows Artifacts
146
+ uses : actions/download-artifact@v4.3.0
147
+ with :
148
+ name : windows-artifacts
149
+ path : artifacts/windows
150
+
151
+ - name : Download Mac ARM Artifacts
152
+ uses : actions/download-artifact@v4.3.0
153
+ with :
154
+ name : mac-arm-artifacts
155
+ path : artifacts/mac-arm
156
+
157
+ - name : Download Mac Intel Artifacts
158
+ uses : actions/download-artifact@v4.3.0
159
+ with :
160
+ name : mac-intel-artifacts
161
+ path : artifacts/mac-intel
162
+
163
+ - name : Fetch latest Chatty tag
164
+ id : fetch_tag
165
+ run : |
166
+ curl \
167
+ -H "Accept: application/vnd.github.v3+json" \
168
+ https://api.github.com/repos/chatty/chatty/releases > latest_chatty.json
169
+ tag_name=$(jq -r '.[0].tag_name' latest_chatty.json)
170
+ tag_text=$(echo $tag_name | sed 's/-b/ Beta /' | sed 's/v//')
171
+ echo "CHATTY_TAG=$tag_name" >> $GITHUB_ENV
172
+ echo "CHATTY_TAG_TEXT=$tag_text" >> $GITHUB_ENV
173
+
174
+ # Create release body content
175
+ release_body="
176
+ - Updated version to official [$tag_text](https://github.com/chatty/chatty/releases/tag/$tag_name)."
177
+ echo "$release_body" > release_body.md
178
+ echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV
179
+ echo "$release_body" >> $GITHUB_ENV
180
+ echo "EOF" >> $GITHUB_ENV
181
+
182
+ - name : Create Release
65
183
uses : softprops/action-gh-release@v0.1.15
66
184
with :
67
185
draft : true
68
- files : build/releases/*
69
- tag_name : v${{ env.NEW_TAG_TEXT }}
70
- name : " Chatty Fork ${{ env.NEW_TAG_TEXT }}"
71
- body : " - Updated version to official [${{ env.CHATTY_TAG_TEXT }}](https://github.com/chatty/chatty/releases/tag/${{ env.CHATTY_TAG }})."
186
+ files : |
187
+ artifacts/windows/*
188
+ artifacts/mac-arm/*
189
+ artifacts/mac-intel/*
190
+ tag_name : v${{ needs.build.outputs.new_tag_text }}
191
+ name : " Chatty Fork ${{ needs.build.outputs.new_tag_text }}"
192
+ body : ${{ env.RELEASE_BODY }}
72
193
env :
73
194
GITHUB_TOKEN : ${{ secrets.REPO_TOKEN }}
0 commit comments