Skip to content

Commit

Permalink
Fix branch publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaldassari committed Aug 3, 2023
1 parent 2feb59b commit 6f07557
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ jobs:
run: |
echo "java: $(java -version)"
- name: Extract branch name
shell: bash
run: echo "BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV

- name: Build and test
run: ./gradlew test --console plain

- name: Publish artifacts
run: ./gradlew publish
run: ./gradlew publish -x test -Pbranch="$BRANCH"
14 changes: 4 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@ ext {
baseVersion = '1.0.0'

getBranch = {
return "${System.getenv('GITHUB_HEAD_REF') ?: ''}"
return project.findProperty('branch') ?: ''
}

getUsername = {
return System.properties['user.name']
}

determineProjectVersion = { baseVersion, branch, username ->
determineProjectVersion = { baseVersion, branch ->
projectVersion = baseVersion
if (!branch.equals("main")) {
if (branch.isEmpty()) {
projectVersion = "${projectVersion}-${username}"
} else {
if (!branch.isEmpty()) {
projectVersion = "${projectVersion}-${branch}"
}
projectVersion = "${projectVersion}-SNAPSHOT"
Expand All @@ -37,7 +31,7 @@ ext {

group = 'com.mabl'
archivesBaseName = 'pac-interpreter'
version = determineProjectVersion(baseVersion, getBranch(), getUsername())
version = determineProjectVersion(baseVersion, getBranch())

java {
toolchain {
Expand Down

0 comments on commit 6f07557

Please sign in to comment.