Skip to content

Commit eeafd06

Browse files
committed
Update release script
1 parent e7055cc commit eeafd06

File tree

5 files changed

+63
-43
lines changed

5 files changed

+63
-43
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,42 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v3
13+
- name: Discord notification
14+
uses: Ilshidur/action-discord@master
15+
env:
16+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
17+
DISCORD_USERNAME: GitHub
18+
DISCORD_AVATAR: https://cdn.discordapp.com/avatars/815532493087178803/df91181b3f1cf0ef1592fbe18e0962d7.webp?size=128
1319
with:
14-
fetch-depth: '0' # will fetch the entire history
20+
args: "A new release ( ${{ env.TAG }} ) is being built."
1521
- name: Set up JDK 17
1622
uses: actions/setup-java@v3
1723
with:
1824
java-version: 17
1925
distribution: 'zulu'
20-
check-latest: true
2126
- name: Setup ENV
2227
run: echo "TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
2328
- name: Grant execute permission for gradlew
2429
run: chmod +x gradlew
2530
- name: Setup Submodules
26-
2731
uses: snickerbockers/submodules-init@v4
2832
- name: Build Jar with Gradle
2933
id: publish_release_assets
3034
run: ./gradlew :build -Pbot_version=${{ env.TAG }}
3135
env:
3236
BUILD_NUMBER: ${{ github.run_number }}
33-
- name: Create release
34-
run: ./gradlew :githubRelease :releaseSummary
37+
- name: Make Changelog
38+
id: changelog
39+
run: ./gradlew :makeChangelog -Ptag=${{ env.TAG }}
3540
env:
36-
GITHUB_TOKEN: ${{ github.token }}
37-
- name: Upload release assets
38-
id: upload_release_assets
39-
uses: AButler/upload-release-assets@v2.0
41+
GITHUB_TOKEN: ${{ github.token }}
42+
- name: Create release
43+
id: create_release
44+
uses: ncipollo/release-action@v1
4045
with:
41-
release-tag: ${{ env.TAG }}
42-
repo-token: ${{ github.token }}
43-
files: 'build/libs/*[-all].jar'
46+
token: ${{ github.token }}
47+
tag: ${{ github.ref }}
48+
name: Release ${{ env.TAG }}
49+
artifactErrorsFailBuild: true
50+
artifacts: 'build/libs/*[-all].jar'
51+
bodyFile: 'changelog.html'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ OCR.png
3636
qr.png
3737
diction.txt
3838
data/
39+
changelog.html
3940

4041
#BotStuff
4142
mmdbot_config.toml
@@ -44,6 +45,7 @@ mmdbot_sticky_roles.json
4445
mmdbot_user_join_times.json
4546
mmdbot_tricks.json
4647
.linkie-cache/
48+
4749
#Just in case anyone else has this still.
4850
mmdbot_config.json
4951
mmdbot_sticky_roles.json.old

build.gradle

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
import org.kohsuke.github.*
3+
import se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask
24

5+
import java.nio.file.Files
36
import java.time.OffsetDateTime
47
import java.time.ZoneOffset
58
import java.time.format.DateTimeFormatter
69

710
buildscript {
811
repositories {
9-
maven { url 'https://plugins.gradle.org/m2/' }
12+
mavenCentral()
1013
}
11-
1214
dependencies {
13-
classpath 'org.shipkit:shipkit-changelog:1.1.15'
14-
classpath 'org.shipkit:shipkit-auto-version:1.1.20'
15+
classpath 'org.kohsuke:github-api:1.306'
1516
}
1617
}
1718

@@ -25,6 +26,7 @@ plugins {
2526
alias(libs.plugins.flyway)
2627
alias(libs.plugins.licenser)
2728
alias(libs.plugins.lombok)
29+
id "se.bjurr.gitchangelog.git-changelog-gradle-plugin" version '1.71.4'
2830
}
2931

3032
group 'com.mcmoddev'
@@ -34,8 +36,6 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(17)
3436

3537
println "Bot Version: $version"
3638

37-
apply from: 'gradle/shipkit.gradle'
38-
3939
final var actualDateTime = OffsetDateTime.now(ZoneOffset.UTC).withNano(0)
4040

4141
application {
@@ -238,6 +238,26 @@ license {
238238
}
239239
}
240240

241+
tasks.register('makeChangelog', GitChangelogTask) {
242+
fromRepo = projectDir.absolutePath.toString()
243+
file = file("changelog.html")
244+
untaggedName = "Current release $version"
245+
toRef = "HEAD"
246+
fromCommit = resolveStartCommit(project.tag)
247+
templateContent = Files.readString(projectDir.toPath().resolve("changelog.mustache"))
248+
}
249+
250+
static String resolveStartCommit(String tag) {
251+
final GitHub github = new GitHubBuilder().withOAuthToken(System.getenv('GITHUB_TOKEN')).build();
252+
final var repo = github.getRepository('MinecraftModDevelopment/MMDBot')
253+
final var tags = repo.listTags().toList()
254+
final var actualTag = tags.stream()
255+
.filter(t -> t.name == tag)
256+
.findFirst().orElseThrow()
257+
final var index = tags.indexOf(actualTag)
258+
return tags.get(index - 1).commit.getSHA1()
259+
}
260+
241261
eclipse.project {
242262
buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
243263
natures 'org.eclipse.buildship.core.gradleprojectnature'

changelog.mustache

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{#tags}}
2+
<h3>{{name}}</h3>
3+
<ul>
4+
{{#commits}}
5+
<li>
6+
<a href="https://github.com/MinecraftModDevelopment/MMDBot/commit/{{hashFull}}">{{{messageTitle}}}</a> - {{{authorName}}}
7+
<ul>
8+
{{#messageBodyItems}}
9+
<li>{{.}}</li>
10+
{{/messageBodyItems}}
11+
</ul>
12+
</li>
13+
{{/commits}}
14+
</ul>
15+
{{/tags}}

gradle/shipkit.gradle

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

0 commit comments

Comments
 (0)