Skip to content

Commit ab46b8f

Browse files
committed
[CI] Upload the manifest script...
1 parent 7e3a8bb commit ab46b8f

File tree

2 files changed

+48
-50
lines changed

2 files changed

+48
-50
lines changed

.github/workflows/_announce-latest-nightly.yml

Lines changed: 25 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,23 @@ jobs:
1515
name: Get Latest Package Info
1616
runs-on: ubuntu-22.04
1717
outputs:
18+
jarFile: ${{ fromJson(steps.info.outputs.latestJson)[0].name }}
1819
version: ${{ steps.download-info.outputs.version }}
20+
mcVersion: ${{steps.minecraft.outputs.prop}}
21+
neoVersion: ${{steps.neoforge.outputs.prop}}
22+
1923
steps:
24+
- name: Set up JDK
25+
uses: actions/setup-java@v4
26+
with:
27+
distribution: temurin
28+
java-version: 21
29+
30+
- name: Setup Groovy
31+
uses: wtfjoke/setup-groovy@v2
32+
with:
33+
groovy-version: '4.x'
34+
2035
- name: Download Package Info
2136
id: download-info
2237
uses: compactmods/[email protected]
@@ -42,49 +57,7 @@ jobs:
4257
run: |
4358
mkdir release
4459
curl -L "${{ fromJson(steps.info.outputs.latestJson)[0].url }}" -o "release/${{ fromJson(steps.info.outputs.latestJson)[0].name}}"
45-
mv compactmachines-nightly.json release/compactmachines-nightly.json
46-
47-
- name: Add Artifact
48-
uses: actions/upload-artifact@v4
49-
with:
50-
name: release
51-
path: release
52-
53-
vars:
54-
name: Get Variables
55-
runs-on: ubuntu-22.04
56-
needs: [get-package-info]
57-
outputs:
58-
jarFile: ${{ fromJson(steps.info.outputs.latestJson)[0].name}}
59-
mcVersion: ${{steps.minecraft.outputs.prop}}
60-
neoVersion: ${{steps.neoforge.outputs.prop}}
61-
62-
steps:
63-
- name: Checkout
64-
uses: actions/checkout@v4
65-
with:
66-
fetch-depth: 0
67-
68-
- name: Grab JAR and Info
69-
uses: actions/download-artifact@v4
70-
with:
71-
name: release
72-
path: .
73-
74-
- name: Read info into variable [latest]
75-
id: info
76-
run: echo "latestJson=$(cat compactmachines-nightly.json)" >> $GITHUB_OUTPUT
77-
78-
- name: Set up JDK
79-
uses: actions/setup-java@v4
80-
with:
81-
distribution: temurin
82-
java-version: 21
83-
84-
- name: Setup Groovy
85-
uses: wtfjoke/setup-groovy@v2
86-
with:
87-
groovy-version: '4.x'
60+
mv compactmachines-nightly.json release/compactmachines-nightly.json
8861
8962
- name: MC Version
9063
id: minecraft
@@ -94,9 +67,15 @@ jobs:
9467
id: neoforge
9568
run: groovy read-manifest.groovy ${{ fromJson(steps.info.outputs.latestJson)[0].name}} "NeoForge-Version" >> "$GITHUB_OUTPUT"
9669

70+
- name: Add Artifact
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: release
74+
path: release
75+
9776
announce:
9877
name: Discord Announcement
99-
needs: [ vars, get-package-info ]
78+
needs: [ get-package-info ]
10079
runs-on: ubuntu-22.04
10180
steps:
10281
- name: Grab JAR and Info
@@ -105,18 +84,14 @@ jobs:
10584
name: release
10685
path: .
10786

108-
- name: Read info into variable [latest]
109-
id: info
110-
run: echo "latestJson=$(cat compactmachines-nightly.json)" >> $GITHUB_OUTPUT
111-
11287
- name: Announce Release
11388
uses: compactmods/[email protected]
11489
env:
11590
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
11691
with:
117-
filename: ${{ needs.vars.outputs.jarFile }}
92+
filename: ${{ needs.get-package-info.outputs.jarFile }}
11893
channel: ${{ secrets.NIGHTLY_CHANNEL_ID }}
11994
modName: Compact Machines
12095
modVersion: ${{ needs.get-package-info.outputs.version }}
12196
thumbnail: https://media.forgecdn.net/avatars/10/602/635460270800375500.png
122-
mcVersion: ${{ needs.vars.outputs.mcVersion }}
97+
mcVersion: ${{ needs.get-package-info.outputs.mcVersion }}

read-manifest.groovy

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env groovy
2+
import java.util.jar.Attributes
3+
import java.util.jar.JarFile
4+
import java.util.jar.Manifest
5+
6+
if (args.length < 2)
7+
{
8+
println "USAGE: read-manifest.groovy <jar_filename> <property_name>"
9+
System.exit(-1)
10+
}
11+
12+
var jar = args[0]
13+
var prop = args[1]
14+
15+
var realProp = new Attributes.Name(prop)
16+
17+
JarFile jarFile = new JarFile(jar)
18+
var manifest = jarFile.manifest.getMainAttributes()
19+
20+
if(manifest.containsKey(realProp)) {
21+
var val = manifest.getValue(prop)
22+
println("prop=$val")
23+
}

0 commit comments

Comments
 (0)