Skip to content

Commit

Permalink
Release-pipeline-Improvements:Plugin version is now version id plus s…
Browse files Browse the repository at this point in the history
…hort hash
  • Loading branch information
Garlapati Anil Masthan Setty committed Nov 19, 2024
1 parent 0be10a4 commit 3d52843
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 @@ -37,11 +37,18 @@
import org.apache.tools.ant.filters.ReplaceTokens

def pluginName="Ansible-Toolkit-UCD"
def 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'
def buildUtilDir = 'build/util'
Expand Down Expand Up @@ -131,7 +138,7 @@ task copyi18n(type: Copy) {
into outputDir
}

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

0 comments on commit 3d52843

Please sign in to comment.