|
| 1 | +on: |
| 2 | + workflow_call: |
| 3 | + inputs: |
| 4 | + javaVersion: |
| 5 | + description: "Java version to use" |
| 6 | + default: "21" |
| 7 | + type: string |
| 8 | + mavenProperties: |
| 9 | + description: "Maven properties to use" |
| 10 | + default: "-DskipGithub=true" |
| 11 | + type: string |
| 12 | + mavenTasks: |
| 13 | + description: "Maven tasks to use" |
| 14 | + default: "clean install deploy" |
| 15 | + type: string |
| 16 | + branch: |
| 17 | + description: "Branch to publish to" |
| 18 | + default: "master" |
| 19 | + type: string |
| 20 | + |
| 21 | +jobs: |
| 22 | + publish: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v5 |
| 26 | + - name: Set up JDK ${{ inputs.javaVersion }} |
| 27 | + uses: actions/setup-java@v5 |
| 28 | + with: |
| 29 | + java-version: "${{ inputs.javaVersion }}" |
| 30 | + distribution: "temurin" |
| 31 | + - name: Set up Maven |
| 32 | + |
| 33 | + with: |
| 34 | + maven-version: 3.8.2 |
| 35 | + - name: Create Maven settings.xml |
| 36 | + run: | |
| 37 | + cat << 'EOF' > $HOME/.m2/settings.xml |
| 38 | + <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" |
| 39 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 40 | + xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 |
| 41 | + https://maven.apache.org/xsd/settings-1.0.0.xsd"> |
| 42 | + <servers> |
| 43 | + <server> |
| 44 | + <id>s3.applause-public-repo</id> |
| 45 | + <username>${{ secrets.APPLAUSE_REPO_USER_NAME }}</username> |
| 46 | + <password>${{ secrets.APPLAUSE_REPO_PASSWORD }}</password> |
| 47 | + </server> |
| 48 | + <server> |
| 49 | + <id>s3.applause-public-snapshots</id> |
| 50 | + <username>${{ secrets.APPLAUSE_REPO_USER_NAME }}</username> |
| 51 | + <password>${{ secrets.APPLAUSE_REPO_PASSWORD }}</password> |
| 52 | + </server> |
| 53 | + </servers> |
| 54 | +
|
| 55 | +
|
| 56 | + <profiles> |
| 57 | + <profile> |
| 58 | + <activation> |
| 59 | + <activeByDefault>true</activeByDefault> |
| 60 | + </activation> |
| 61 | +
|
| 62 | + <repositories> |
| 63 | + <repository> |
| 64 | + <id>applause-public-repo</id> |
| 65 | + <name>Repository for Applause public artifacts (releases)</name> |
| 66 | + <url>https://repo.applause.com/repository/public</url> |
| 67 | + <releases><enabled>true</enabled></releases> |
| 68 | + <snapshots><enabled>false</enabled></snapshots> |
| 69 | + </repository> |
| 70 | + <repository> |
| 71 | + <id>applause-public-snapshots</id> |
| 72 | + <name>Repository for Applause public artifacts (snapshots)</name> |
| 73 | + <url>https://repo.applause.com/repository/snapshots</url> |
| 74 | + <releases><enabled>false</enabled></releases> |
| 75 | + <snapshots><enabled>true</enabled></snapshots> |
| 76 | + </repository> |
| 77 | + </repositories> |
| 78 | + <pluginRepositories> |
| 79 | + <pluginRepository> |
| 80 | + <id>applause-public-repo</id> |
| 81 | + <name>Repository for Applause public artifacts (releases)</name> |
| 82 | + <url>https://repo.applause.com/repository/public</url> |
| 83 | + <releases><enabled>true</enabled></releases> |
| 84 | + <snapshots><enabled>false</enabled></snapshots> |
| 85 | + </pluginRepository> |
| 86 | + </pluginRepositories> |
| 87 | + </profile> |
| 88 | + </profiles> |
| 89 | + </settings> |
| 90 | + EOF |
| 91 | +
|
| 92 | + - name: Publish |
| 93 | + run: | |
| 94 | + # Parse our version using build-helper and versions to strip SNAPSHOT |
| 95 | + mvn build-helper:parse-version versions:set -DgenerateBackupPoms=false -DnewVersion=\\${parsedVersion.majorVersion}.\\${parsedVersion.minorVersion}.\\${parsedVersion.incrementalVersion} |
| 96 | +
|
| 97 | + # Write the current version |
| 98 | + mvn help:evaluate -q -Dexpression=project.version -DforceStdout=true | tail -n 1 | tee VERSION |
| 99 | +
|
| 100 | + mvn ${{ inputs.mavenProperties }} ${{ inputs.mavenTasks }} |
| 101 | +
|
| 102 | + VERSION=`cat VERSION` |
| 103 | +
|
| 104 | + # Remove the org from the repo name |
| 105 | + GITHUB_REPO_NAME=${GITHUB_REPOSITORY#*/} |
| 106 | +
|
| 107 | + git config --global --add safe.directory `pwd -P` |
| 108 | + git commit -am "GHA: release version \${VERSION}" |
| 109 | + git tag v\${VERSION} -am "GHA: publish public-$GITHUB_REPO_NAME v\${VERSION}" |
| 110 | + git log -1 |
| 111 | + # git push origin v\${VERSION} |
| 112 | + # git push origin HEAD:${{ inputs.branch }} |
| 113 | +
|
| 114 | + # Increment incremental version and set SNAPSHOT |
| 115 | + mvn build-helper:parse-version versions:set -DgenerateBackupPoms=false -DnewVersion=\\${parsedVersion.majorVersion}.\\${parsedVersion.minorVersion}.\\${parsedVersion.nextIncrementalVersion}-SNAPSHOT |
| 116 | +
|
| 117 | + # Write the SNAPSHOT version to VERSION |
| 118 | + mvn help:evaluate -q -Dexpression=project.version -DforceStdout=true | tail -n 1 | tee VERSION |
| 119 | +
|
| 120 | + # Looks good! Now, for the git-fu for our SNAPSHOT version |
| 121 | + VERSION=`cat VERSION` |
| 122 | + git commit -am "GHA: SNAPSHOT version \${VERSION}" |
| 123 | + git diff HEAD^ HEAD |
| 124 | + # git push origin HEAD:${{ inputs.branch }} |
0 commit comments