From d36450fe61a6c340dc4f6b261619befd2b5c1d60 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Wed, 7 Apr 2021 09:45:54 +0200 Subject: [PATCH 1/2] Release job --- .github/workflows/release.yml | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..00feb7b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + publish: + name: Publish release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Install JDK ${{ matrix.java_version }} + uses: actions/setup-java@v1 + with: + java-version: 8 + - name: Build project + run: ./gradlew build + env: + VERSION: ${{ github.ref }} + - name: Find Tag + id: tagger + uses: jimschubert/query-tag-action@v2 + with: + skip-unshallow: 'true' + commit-ish: HEAD + - run: | + PRE_RELEASE="" + string='My long string' + if [[ ${{steps.tagger.outputs.tag}} == *"beta"* ]]; then + PRE_RELEASE="-p" + fi + if [[ ${{steps.tagger.outputs.tag}} == *"alpha"* ]]; then + PRE_RELEASE="-p" + fi + assets=$(find . -name "*${{steps.tagger.outputs.tag}}*.jar" -or -name " *release.aar" | while read -r asset ; do echo "-a $asset" ; done) + set -x + hub release create $PRE_RELEASE ${assets} -m "${{steps.tagger.outputs.tag}}" "${{steps.tagger.outputs.tag}}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{steps.tagger.outputs.tag}} +# - name: Publish ${{steps.tagger.outputs.tag}} +# uses: burrunan/gradle-cache-action@v1.10 +# with: +# remote-build-cache-proxy-enabled: false +# properties: | +# gradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }} +# gradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }} +# arguments: publishPlugins -s --scan From 80d4468393b8db031525b15d7ad72e132e43c943 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Wed, 7 Apr 2021 09:56:52 +0200 Subject: [PATCH 2/2] Version name from git tag --- build.gradle | 187 ++++++++++++++++++++++++++++----------------------- 1 file changed, 104 insertions(+), 83 deletions(-) diff --git a/build.gradle b/build.gradle index 50f8a7e..eae726c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,16 @@ buildscript { - // Executed in context of buildscript - repositories { - // mavenLocal() - mavenCentral() - // jcenter() - // maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } - gradlePluginPortal() - } - - dependencies { - classpath 'org.anarres.gradle:gradle-stdproject-plugin:1.0.10' - } + // Executed in context of buildscript + repositories { + // mavenLocal() + mavenCentral() + // jcenter() + // maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + gradlePluginPortal() + } + + dependencies { + classpath 'org.anarres.gradle:gradle-stdproject-plugin:1.0.10' + } } @@ -19,94 +19,115 @@ stdproject { } subprojects { - version = '1.1.1' - apply plugin: 'org.anarres.stdmodule' - apply plugin: 'eclipse' - stdmodule { - description "Jar Jar Links is a utility that makes it easy to repackage Java libraries and embed them into your own distribution." - author id: 'shevek', name: 'Shevek', email: 'github@anarres.org' - license 'Apache-2.0' - } - - group = "org.anarres.jarjar" - - dependencies { - compile 'com.google.code.findbugs:annotations:3.0.1' - compile 'org.slf4j:slf4j-api:1.7.12' - } - - sourceCompatibility = 1.7 + version = getTag() + apply plugin: 'org.anarres.stdmodule' + apply plugin: 'eclipse' + stdmodule { + description "Jar Jar Links is a utility that makes it easy to repackage Java libraries and embed them into your own distribution." + author id: 'shevek', name: 'Shevek', email: 'github@anarres.org' + license 'Apache-2.0' + } + + group = "org.anarres.jarjar" + + dependencies { + compile 'com.google.code.findbugs:annotations:3.0.1' + compile 'org.slf4j:slf4j-api:1.7.12' + } + + sourceCompatibility = 1.7 } -version = '1.1.1' +version = getTag() project(':jarjar-testdata') { - dependencies { - compile 'com.google.guava:guava:17.0' - } - - for (int i = 0; i < 4; i++) { - String name = "jar$i"; - Task t = task(name, type: Jar) { - classifier = name - from(sourceSets.main.output) { - include "**/pkg$i/**"; - } - } - - artifacts { - archives t - } - } - - uploadArchives.enabled = false + dependencies { + compile 'com.google.guava:guava:17.0' + } + + for (int i = 0; i < 4; i++) { + String name = "jar$i"; + Task t = task(name, type: Jar) { + classifier = name + from(sourceSets.main.output) { + include "**/pkg$i/**"; + } + } + + artifacts { + archives t + } + } + + uploadArchives.enabled = false } project(':jarjar-core') { - dependencies { - compile 'org.ow2.asm:asm-commons:8.0.1' - compile 'org.ow2.asm:asm-util:8.0.1' - // compile 'org.ow2.asm:asm-commons:4.0' - - // testCompile project(':jarjar-testdata') - } - - def samplesProject = project(':jarjar-testdata') - test.dependsOn samplesProject.tasks['assemble'] - test { - systemProperty "jar", samplesProject.jar.archivePath - for (int i = 0; i < 4; i++) { - systemProperty "jar$i", samplesProject."jar$i".archivePath - } - } + dependencies { + compile 'org.ow2.asm:asm-commons:8.0.1' + compile 'org.ow2.asm:asm-util:8.0.1' + // compile 'org.ow2.asm:asm-commons:4.0' + + // testCompile project(':jarjar-testdata') + } + + def samplesProject = project(':jarjar-testdata') + test.dependsOn samplesProject.tasks['assemble'] + test { + systemProperty "jar", samplesProject.jar.archivePath + for (int i = 0; i < 4; i++) { + systemProperty "jar$i", samplesProject."jar$i".archivePath + } + } } project(':jarjar-gradle') { - apply plugin: 'org.anarres.stdplugin' + apply plugin: 'org.anarres.stdplugin' - stdplugin { - implementation "org.anarres.jarjar", "org.anarres.gradle.plugin.jarjar.JarjarPlugin" - } + stdplugin { + implementation "org.anarres.jarjar", "org.anarres.gradle.plugin.jarjar.JarjarPlugin" + } - dependencies { - compile project(':jarjar-core') - compile 'org.apache.commons:commons-compress:1.9' - compile gradleApi() - compile 'oro:oro:2.0.8' + dependencies { + compile project(':jarjar-core') + compile 'org.apache.commons:commons-compress:1.9' + compile gradleApi() + compile 'oro:oro:2.0.8' - testCompile project(':jarjar-core').sourceSets.test.output - } + testCompile project(':jarjar-core').sourceSets.test.output + } } project(':jarjar-command') { - dependencies { - compile project(':jarjar-core') - compile 'net.sf.jopt-simple:jopt-simple:4.8' + dependencies { + compile project(':jarjar-core') + compile 'net.sf.jopt-simple:jopt-simple:4.8' - testCompile project(':jarjar-core').sourceSets.test.output - } + testCompile project(':jarjar-core').sourceSets.test.output + } - apply plugin: 'application' + apply plugin: 'application' - mainClassName = "com.tonicsystems.jarjar.Main" + mainClassName = "com.tonicsystems.jarjar.Main" +} + +static def getTag() { + def tagVersion = "$System.env.VERSION" + if (tagVersion == "null") { + // with local un-commited changes a -DIRTY is added + def processChanges = "git diff-index --name-only HEAD --".execute() + def dirty = "" + if (!processChanges.text.toString().trim().isEmpty()) + dirty = "-DIRTY" + + def process = "git describe --tags".execute() + tagVersion = process.text.toString().trim() + dirty + } else { + def tagVersionToken = tagVersion.split("/") + if (tagVersionToken.size() > 2) + tagVersion = tagVersionToken[2] + else + tagVersion = tagVersionToken[0] + } + return tagVersion }