Skip to content

Commit 9560909

Browse files
authored
Add GitHub release workflow (publish Maven packages) (#4)
* Add maven-release.yml GH workflow file that publishes Maven packages when release is made * Update main pom.xml to include distributionManagement for github_ci
1 parent c697866 commit 9560909

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
2+
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
3+
4+
name: Publish to GitHub Packages Apache Maven (Maven repository)
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
publish:
12+
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
settings-path: ${{ github.workspace }} # location for the settings.xml file
26+
27+
- name: Publish to GitHub Packages Apache Maven
28+
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
29+
env:
30+
GITHUB_TOKEN: ${{ github.token }}

pom.xml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,24 @@
102102
<!-- When pulling, the package index is based on the organization level, not the repository level. -->
103103
<!-- Although GITHUB_REPOSITORY contains repo, all organization packages are indexed there -->
104104
<!-- https://stackoverflow.com/questions/63041402/github-packages-single-maven-repository-for-github-organization -->
105+
<!--suppress UnresolvedMavenProperty -->
105106
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
106107
</repository>
108+
107109
</repositories>
110+
<distributionManagement>
111+
<repository>
112+
<id>github</id>
113+
<!--suppress UnresolvedMavenProperty -->
114+
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
115+
</repository>
116+
<snapshotRepository>
117+
<id>github</id>
118+
<!--suppress UnresolvedMavenProperty -->
119+
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
120+
</snapshotRepository>
121+
</distributionManagement>
122+
108123
</profile>
109124

110125
<profile>
@@ -122,11 +137,13 @@
122137
<distributionManagement>
123138
<!-- env variables are available, when run by gitlab CI -->
124139
<repository>
125-
<id>gitlab.ext.cyber.ee</id>
140+
<id>${env.CI_SERVER_HOST}</id>
141+
<!--suppress UnresolvedMavenProperty -->
126142
<url>${env.CI_SERVER_URL}/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url>
127143
</repository>
128144
<snapshotRepository>
129-
<id>gitlab.ext.cyber.ee</id>
145+
<id>${env.CI_SERVER_HOST}</id>
146+
<!--suppress UnresolvedMavenProperty -->
130147
<url>${env.CI_SERVER_URL}/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url>
131148
</snapshotRepository>
132149
</distributionManagement>

0 commit comments

Comments
 (0)