diff --git a/.github/workflows/gradle-cd.yml b/.github/workflows/gradle-cd.yml index 065ab59..2443ca1 100644 --- a/.github/workflows/gradle-cd.yml +++ b/.github/workflows/gradle-cd.yml @@ -2,8 +2,7 @@ name: Gradle CD on: push: - tags: - - '*' + branches: [ "master" ] jobs: @@ -22,28 +21,45 @@ jobs: java-version: '8' distribution: 'adopt-openj9' - - name: Grant execute permission for gradlew - run: chmod +x ./gradlew + - name: Set up Git + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Fetch all tags + run: git fetch --tags - - name: Get short commit SHA - id: getShortHash - run: echo "shortHash=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_OUTPUT + - name: Determine next tag version + id: getNextTag + run: | + # Get version from plugin.xml + pluginXmlVersion=$(grep -oP '> $GITHUB_OUTPUT + # Determine next tag + if awk "BEGIN {exit !( $latestTag < $pluginXmlVersion )}"; then + nextTag="$pluginXmlVersion.0" + else + nextTag=$(awk "BEGIN {print $latestTag + 0.1}") + fi - - name: Echo Plugin Version - run: echo "${{ steps.getPluginVersion.outputs.pluginVersion }}" + echo "nextTag is $nextTag" + echo "value=$nextTag" >> $GITHUB_OUTPUT + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew - name: Create dist - run: ./gradlew "-PpluginVersion=${{ steps.getPluginVersion.outputs.pluginVersion }}" distPlugin + run: ./gradlew "-PpluginVersion=${{ steps.getNextTag.outputs.value }}" distPlugin - - name: Create Release - uses: ncipollo/release-action@v1.12.0 + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 with: - name: "${{ github.event.repository.name }} v${{ steps.getPluginVersion.outputs.pluginVersion }}" - artifacts: "build/distributions/*.zip" + tag_name: ${{ steps.getNextTag.outputs.value }} + files: "build/distributions/*.zip" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 220fce2..a72cff4 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ This plug-in requires version 6.2.2 (or later) of IBM UrbanCode Deploy. * Use wrapper script `gradlew/gradle.bat` to build the project locally. * To create distributable with a plugin release version pass property `pluginVersion` while running wrapper script like below -> ./gradlew "-PpluginVersion=7.24072024" +> ./gradlew "-PpluginVersion=6.9" ### Installation The packaged zip is located in the 'Releases' tab. No special steps are required for installation. diff --git a/build.gradle b/build.gradle index a518cef..c666322 100644 --- a/build.gradle +++ b/build.gradle @@ -122,7 +122,7 @@ tasks.register('distPlugin', Zip) { exclude 'META-INF', 'i18n-scraper.groovy' } - archiveFileName = pluginVersion ? "${pluginName}-v${pluginVersion}.zip" : "${pluginName}-dev.zip" + archiveFileName = "${pluginName}-${pluginVersion}.zip" } tasks.register('gatherI18n', JavaExec) { @@ -134,14 +134,6 @@ tasks.register('gatherI18n', JavaExec) { classpath = sourceSets.main.runtimeClasspath } -tasks.register('writePluginVersionToFile') { - File pluginXml = new File('./src/main/zip/plugin.xml') - def plugin = new XmlParser().parse(pluginXml) - String[] version = plugin.header.identifier.@version - File file = new File(".output.txt") - file.write version[0] -} - tasks.register('cleanAll') { dependsOn('clean', 'cleanCopyDeps', 'cleanDistPlugin', 'cleanGatherI18n') }