Skip to content

Commit d5f758c

Browse files
authored
Merge pull request #1 from devExcale/develop
2 parents ae46073 + 94f6d4f commit d5f758c

42 files changed

Lines changed: 1659 additions & 799 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: PR Validation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK 25
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '25'
21+
distribution: 'temurin'
22+
cache: 'maven'
23+
24+
- name: Run Maven Tests
25+
run: mvn clean test
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Release & Publish
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- master
9+
10+
jobs:
11+
release:
12+
if: github.event.pull_request.merged == true && github.head_ref == 'develop'
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
17+
- name: Checkout master branch
18+
uses: actions/checkout@v4
19+
with:
20+
ref: master
21+
token: ${{ secrets.PAT_TOKEN }}
22+
23+
- name: Set up JDK 25
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: '25'
27+
distribution: 'temurin'
28+
cache: 'maven'
29+
30+
- name: Remove SNAPSHOT from POM
31+
id: bump_version
32+
run: |
33+
mvn versions:set -DremoveSnapshot=true -DgenerateBackupPoms=false
34+
NEW_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
35+
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
36+
37+
- name: Commit and Push to Master
38+
run: |
39+
git config user.name "github-actions[bot]"
40+
git config user.email "github-actions[bot]@users.noreply.github.com"
41+
git commit -am "chore: release version ${{ env.VERSION }}"
42+
git push origin master
43+
44+
- name: Package Application
45+
# Tests are skipped because they already passed in the PR Validation workflow
46+
run: mvn clean package -DskipTests
47+
48+
- name: Publish GitHub Release
49+
uses: softprops/action-gh-release@v2
50+
with:
51+
tag_name: v${{ env.VERSION }}
52+
name: Release v${{ env.VERSION }}
53+
files: target/*.jar
54+
generate_release_notes: true

pom.xml

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,27 @@
77
<parent>
88
<groupId>org.springframework.boot</groupId>
99
<artifactId>spring-boot-starter-parent</artifactId>
10-
<version>2.5.2</version>
10+
<version>4.0.4</version>
1111
<relativePath/>
1212
</parent>
1313

1414
<groupId>ovh.excale</groupId>
1515
<artifactId>vgreeter</artifactId>
16-
<version>2.3.0</version>
16+
<version>26.4.0-SNAPSHOT</version>
1717

1818
<name>VGreeter</name>
1919
<description>Let the bot greet your friends when they join vocal chat on Discord!</description>
2020
<url>https://github.com/devExcale/VGreeter</url>
2121
<packaging>jar</packaging>
2222

23+
<scm>
24+
<connection>scm:git:${project.url}</connection>
25+
</scm>
26+
2327
<properties>
24-
<java.version>1.8</java.version>
25-
<maven.compiler.source>8</maven.compiler.source>
26-
<maven.compiler.target>8</maven.compiler.target>
28+
<java.version>25</java.version>
2729
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
30+
<jdave.version>0.1.8</jdave.version>
2831
</properties>
2932

3033
<dependencies>
@@ -43,7 +46,27 @@
4346
<dependency>
4447
<groupId>net.dv8tion</groupId>
4548
<artifactId>JDA</artifactId>
46-
<version>4.3.0_277</version>
49+
<version>6.4.1</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>club.minnced</groupId>
53+
<artifactId>jdave-api</artifactId>
54+
<version>${jdave.version}</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>club.minnced</groupId>
58+
<artifactId>jdave-native-win-x86-64</artifactId>
59+
<version>${jdave.version}</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>club.minnced</groupId>
63+
<artifactId>jdave-native-linux-x86-64</artifactId>
64+
<version>${jdave.version}</version>
65+
</dependency>
66+
<dependency>
67+
<groupId>club.minnced</groupId>
68+
<artifactId>jdave-native-linux-aarch64</artifactId>
69+
<version>${jdave.version}</version>
4770
</dependency>
4871

4972
<!-- Opus processing -->
@@ -62,7 +85,12 @@
6285
<dependency>
6386
<groupId>ch.qos.logback</groupId>
6487
<artifactId>logback-classic</artifactId>
65-
<version>1.2.5</version>
88+
</dependency>
89+
90+
<!-- JSON parsing -->
91+
<dependency>
92+
<groupId>com.fasterxml.jackson.core</groupId>
93+
<artifactId>jackson-databind</artifactId>
6694
</dependency>
6795

6896
<!-- Environment -->
@@ -76,18 +104,18 @@
76104
<dependency>
77105
<groupId>org.postgresql</groupId>
78106
<artifactId>postgresql</artifactId>
79-
<version>42.2.22</version>
107+
<version>42.7.7</version>
80108
</dependency>
81109

82-
</dependencies>
110+
<!-- Better code -->
111+
<dependency>
112+
<groupId>org.projectlombok</groupId>
113+
<artifactId>lombok</artifactId>
114+
<version>1.18.44</version>
115+
<scope>provided</scope>
116+
</dependency>
83117

84-
<repositories>
85-
<repository>
86-
<id>dv8tion</id>
87-
<name>m2-dv8tion</name>
88-
<url>https://m2.dv8tion.net/releases</url>
89-
</repository>
90-
</repositories>
118+
</dependencies>
91119

92120
<build>
93121
<finalName>${project.name}-${project.version}</finalName>
@@ -105,10 +133,31 @@
105133

106134
<plugins>
107135

136+
<plugin>
137+
<groupId>org.apache.maven.plugins</groupId>
138+
<artifactId>maven-compiler-plugin</artifactId>
139+
<version>3.14.1</version>
140+
<configuration>
141+
<release>${java.version}</release>
142+
<proc>full</proc>
143+
<annotationProcessorPaths>
144+
<path>
145+
<groupId>org.projectlombok</groupId>
146+
<artifactId>lombok</artifactId>
147+
<version>1.18.44</version>
148+
</path>
149+
<path>
150+
<groupId>org.springframework.boot</groupId>
151+
<artifactId>spring-boot-configuration-processor</artifactId>
152+
<version>${project.parent.version}</version>
153+
</path>
154+
</annotationProcessorPaths>
155+
</configuration>
156+
</plugin>
157+
108158
<plugin>
109159
<groupId>org.springframework.boot</groupId>
110160
<artifactId>spring-boot-maven-plugin</artifactId>
111-
<version>2.5.2</version>
112161
</plugin>
113162

114163
</plugins>
Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package ovh.excale.vgreeter;
22

3+
import lombok.extern.log4j.Log4j2;
34
import org.jetbrains.annotations.NotNull;
4-
import org.slf4j.Logger;
5-
import org.slf4j.LoggerFactory;
5+
import org.jetbrains.annotations.Nullable;
66
import org.springframework.beans.BeansException;
77
import org.springframework.beans.factory.annotation.Value;
88
import org.springframework.boot.Banner;
@@ -11,11 +11,14 @@
1111
import org.springframework.boot.autoconfigure.SpringBootApplication;
1212
import org.springframework.context.ApplicationContext;
1313
import org.springframework.context.ApplicationContextAware;
14+
import org.springframework.context.ConfigurableApplicationContext;
1415

16+
@Log4j2
1517
@SpringBootApplication
1618
public class VGreeterApplication implements CommandLineRunner, ApplicationContextAware {
1719

18-
private static ApplicationContext ctx;
20+
private static Boolean maintenance;
21+
private static ConfigurableApplicationContext ctx;
1922

2023
public static void main(String[] args) {
2124

@@ -25,26 +28,64 @@ public static void main(String[] args) {
2528

2629
}
2730

31+
// TODO: DON'T CONNECT TO DB DURING MAINTENANCE
32+
33+
// keep previous maintenance state
34+
public static void restart(@Nullable final Runnable then, @Nullable final Boolean maintenance) {
35+
36+
log.info("Restarting app");
37+
38+
Thread thread = new Thread(() -> {
39+
ctx.close();
40+
41+
VGreeterApplication.maintenance = maintenance != null ? maintenance : VGreeterApplication.maintenance;
42+
43+
SpringApplication app = new SpringApplication(VGreeterApplication.class);
44+
app.setBannerMode(Banner.Mode.OFF);
45+
app.run();
46+
47+
if(then != null)
48+
then.run();
49+
50+
});
51+
52+
thread.setDaemon(false);
53+
thread.start();
54+
55+
}
56+
57+
public static void restart(@NotNull Runnable then) {
58+
restart(then, null);
59+
}
60+
61+
public static void restart(boolean maintenance) {
62+
restart(null, maintenance);
63+
}
64+
65+
public static boolean isInMaintenance() {
66+
return maintenance;
67+
}
68+
2869
public static ApplicationContext getApplicationContext() {
2970
return ctx;
3071
}
3172

32-
public final Logger logger;
3373
public final String version;
3474

35-
public VGreeterApplication(@Value("${application.version}") String version) {
75+
public VGreeterApplication(@Value("${application.version}") String version,
76+
@Value("${env.MAINTENANCE:false}") boolean maintenance) {
3677
this.version = version;
37-
logger = LoggerFactory.getLogger(VGreeterApplication.class);
78+
VGreeterApplication.maintenance = maintenance;
3879
}
3980

4081
@Override
4182
public void run(String[] args) {
42-
logger.info("Running on version {}", version);
83+
log.info("Running on version {}", version);
4384
}
4485

4586
@Override
4687
public void setApplicationContext(@NotNull ApplicationContext context) throws BeansException {
47-
ctx = context;
88+
ctx = (ConfigurableApplicationContext) context;
4889
}
4990

5091
}

src/main/java/ovh/excale/vgreeter/commands/AbstractCommand.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)