Skip to content

Commit

Permalink
Plugin version is now version id plus short hash (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
shabaz213 authored Nov 19, 2024
1 parent b38f204 commit ba22e53
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
31 changes: 10 additions & 21 deletions .github/workflows/gradle-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,29 @@ jobs:
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: Determine next tag version
id: getNextTag
- name: Determine plugin version
id: getPluginVersion
run: |
# Get version from plugin.xml
pluginXmlVersion=$(grep -oP '<identifier .* version="\K[^"]+' src/main/zip/plugin.xml)
echo "pluginXmlVersion is $pluginXmlVersion"
# Get the latest tag
latestTag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "latestTag is $latestTag"
# Determine next tag
if awk "BEGIN {exit !( $latestTag < $pluginXmlVersion )}"; then
nextTag="$pluginXmlVersion.0"
else
nextTag=$(awk "BEGIN {print $latestTag + 0.1}")
fi
# Get the latest short hash
latestShortHash=$(git rev-parse --short $GITHUB_SHA)
echo "latest short hash is $latestShortHash"
echo "nextTag is $nextTag"
echo "value=$nextTag" >> $GITHUB_OUTPUT
echo "value=$pluginXmlVersion.$latestShortHash" >> $GITHUB_OUTPUT
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Create dist
run: ./gradlew "-PpluginVersion=${{ steps.getNextTag.outputs.value }}" distPlugin
- name: Create plugin zip
run: ./gradlew "-PpluginVersion=${{ steps.getPluginVersion.outputs.value }}"

- name: Create GitHub Release
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.getNextTag.outputs.value }}
tag_name: ${{ steps.getPluginVersion.outputs.value }}
files: "build/distributions/*.zip"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 10 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
import org.apache.tools.ant.filters.ReplaceTokens

String pluginName = "IBM-MQ-zOS-UCD"
String pluginVersion = project.hasProperty('pluginVersion') ? project.getProperty('pluginVersion') : 'dev'

String pluginVersion
if (project.hasProperty('pluginVersion')) {
pluginVersion = project.getProperty('pluginVersion')
} else {
def pluginNode = new XmlParser().parse(new File('src/main/zip/plugin.xml'))
pluginVersion = "${pluginNode.header.identifier.@version[0]}.dev"
}

apply plugin: 'groovy'

defaultTasks 'distPlugin'
defaultTasks("dist")

def buildLocaleDir = 'build/locale'

Expand Down Expand Up @@ -101,7 +108,7 @@ tasks.register('copyi18n', Copy) {
into outputDir
}

tasks.register('distPlugin', Zip) {
tasks.register('dist', Zip) {
dependsOn('compileGroovy', 'gatherI18n')
from(sourceSets.zip.groovy.srcDirs) {
filter(ReplaceTokens, tokens: [RELEASE_VERSION: pluginVersion])
Expand Down

0 comments on commit ba22e53

Please sign in to comment.