Skip to content

Commit 9a77157

Browse files
committed
Use Github Actions to make releases
1 parent 3b0d7ab commit 9a77157

File tree

2 files changed

+47
-27
lines changed

2 files changed

+47
-27
lines changed

.github/workflows/maven.yml

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
1-
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
8-
9-
name: Java CI with Maven
1+
name: Build and Release JAR
102

113
on:
124
push:
13-
branches: [ "master" ]
14-
pull_request:
15-
branches: [ "master" ]
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: write
1610

1711
jobs:
1812
build:
19-
2013
runs-on: ubuntu-latest
2114

2215
steps:
23-
- uses: actions/checkout@v4
24-
- name: Set up JDK 17
25-
uses: actions/setup-java@v3
26-
with:
27-
java-version: '17'
28-
distribution: 'temurin'
29-
cache: maven
30-
- name: Build with Maven
31-
run: mvn -B package --file pom.xml
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up JDK 8
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'temurin'
23+
java-version: '8'
24+
25+
- name: Build with Maven
26+
run: mvn clean package
3227

33-
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
34-
- name: Update dependency graph
35-
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
28+
- name: Create Release
29+
uses: softprops/action-gh-release@v2
30+
with:
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
files: target/UnityPackageViewer-*.jar

pom.xml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</properties>
1313

1414
<dependencies>
15-
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress -->
15+
<!-- Only dependency is Apache Commons Compress to read .tar files -->
1616
<dependency>
1717
<groupId>org.apache.commons</groupId>
1818
<artifactId>commons-compress</artifactId>
@@ -21,18 +21,35 @@
2121
</dependencies>
2222

2323
<build>
24+
25+
<!-- Just put everything in the .jar so it can be distributed as a single file -->
2426
<resources>
27+
<!-- Default resources location -->
2528
<resource><directory>src/main/resources</directory></resource>
29+
30+
<!-- Include the source code in the .jar -->
2631
<resource><directory>src/main/java</directory></resource>
32+
33+
<!--
34+
Include files in src/main/misc/ in the .jar, but also filter them
35+
(primarily to put the app version as a property for the app to use)
36+
-->
2737
<resource>
2838
<directory>src/main/misc</directory>
2939
<filtering>true</filtering>
3040
</resource>
41+
42+
<!-- Include the licence file in the .jar -->
3143
<resource>
3244
<directory>.</directory>
3345
<includes><include>LICENSE.txt</include></includes>
3446
</resource>
3547
</resources>
48+
49+
<!--
50+
Use the Maven Shade plugin to strip out all unused classes
51+
and turn everything into a single fat jar.
52+
-->
3653
<plugins>
3754
<plugin>
3855
<groupId>org.apache.maven.plugins</groupId>
@@ -48,7 +65,10 @@
4865
<finalName>UnityPackageViewer-${project.version}</finalName>
4966
<minimizeJar>true</minimizeJar>
5067

51-
<!-- Choose my MANIFEST.MF as the winner -->
68+
<!--
69+
Apache Compress .jar also has its own MANIFEST.MF file.
70+
Choose my MANIFEST.MF as the winner
71+
-->
5272
<filters>
5373
<filter>
5474
<artifact>${project.groupId}:${project.artifactId}</artifact>
@@ -65,8 +85,11 @@
6585
</filters>
6686

6787
<transformers>
88+
<!--Prevents license duplication -->
6889
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
90+
<!-- Prepares merged NOTICE -->
6991
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer"/>
92+
<!--Set the main class in the MANIFEST -->
7093
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
7194
<mainClass>unitypackage.viewer.Main</mainClass>
7295
</transformer>

0 commit comments

Comments
 (0)