Skip to content

Commit bedfcfe

Browse files
authored
Merge pull request #63 from ApplauseOSS/ci/add-publish-job
ci: add publish workflows
2 parents 1b1416e + 19de281 commit bedfcfe

File tree

2 files changed

+211
-0
lines changed

2 files changed

+211
-0
lines changed

.github/workflows/publish.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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+
uses: hb0730/[email protected]
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 }}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Maven Publish Private
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
javaVersion:
7+
description: "Java version to use"
8+
default: "21"
9+
type: string
10+
mavenProperties:
11+
description: "Maven properties to use"
12+
default: "-DskipGithub=true"
13+
type: string
14+
mavenTasks:
15+
description: "Maven tasks to use"
16+
default: "clean install deploy"
17+
type: string
18+
19+
jobs:
20+
build-and-publish:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v5
24+
- name: Set up JDK ${{ inputs.javaVersion }}
25+
uses: actions/setup-java@v5
26+
with:
27+
java-version: "${{ inputs.javaVersion }}"
28+
distribution: "temurin"
29+
- name: Set up Maven
30+
uses: hb0730/[email protected]
31+
with:
32+
maven-version: 3.8.9
33+
34+
- name: Create Maven settings.xml
35+
run: |
36+
cat << 'EOF' > $HOME/.m2/settings.xml
37+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
38+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
39+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
40+
https://maven.apache.org/xsd/settings-1.0.0.xsd">
41+
<servers>
42+
<server>
43+
<id>s3.applause-private-repo</id>
44+
<username>${{ secrets.APPLAUSE_REPO_USER_NAME }}</username>
45+
<password>${{ secrets.APPLAUSE_REPO_PASSWORD }}</password>
46+
</server>
47+
</servers>
48+
49+
<profiles>
50+
<profile>
51+
<activation>
52+
<activeByDefault>true</activeByDefault>
53+
</activation>
54+
55+
<repositories>
56+
<repository>
57+
<id>applause-repo</id>
58+
<name>Repository for Applause private artifacts</name>
59+
<url>https://repo.applause.com/repository/private</url>
60+
<releases><enabled>true</enabled></releases>
61+
<snapshots><enabled>true</enabled></snapshots>
62+
</repository>
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+
</repositories>
71+
<pluginRepositories>
72+
<pluginRepository>
73+
<id>applause-public-repo</id>
74+
<name>Repository for Applause public artifacts (releases)</name>
75+
<url>https://repo.applause.com/repository/public</url>
76+
<releases><enabled>true</enabled></releases>
77+
<snapshots><enabled>false</enabled></snapshots>
78+
</pluginRepository>
79+
</pluginRepositories>
80+
</profile>
81+
</profiles>
82+
</settings>
83+
EOF
84+
85+
- name: Publish
86+
run: |
87+
mvn ${{ inputs.mavenProperties }} ${{ inputs.mavenTasks }}

0 commit comments

Comments
 (0)