Skip to content

Commit

Permalink
Add GitHub Workflows for building the develop branch and for releasin…
Browse files Browse the repository at this point in the history
…g v*.*.* tags. (#3)
  • Loading branch information
andylassiter authored Feb 6, 2024
1 parent 3ee365c commit 9312976
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 44 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Develop

on:
push:
branches:
- develop

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'zulu'
java-package: jdk

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 6.7

- name: Build JAR with Gradle Wrapper
run: ./gradlew clean jar

- name: Upload JAR
uses: actions/upload-artifact@v4
with:
name: pixi-plugin-jar
path: build/libs/*.jar
retention-days: 14
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

jobs:

release:

runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v4

- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'zulu'
java-package: jdk

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 6.7

- name: Build JAR with Gradle Wrapper
run: ./gradlew clean jar

- name: Publish Release
uses: softprops/action-gh-release@v1
with:
files: build/libs/*.jar
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') }}
body: The plugin JAR is attached to this release.
59 changes: 15 additions & 44 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
id "java"
id "org.nrg.xnat.build.xnat-data-builder" version "1.8.9"
id "io.freefair.lombok" version "6.0.0-m2"
id "com.palantir.git-version" version "0.12.1"
}

group "org.nrg.xnatx.plugins"
Expand Down Expand Up @@ -57,54 +56,26 @@ test {
useJUnit()
}

// Pulls in the Jenkins BUILD_NUMBER environment variable if available.
def buildDate = new Date()
def buildNumber = System.getenv().BUILD_NUMBER?.toInteger() ?: "Manual"
def isDirty, branchName, gitHash, gitHashFull, commitDistance, lastTag, isCleanTag

try {
def gitDetails = versionDetails()
isDirty = gitVersion().endsWith ".dirty"
branchName = gitDetails.branchName ?: "Unknown"
gitHash = gitDetails.gitHash
gitHashFull = gitDetails.gitHashFull
commitDistance = gitDetails.commitDistance
lastTag = gitDetails.lastTag
isCleanTag = gitDetails.isCleanTag
} catch (IllegalArgumentException ignored) {
logger.info "Got an error trying to read VCS metadata from git. It's possible this project is not under VCS control. Using placeholder values for manifest entries."
isDirty = true
branchName = "Unknown"
gitHash = "None"
gitHashFull = "None"
commitDistance = 0
lastTag = "None"
isCleanTag = false
}

logger.info "Build-Date: ${buildDate}"
logger.info "Build-Number: ${buildNumber}"
logger.info "Implementation-Version: ${version}"
logger.info "Implementation-Sha-Full: ${gitHashFull}"
logger.info "Implementation-Sha: ${gitHash}"
logger.info "Implementation-Commit: ${commitDistance}"
logger.info "Implementation-LastTag: ${lastTag}"
logger.info "Implementation-Branch: ${branchName}"
logger.info "Implementation-CleanTag: ${isCleanTag}"
logger.info "Implementation-Dirty: ${isDirty}"
// Pulls in GitHub Actions environment variables if available.
def github_actor = System.getenv().GITHUB_ACTOR ?: "Unknown"
def github_repo = System.getenv().GITHUB_REPOSITORY ?: "Unknown"
def github_sha = System.getenv().GITHUB_SHA ?: "Unknown"
def github_ref = System.getenv().GITHUB_REF ?: "Unknown"

logger.info("Building plugin: ${project.name} ${project.version} on ${buildDate}")
logger.info("GitHub actor: ${github_actor}")
logger.info("GitHub repository: ${github_repo}")
logger.info("GitHub SHA: ${github_sha}")
logger.info("GitHub ref: ${github_ref}")

ext.gitManifest = manifest {
attributes "Application-Name": "PIXI-PLUGIN",
"Build-Date": buildDate,
"Build-Number": buildNumber,
"Implementation-Version": project.version,
"Implementation-Sha": gitHash,
"Implementation-Sha-Full": gitHashFull,
"Implementation-Commit": commitDistance,
"Implementation-LastTag": lastTag,
"Implementation-Branch": branchName,
"Implementation-CleanTag": isCleanTag,
"Implementation-Dirty": isDirty
"GITHUB-ACTOR": github_actor,
"GITHUB-REPO": github_repo,
"GITHUB-SHA": github_sha,
"GITHUB-REF": github_ref
}

// Configure the compileJava task to call the xnatDataBuilder task before trying to compile any
Expand Down

0 comments on commit 9312976

Please sign in to comment.