mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
deployment-tool: Add platform-specific deployments and flag to send disc notification
This commit is contained in:
26
.github/workflows/deploy-snapshot-fancynpcs.yml
vendored
26
.github/workflows/deploy-snapshot-fancynpcs.yml
vendored
@@ -27,22 +27,36 @@ jobs:
|
|||||||
- name: Modify gradlew permissions
|
- name: Modify gradlew permissions
|
||||||
run: chmod +x ./gradlew
|
run: chmod +x ./gradlew
|
||||||
|
|
||||||
- name: Build FancyNpcs
|
- name: Build deployment tool
|
||||||
|
run: ./gradlew :tools:deployment:shadowJar
|
||||||
|
|
||||||
|
- name: Build FancyNpcs for Modrinth
|
||||||
env:
|
env:
|
||||||
RELEASE_CHANNEL: 'snapshot'
|
RELEASE_CHANNEL: 'snapshot'
|
||||||
RELEASE_PLATFORM: 'modrinth'
|
RELEASE_PLATFORM: 'modrinth'
|
||||||
run: ./gradlew :plugins:fancynpcs:shadowJar
|
run: ./gradlew :plugins:fancynpcs:shadowJar
|
||||||
|
|
||||||
- name: Build deployment tool
|
- name: Deploy to Modrinth
|
||||||
run: ./gradlew :tools:deployment:shadowJar
|
|
||||||
|
|
||||||
- name: Deploy
|
|
||||||
env:
|
env:
|
||||||
MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }}
|
MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }}
|
||||||
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||||
run:
|
run:
|
||||||
cd tools/deployment/build/libs &&
|
cd tools/deployment/build/libs &&
|
||||||
java -jar deployment.jar ../../../../plugins/fancynpcs/snapshot_deployment_config.json
|
java -jar deployment.jar modrinth ../../../../plugins/fancynpcs/snapshot_deployment_config.json true
|
||||||
|
|
||||||
|
# - name: Build FancyNpcs for Hangar
|
||||||
|
# env:
|
||||||
|
# RELEASE_CHANNEL: 'snapshot'
|
||||||
|
# RELEASE_PLATFORM: 'hangar'
|
||||||
|
# run: ./gradlew :plugins:fancynpcs:shadowJar
|
||||||
|
#
|
||||||
|
# - name: Deploy to Hangar
|
||||||
|
# env:
|
||||||
|
# HANGAR_API_KEY: "${{ secrets.HANGAR_API_KEY }}"
|
||||||
|
# DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||||
|
# run:
|
||||||
|
# cd tools/deployment/build/libs &&
|
||||||
|
# java -jar deployment.jar hangar ../../../../plugins/fancynpcs/snapshot_deployment_config.json true
|
||||||
|
|
||||||
- name: Publish to reposilite (snapshots)
|
- name: Publish to reposilite (snapshots)
|
||||||
run: ./gradlew :plugins:fancynpcs:fn-api:publishAllPublicationsToFancyinnovationsSnapshotsRepository
|
run: ./gradlew :plugins:fancynpcs:fn-api:publishAllPublicationsToFancyinnovationsSnapshotsRepository
|
||||||
@@ -1 +1 @@
|
|||||||
2.6.0.276
|
2.6.0.277
|
||||||
@@ -15,10 +15,32 @@ public class Main {
|
|||||||
private static final Gson GSON = new Gson();
|
private static final Gson GSON = new Gson();
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
String configFilePath = args[0];
|
if (args.length < 2) {
|
||||||
|
System.err.println("Usage: java -jar deployment.jar <platform> <config_file path> [send_notification]");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
String platform = args[0];
|
||||||
|
|
||||||
|
String configFilePath = args[1];
|
||||||
String configData = Files.readString(Path.of(configFilePath));
|
String configData = Files.readString(Path.of(configFilePath));
|
||||||
Configuration configuration = GSON.fromJson(configData, Configuration.class);
|
Configuration configuration = GSON.fromJson(configData, Configuration.class);
|
||||||
|
|
||||||
|
boolean sendNotification = args.length > 2 && Boolean.parseBoolean(args[2]);
|
||||||
|
|
||||||
|
if (platform.equalsIgnoreCase("modrinth")) {
|
||||||
|
deployToModrinth(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sendNotification) {
|
||||||
|
sendDiscordNotification(configuration);
|
||||||
|
System.out.println("Deployment completed and notification sent.");
|
||||||
|
} else {
|
||||||
|
System.out.println("Deployment completed without sending notification.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void deployToModrinth(Configuration configuration) {
|
||||||
String modrinthApiKey = System.getenv("MODRINTH_API_KEY");
|
String modrinthApiKey = System.getenv("MODRINTH_API_KEY");
|
||||||
ModrinthService modrinthService = new ModrinthService(modrinthApiKey);
|
ModrinthService modrinthService = new ModrinthService(modrinthApiKey);
|
||||||
try {
|
try {
|
||||||
@@ -26,12 +48,14 @@ public class Main {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendDiscordNotification(Configuration configuration) {
|
||||||
String discordWebhookUrl = System.getenv("DISCORD_WEBHOOK_URL");
|
String discordWebhookUrl = System.getenv("DISCORD_WEBHOOK_URL");
|
||||||
if (discordWebhookUrl != null) {
|
if (discordWebhookUrl != null) {
|
||||||
DiscordWebhook.Data data = new DiscordWebhook.Data("Deployment completed", List.of(
|
DiscordWebhook.Data data = new DiscordWebhook.Data("Deployment completed", List.of(
|
||||||
new DiscordWebhook.Data.Embed(
|
new DiscordWebhook.Data.Embed(
|
||||||
"New version of "+configuration.projectName(),
|
"New version of " + configuration.projectName(),
|
||||||
"""
|
"""
|
||||||
**Version:** %s
|
**Version:** %s
|
||||||
**Channel:** %s
|
**Channel:** %s
|
||||||
@@ -42,7 +66,7 @@ public class Main {
|
|||||||
configuration.channel(),
|
configuration.channel(),
|
||||||
GitService.getCommitHash().substring(0, 7),
|
GitService.getCommitHash().substring(0, 7),
|
||||||
GitService.getCommitHash(),
|
GitService.getCommitHash(),
|
||||||
"https://modrinth.com/plugin/"+configuration.projectName()+"/version/"+configuration.readVersion()),
|
"https://modrinth.com/plugin/" + configuration.projectName() + "/version/" + configuration.readVersion()),
|
||||||
|
|
||||||
0x00FF00
|
0x00FF00
|
||||||
)
|
)
|
||||||
@@ -52,7 +76,6 @@ public class Main {
|
|||||||
} else {
|
} else {
|
||||||
System.out.println("Discord webhook URL not set. Skipping notification.");
|
System.out.println("Discord webhook URL not set. Skipping notification.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user