Skip to content
This repository has been archived by the owner on Jul 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #188 from book000/fix/rollbar-code-version
Browse files Browse the repository at this point in the history
fix: rollbarに報告されるコードバージョンが不適切な問題を修正
  • Loading branch information
yuuahp authored Nov 25, 2022
2 parents ea5ec20 + cb27cb0 commit 87d8db8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 35 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ jobs:
ref_dev: "dev"
files: |
./target/jdavcspeaker-jar-with-dependencies.jar
runs-on: ubuntu-latest

steps:
- name: 👉 Release Version
id: version
Expand All @@ -24,28 +26,38 @@ jobs:
github_token: ${{ github.token }}
default_bump: "minor"
custom_release_rules: "breaking:major:💣 Breaking Changes,feat:minor:✨ Features,fix:patch:💣 Bug Fixes,docs:patch:📰 Docs,chore:patch:🎨 Chore,pref:patch:🎈 Performance improvements,refactor:patch:🧹 Refactoring,build:patch:🔍 Build,ci:patch:🔍 CI,revert:patch:⏪ Revert,style:patch:🧹 Style,test:patch:👀 Test"

- name: 📻 Setup JDK16
uses: actions/[email protected]
with:
distribution: "zulu"
java-version: ${{ env.jdk }}

- name: 📦 Checkout ${{ github.repository }}
uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
token: ${{ github.token }}

- name: ⌛ Cache
uses: actions/cache@v2
with:
path: ~/.m2/caches
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: ✏ Insert Version
run: |
sed -r -i "1,/version/s#<version>(.+?)</version>#<version>${{ steps.version.outputs.new_version }}</version>#" pom.xml
git diff
- name: 📦 Package
env:
project_version: ${{ steps.version.outputs.new_version }}
run: |
mvn ${{ env.maven_cmd }}
- name: 🗃️ Publish Release (main)
env:
project_version: ${{ steps.version.outputs.new_version }}
Expand All @@ -55,6 +67,7 @@ jobs:
generate_release_notes: true
tag_name: ${{ env.project_version }}
files: ${{ env.files }}

- name: 🗃️ Publish Release (dev)
env:
project_version: ${{ steps.version.outputs.new_version }}
Expand Down
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
<archive>
<manifest>
<mainClass>com.jaoafa.jdavcspeaker.Main</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
Expand Down
38 changes: 3 additions & 35 deletions src/main/java/com/jaoafa/jdavcspeaker/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import java.nio.file.Path;
import java.util.List;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.jar.JarEntry;
Expand Down Expand Up @@ -139,7 +138,7 @@ public static void main(String[] _args) {
LibValue.rollbar = Rollbar.init(ConfigBuilder
.withAccessToken(tokenConfig.getString("rollbar"))
.environment(getLocalHostName())
.codeVersion(getGitHash())
.codeVersion(Main.class.getPackage().getImplementationVersion())
.handleUncaughtErrors(false)
.build());

Expand All @@ -162,6 +161,7 @@ public static void main(String[] _args) {
.addField("Summary", String.format("%s (%s)", e.getMessage(), e.getClass().getName()), false)
.addField("Details", details.substring(0, 1000), false)
.addField("Thread Name", t.getName(), false)
.setFooter("JDA-VCSpeaker %s".formatted(Main.class.getPackage().getImplementationVersion()))
.setColor(Color.RED)
.build())
.addFile(is, "stacktrace.txt")
Expand All @@ -188,6 +188,7 @@ public static void main(String[] _args) {
.setTitle("JDA-VCSpeaker Error Reporter")
.addField("Summary", String.format("%s (%s)", e.getMessage(), e.getClass().getName()), false)
.addField("Details", details.substring(0, 1000), false)
.setFooter("JDA-VCSpeaker %s".formatted(Main.class.getPackage().getImplementationVersion()))
.setColor(Color.RED)
.build())
.addFile(is, "stacktrace.txt")
Expand Down Expand Up @@ -309,39 +310,6 @@ private static String getLocalHostName() {
}
}

private static String getGitHash() {
try {
Process p;
try {
ProcessBuilder builder = new ProcessBuilder();
builder.command("git", "rev-parse", "--short", "HEAD");
builder.redirectErrorStream(true);
p = builder.start();
boolean bool = p.waitFor(10, TimeUnit.SECONDS);
if (!bool) {
return null;
}
} catch (InterruptedException e) {
return null;
}
try (InputStream is = p.getInputStream()) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
StringBuilder text = new StringBuilder();
while (true) {
String line = br.readLine();
if (line == null) {
break;
}
text.append(line).append("\n");
}
return text.toString().trim();
}
}
} catch (IOException e) {
return "Unknown";
}
}

static void removeCommands(JSONObject tokenConfig) {
LibFlow removeCmdFlow = new LibFlow("RemoveCmd");
removeCmdFlow.action("登録済みのコマンドをすべて削除します。");
Expand Down

0 comments on commit 87d8db8

Please sign in to comment.