From b6da5b94ffba77dc8f41ad22495bf198cf164dfe Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 22:17:36 -0700 Subject: [PATCH 01/13] Update publish action to publish to new release as well as maven. Remove version # defined by gradle.properties. Instead, the publish CI will now automatically generate and tag the commit based on the last version tag. The type of increment is determined by a tag on the PR, one of `major`, `minor`, or `patch`. If one of these labels is not present CI _will fail_ and no release will be generated! A few changes have been made outside of source control to this repo for these changes: 1. New labels mentioned above have been added. 2. Merges to master now requires the branch being merged into master to be completely up to date with master. --- .github/workflows/main.yml | 52 ++++++++++++---------- .github/workflows/publish-snapshot.yml | 30 ------------- .github/workflows/publish.yml | 60 ++++++++++++++++++++++++++ build.gradle | 37 +++++----------- gradle.properties | 2 - 5 files changed, 101 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/publish-snapshot.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 gradle.properties diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6bc63cf..47ad0bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,29 +1,37 @@ name: Java CI -on: [push] +on: + push: + branches-ignore: + - master + paths-ignore: + - .gitignore + - README.md + - geary.iml jobs: build: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - run: cat $HOME/.m2/settings.xml - - uses: derongan/nmsaction@v1 - with: - rev: 1.15.1 - - name: Install nms into m2 - run: mkdir -p $HOME/.m2/repository && cp -a nms-build/.m2/repository/. $HOME/.m2/repository - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew -PbuildNo=${{ github.run_number }} shadowJar - - name: Upload artifact - uses: actions/upload-artifact@v1.0.0 - with: - name: package - path: build/libs + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build NMS + uses: derongan/nmsaction@v1 + with: + rev: 1.15.1 + - name: Install nms into m2 + run: mkdir -p $HOME/.m2/repository && cp -a nms-build/.m2/repository/. $HOME/.m2/repository + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Run tests + run: ./gradlew test + - name: Build with Gradle + run: ./gradlew -PbuildNo=${{ github.run_number }} jar shadowJar + - name: Upload artifact + uses: actions/upload-artifact@v1.0.0 + with: + name: package + path: build/libs diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml deleted file mode 100644 index a515a7d..0000000 --- a/.github/workflows/publish-snapshot.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Publish Snapshot - -on: - push: - branches: - - master - -jobs: - publish-snapshot: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - run: cat $HOME/.m2/settings.xml - - uses: derongan/nmsaction@v1 - with: - rev: 1.15.1 - - name: Install nms into m2 - run: mkdir -p $HOME/.m2/repository && cp -a nms-build/.m2/repository/. $HOME/.m2/repository - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Publish artifact - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: - ./gradlew -PbuildNo=${{ github.run_number }} publish diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..eba48da --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,60 @@ +name: Publish Release + +on: + push: + branches: + - master + paths-ignore: + - .gitignore + - README.md + - geary.iml + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build NMS + uses: derongan/nmsaction@v1 + with: + rev: 1.15.1 + - name: Install nms into m2 + run: mkdir -p $HOME/.m2/repository && cp -a nms-build/.m2/repository/. $HOME/.m2/repository + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Find change type + id: bump + uses: zwaldowski/match-label-action@v1 + with: + allowed: major,minor,patch + - uses: zwaldowski/semver-release-action@v1 + id: next_version + with: + bump: ${{ steps.bump.outputs.match }} + github_token: ${{ secrets.GITHUB_TOKEN }} + prefix: v + - name: Run tests + run: ./gradlew test + - name: Build output jars + run: ./gradlew -Pversion=${{ steps.next_version.outputs.version }} jar shadowJar + - name: Upload artifact + uses: actions/upload-artifact@v1.0.0 + with: + name: package + path: build/libs + - name: Publish to GitHub Package Repository + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./gradlew -Pversion=${{ steps.next_version.outputs.version }} publish + - name: Create GitHub Release + uses: marvinpinto/action-automatic-releases@latest + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: false + files: | + build/libs/*.jar + diff --git a/build.gradle b/build.gradle index 44648b6..24a0920 100644 --- a/build.gradle +++ b/build.gradle @@ -7,22 +7,18 @@ buildscript { } } -plugins { - id 'java' - id 'maven-publish' -} - +apply plugin: "java" +apply plugin: "maven-publish" apply plugin: "com.github.johnrengelman.shadow" -group = pluginGroup -version = pluginVersion +defaultTasks 'build' -if (project.hasProperty("buildNo")) { - version += "-" + buildNo -} +group = "com.mineinabyss" -sourceCompatibility = '1.8' -targetCompatibility = '1.8' +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} repositories { mavenCentral() @@ -35,11 +31,6 @@ repositories { name = 'sonatype' url = 'https://oss.sonatype.org/content/groups/public/' } - - maven { - name = "papermc" - url = "https://papermc.io/repo/repository/maven-public/" - } } publishing { @@ -67,7 +58,6 @@ dependencies { testImplementation "junit:junit:4.12" testImplementation "org.mockito:mockito-core:3.2.4" testImplementation group: 'org.spigotmc', name: 'spigot', version: '1.15.1-R0.1-SNAPSHOT' - testImplementation "org.reflections:reflections:0.9.12" testImplementation "com.google.truth:truth:1.0.1" annotationProcessor "com.google.auto.value:auto-value:1.7" } @@ -80,12 +70,7 @@ processResources { } } -//Move into plugins folder -if (project.hasProperty("plugin_path") && plugin_path) { - println("Copying to plugin directory $plugin_path") - task copyJar(type: Copy) { - from shadowJar // here it automatically reads jar file produced from jar task - into plugin_path - } - build.dependsOn copyJar +task copyJar(type: Copy) { + from shadowJar // here it automatically reads jar file produced from shadowJar task + into plugin_path } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 3e7ea47..0000000 --- a/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -pluginGroup=com.mineinabyss -pluginVersion=1.0.2 \ No newline at end of file From 181899542253429bde8bf0714e27a64194de5a69 Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 22:28:45 -0700 Subject: [PATCH 02/13] Add check that verifies that a PR has an appropriate label. --- .github/workflows/pr-has-version-label.yml | 19 +++++++++++++++++++ .github/workflows/publish.yml | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pr-has-version-label.yml diff --git a/.github/workflows/pr-has-version-label.yml b/.github/workflows/pr-has-version-label.yml new file mode 100644 index 0000000..0d6bae6 --- /dev/null +++ b/.github/workflows/pr-has-version-label.yml @@ -0,0 +1,19 @@ +on: + pull_request: + types: [opened, reopened, labeled, unlabeled] + branches-ignore: + - master + paths-ignore: + - .gitignore + - README.md + - geary.iml + + jobs: + check-has-version-label: + runs-on: ubuntu-latest + steps: + - name: Find change type + id: bump + uses: zwaldowski/match-label-action@v1 + with: + allowed: major,minor,patch \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index eba48da..141ece8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ on: - geary.iml jobs: - build-and-test: + build-and-publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 47d89a52096c316b2c0fe4050de556a7b0344b36 Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 22:34:23 -0700 Subject: [PATCH 03/13] Add name to version label check --- .github/workflows/pr-has-version-label.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-has-version-label.yml b/.github/workflows/pr-has-version-label.yml index 0d6bae6..103a727 100644 --- a/.github/workflows/pr-has-version-label.yml +++ b/.github/workflows/pr-has-version-label.yml @@ -1,3 +1,5 @@ +name: Check PR Has Version Label + on: pull_request: types: [opened, reopened, labeled, unlabeled] From e3d93c21c07a0c0ed08a53d67ba228110a6c2dbf Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 22:38:36 -0700 Subject: [PATCH 04/13] Fix copyJar to check if plugin_path exists --- build.gradle | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 24a0920..473cecb 100644 --- a/build.gradle +++ b/build.gradle @@ -71,6 +71,10 @@ processResources { } task copyJar(type: Copy) { - from shadowJar // here it automatically reads jar file produced from shadowJar task - into plugin_path + if (project.hasProperty('plugin_path')) { + from shadowJar // here it automatically reads jar file produced from shadowJar task + into plugin_path + } else { + throw new InvalidUserDataException("plugin_path must be defined") + } } \ No newline at end of file From f4b4069d82cbfd232e517ecea57071325f33c98a Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 22:39:32 -0700 Subject: [PATCH 05/13] fix job indentation --- .github/workflows/pr-has-version-label.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-has-version-label.yml b/.github/workflows/pr-has-version-label.yml index 103a727..85051f5 100644 --- a/.github/workflows/pr-has-version-label.yml +++ b/.github/workflows/pr-has-version-label.yml @@ -10,12 +10,12 @@ on: - README.md - geary.iml - jobs: - check-has-version-label: - runs-on: ubuntu-latest - steps: - - name: Find change type - id: bump - uses: zwaldowski/match-label-action@v1 - with: - allowed: major,minor,patch \ No newline at end of file +jobs: + check-has-version-label: + runs-on: ubuntu-latest + steps: + - name: Find change type + id: bump + uses: zwaldowski/match-label-action@v1 + with: + allowed: major,minor,patch \ No newline at end of file From 6854f408d891bf4f8dfb09648450abb9d945b5e2 Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 22:44:00 -0700 Subject: [PATCH 06/13] Add synchronize to pr-has-version-label.yml conditions --- .github/workflows/pr-has-version-label.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-has-version-label.yml b/.github/workflows/pr-has-version-label.yml index 85051f5..e32c539 100644 --- a/.github/workflows/pr-has-version-label.yml +++ b/.github/workflows/pr-has-version-label.yml @@ -2,7 +2,7 @@ name: Check PR Has Version Label on: pull_request: - types: [opened, reopened, labeled, unlabeled] + types: [opened, reopened, labeled, unlabeled, synchronize] branches-ignore: - master paths-ignore: From 91a0d487c61741629cd44e83b18ef7f130badf90 Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 22:52:00 -0700 Subject: [PATCH 07/13] remove master branch req on pr-has-version-label.yml because PR conditions look at the branch being merged ONTO --- .github/workflows/pr-has-version-label.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pr-has-version-label.yml b/.github/workflows/pr-has-version-label.yml index e32c539..08aa600 100644 --- a/.github/workflows/pr-has-version-label.yml +++ b/.github/workflows/pr-has-version-label.yml @@ -3,8 +3,6 @@ name: Check PR Has Version Label on: pull_request: types: [opened, reopened, labeled, unlabeled, synchronize] - branches-ignore: - - master paths-ignore: - .gitignore - README.md From 83a886a310f9b124f9c042125519af3967ce52bc Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 22:54:29 -0700 Subject: [PATCH 08/13] Exclude workflows subdir from publish/pr version check workflows --- .github/workflows/pr-has-version-label.yml | 1 + .github/workflows/publish.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/pr-has-version-label.yml b/.github/workflows/pr-has-version-label.yml index 08aa600..1f7be10 100644 --- a/.github/workflows/pr-has-version-label.yml +++ b/.github/workflows/pr-has-version-label.yml @@ -7,6 +7,7 @@ on: - .gitignore - README.md - geary.iml + - .github/workflows/** jobs: check-has-version-label: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 141ece8..035fc8d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,6 +8,7 @@ on: - .gitignore - README.md - geary.iml + - .github/workflows/** jobs: build-and-publish: From acb3ee195960ae7df1193f4fc60beb02b0b351c7 Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 23:04:34 -0700 Subject: [PATCH 09/13] Show the next action in the label check --- .github/workflows/pr-has-version-label.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-has-version-label.yml b/.github/workflows/pr-has-version-label.yml index 1f7be10..55513e6 100644 --- a/.github/workflows/pr-has-version-label.yml +++ b/.github/workflows/pr-has-version-label.yml @@ -17,4 +17,13 @@ jobs: id: bump uses: zwaldowski/match-label-action@v1 with: - allowed: major,minor,patch \ No newline at end of file + allowed: major,minor,patch + - uses: zwaldowski/semver-release-action@v1 + id: next_version + with: + bump: ${{ steps.bump.outputs.match }} + github_token: ${{ secrets.GITHUB_TOKEN }} + dry_run: true + prefix: v + - name: Show Version + run: echo Next version at time of running this action will be ${{ steps.next_version.outputs.version }} \ No newline at end of file From f8c63fa362793e4d1faa5f62cf8a216bf343abf1 Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 23:11:38 -0700 Subject: [PATCH 10/13] Fix copyJar to only reference copyjar through string --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 473cecb..baa3146 100644 --- a/build.gradle +++ b/build.gradle @@ -73,7 +73,7 @@ processResources { task copyJar(type: Copy) { if (project.hasProperty('plugin_path')) { from shadowJar // here it automatically reads jar file produced from shadowJar task - into plugin_path + into project.getProperty('plugin_path') } else { throw new InvalidUserDataException("plugin_path must be defined") } From 276895caa098d849c034ea2832efa4366a3b89e8 Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 23:29:58 -0700 Subject: [PATCH 11/13] Fix copyJar to depend on an input property, plugin_path --- build.gradle | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index baa3146..de03dd9 100644 --- a/build.gradle +++ b/build.gradle @@ -71,10 +71,8 @@ processResources { } task copyJar(type: Copy) { - if (project.hasProperty('plugin_path')) { - from shadowJar // here it automatically reads jar file produced from shadowJar task - into project.getProperty('plugin_path') - } else { - throw new InvalidUserDataException("plugin_path must be defined") - } + def plugin_path = project.findProperty("plugin_path") + inputs.property 'plugin_path', plugin_path + from shadowJar // here it automatically reads jar file produced from shadowJar task + into plugin_path } \ No newline at end of file From d2e33bb9605b04529e3ed7fcafe88bf260660c88 Mon Sep 17 00:00:00 2001 From: Derongan Date: Sun, 19 Apr 2020 23:42:53 -0700 Subject: [PATCH 12/13] Undo change of plugin decl. New format is preferred --- build.gradle | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index de03dd9..10622f3 100644 --- a/build.gradle +++ b/build.gradle @@ -7,8 +7,11 @@ buildscript { } } -apply plugin: "java" -apply plugin: "maven-publish" +plugins { + id 'java' + id 'maven-publish' +} + apply plugin: "com.github.johnrengelman.shadow" defaultTasks 'build' From aa1d7dd6fc91747639f5b4a41697325dc6f59756 Mon Sep 17 00:00:00 2001 From: Derongan Date: Wed, 22 Apr 2020 22:43:55 -0700 Subject: [PATCH 13/13] Run tests before checking for release tag Remove default task --- .github/workflows/publish.yml | 4 ++-- build.gradle | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 035fc8d..1e3e4f9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,6 +27,8 @@ jobs: run: mkdir -p $HOME/.m2/repository && cp -a nms-build/.m2/repository/. $HOME/.m2/repository - name: Grant execute permission for gradlew run: chmod +x gradlew + - name: Run tests + run: ./gradlew test - name: Find change type id: bump uses: zwaldowski/match-label-action@v1 @@ -38,8 +40,6 @@ jobs: bump: ${{ steps.bump.outputs.match }} github_token: ${{ secrets.GITHUB_TOKEN }} prefix: v - - name: Run tests - run: ./gradlew test - name: Build output jars run: ./gradlew -Pversion=${{ steps.next_version.outputs.version }} jar shadowJar - name: Upload artifact diff --git a/build.gradle b/build.gradle index 10622f3..e0cdd5e 100644 --- a/build.gradle +++ b/build.gradle @@ -14,8 +14,6 @@ plugins { apply plugin: "com.github.johnrengelman.shadow" -defaultTasks 'build' - group = "com.mineinabyss" java {