Skip to content

Commit

Permalink
Updated build
Browse files Browse the repository at this point in the history
  • Loading branch information
Shabaz Basha Kowthalam committed Nov 4, 2024
1 parent c90a289 commit f34036d
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 3 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/gradle-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Gradle CD

on:
push:
branches: [ "main" ]

jobs:

create-release:

permissions: write-all
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt-openj9'

- 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: Determine next tag version
id: getNextTag
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
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.getNextTag.outputs.value }}" dist

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.getNextTag.outputs.value }}
files: "build/distributions/*.zip"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/gradle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build Gradle Project

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build-gradle-project:

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt-openj9'

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Run build
run: ./gradlew build
14 changes: 11 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import groovy.xml.XmlParser

plugins {
id 'java'
}

version = "1.0"

tasks.register("dist", Zip) {

dependsOn("build")
Expand All @@ -12,10 +12,18 @@ tasks.register("dist", Zip) {
include("*.jar")
}

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"
}

from("src/main/zip") {
include("*.xml")
filter {
it.replace("@RELEASE_VERSION@", "$version")
it.replace("@RELEASE_VERSION@", "$pluginVersion")
}
}

Expand Down

0 comments on commit f34036d

Please sign in to comment.