Skip to content

Commit f0b20b6

Browse files
committed
RM-3338: backport maven-release.yml from jann0k:gh_release_actions
1 parent 69dbdd7 commit f0b20b6

File tree

3 files changed

+104
-35
lines changed

3 files changed

+104
-35
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 }}

.github/workflows/maven.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# separate terms of service, privacy policy, and support
77
# documentation.
88

9-
name: Java CI with Maven
9+
name: Build cdoc2-java-ref-impl with CI
1010

1111
on:
1212
push:
@@ -23,24 +23,22 @@ jobs:
2323
runs-on: ubuntu-latest
2424

2525
steps:
26-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2727
- name: Set up JDK 17
28-
uses: actions/setup-java@v3
28+
uses: actions/setup-java@v4
2929

3030
with:
3131
java-version: '17'
3232
distribution: 'temurin'
33+
overwrite-settings: true #generate settings.xml
3334
cache: maven
34-
- name: Debug settings.xml
35-
run: |
36-
echo $(cat ~/.m2/settings.xml)
37-
echo $env.GITHUB_ACTOR
3835

3936
- name: Build with Maven
4037
run: mvn -B package --file pom.xml
4138
env:
4239
GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password
4340

41+
4442
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
4543
#- name: Update dependency graph
4644
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6

pom.xml

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,12 @@
2626
<!-- https://docs.spring.io/spring-boot/docs/current/reference/html/dependency-versions
2727
.html-->
2828
<junit-jupiter.version>5.10.2</junit-jupiter.version>
29-
<lombok.version>1.18.32</lombok.version>
3029
<logback-classic.version>1.5.6</logback-classic.version>
3130
<exec-maven-plugin.version>3.2.0</exec-maven-plugin.version>
3231
<maven-shade-plugin.version>3.5.2</maven-shade-plugin.version>
3332
<bouncycastle.version>1.78.1</bouncycastle.version>
3433
<spring-boot.version>3.2.5</spring-boot.version>
3534
<spring.version>6.1.6</spring.version>
36-
<gatling.version>3.10.5</gatling.version>
37-
<gatling-maven-plugin.version>4.8.2</gatling-maven-plugin.version>
38-
3935
</properties>
4036

4137
<profiles>
@@ -88,35 +84,80 @@
8884
</plugins>
8985
</build>
9086
</profile>
91-
</profiles>
9287

93-
<!-- Configuration for Maven Release plugin -->
94-
<scm>
95-
<connection>scm:git:${project.scm.url}</connection>
96-
<developerConnection>scm:git:${project.scm.url}</developerConnection>
97-
<url>[email protected]:jann0k/cdoc2-java-ref-impl-private.git</url>
98-
<tag>HEAD</tag>
99-
</scm>
88+
<profile>
89+
<!-- activate github profile when run by github actions -->
90+
<id>github_ci</id>
91+
<activation>
92+
<property>
93+
<name>env.GITHUB_ACTIONS</name>
94+
<value>true</value>
95+
</property>
96+
</activation>
97+
<repositories>
98+
<repository>
99+
<!-- must have matching server.id in settings.xml -->
100+
<!-- github actions/checkout default for server-id is "github"-->
101+
<id>github</id>
102+
<!-- When pulling, the package index is based on the organization level, not the repository level. -->
103+
<!-- Although GITHUB_REPOSITORY contains repo, all organization packages are indexed there -->
104+
<!-- https://stackoverflow.com/questions/63041402/github-packages-single-maven-repository-for-github-organization -->
105+
<!--suppress UnresolvedMavenProperty -->
106+
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
107+
</repository>
108+
109+
</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+
123+
</profile>
124+
125+
<profile>
126+
<!-- set gitlab.ext profile active when run by gitlab CI -->
127+
<id>gitlab_ci</id>
128+
<activation>
129+
<property>
130+
<name>env.GITLAB_CI</name>
131+
<value>true</value>
132+
</property>
133+
</activation>
134+
<!-- repositories are configured in settings.xml -->
135+
<!--repositories></repositories-->
136+
137+
<distributionManagement>
138+
<!-- env variables are available, when run by gitlab CI -->
139+
<repository>
140+
<id>gitlab.ext.cyber.ee</id>
141+
<!--suppress UnresolvedMavenProperty -->
142+
<url>${env.CI_SERVER_URL}/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url>
143+
</repository>
144+
<snapshotRepository>
145+
<id>gitlab.ext.cyber.ee</id>
146+
<!--suppress UnresolvedMavenProperty -->
147+
<url>${env.CI_SERVER_URL}/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url>
148+
</snapshotRepository>
149+
</distributionManagement>
150+
</profile>
151+
</profiles>
100152

101153
<repositories>
102-
<repository>
103-
<id>gitlab.ext.cyber.ee</id>
104-
<url>https://gitlab.ext.cyber.ee/api/v4/projects/39/packages/maven</url>
105-
</repository>
154+
<!-- for local development, configure your settings.xml-->
155+
<!--repository>
156+
<id>github</id>
157+
<url>https://maven.pkg.github.com/open-eid/cdoc2-capsule-server</url>
158+
</repository-->
106159
</repositories>
107160

108-
<distributionManagement>
109-
<repository>
110-
<id>gitlab.ext.cyber.ee</id>
111-
<url>https://gitlab.ext.cyber.ee/api/v4/projects/40/packages/maven</url>
112-
</repository>
113-
114-
<snapshotRepository>
115-
<id>gitlab.ext.cyber.ee</id>
116-
<url>https://gitlab.ext.cyber.ee/api/v4/projects/40/packages/maven</url>
117-
</snapshotRepository>
118-
</distributionManagement>
119-
120161
<modules>
121162
<module>cdoc2-schema</module>
122163
<module>cdoc2-lib</module>

0 commit comments

Comments
 (0)