Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub release workflow (publish Maven packages) #4

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path

name: Publish to GitHub Packages Apache Maven (Maven repository)

on:
release:
types: [created]

jobs:
publish:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
21 changes: 19 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,24 @@
<!-- When pulling, the package index is based on the organization level, not the repository level. -->
<!-- Although GITHUB_REPOSITORY contains repo, all organization packages are indexed there -->
<!-- https://stackoverflow.com/questions/63041402/github-packages-single-maven-repository-for-github-organization -->
<!--suppress UnresolvedMavenProperty -->
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
</repository>

</repositories>
<distributionManagement>
<repository>
<id>github</id>
<!--suppress UnresolvedMavenProperty -->
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
</repository>
<snapshotRepository>
<id>github</id>
<!--suppress UnresolvedMavenProperty -->
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
</snapshotRepository>
</distributionManagement>

</profile>

<profile>
Expand All @@ -122,11 +137,13 @@
<distributionManagement>
<!-- env variables are available, when run by gitlab CI -->
<repository>
<id>gitlab.ext.cyber.ee</id>
<id>${env.CI_SERVER_HOST}</id>
<!--suppress UnresolvedMavenProperty -->
<url>${env.CI_SERVER_URL}/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab.ext.cyber.ee</id>
<id>${env.CI_SERVER_HOST}</id>
<!--suppress UnresolvedMavenProperty -->
<url>${env.CI_SERVER_URL}/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url>
</snapshotRepository>
</distributionManagement>
Expand Down