Skip to content

Commit

Permalink
Publish Maven artifacts to dogtagpki/repo
Browse files Browse the repository at this point in the history
Previously LDAP SDK's Maven artifacts were published to GitHub
Packages which is a private repository so it's difficult to use.

To resolve the problem, the pom.xml has been modified to publish
the artifacts to a publicly accessible dogtagpki/repo instead.
  • Loading branch information
edewata committed Jul 9, 2024
1 parent 27d6695 commit 9cc46c9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 17 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
name: Publishing Maven artifacts
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install xmlstarlet
- name: Clone repository
uses: actions/checkout@v4

Expand All @@ -23,15 +28,23 @@ jobs:
java-version: '17'
distribution: 'adopt'

- name: Check settings.xml
- name: Configure settings.xml
run: |
xmlstarlet edit --inplace \
-u "/_:settings/_:servers/_:server[_:id='github']/_:password" \
-v "$REPO_TOKEN" \
~/.m2/settings.xml
cat ~/.m2/settings.xml
env:
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}

- name: Update pom.xml
- name: Configure pom.xml
run: |
sed -i \
-e "s/OWNER/$NAMESPACE/g" \
-e "s/REPOSITORY/ldap-sdk/g" \
xmlstarlet edit --inplace \
-u "/_:project/_:build/_:plugins/_:plugin[_:artifactId='site-maven-plugin']/_:configuration/_:repositoryOwner" \
-v "$NAMESPACE" \
-u "/_:project/_:repositories/_:repository[_:id='dogtagpki']/_:url" \
-v "https://raw.githubusercontent.com/$NAMESPACE/repo/maven" \
pom.xml
cat pom.xml
Expand All @@ -41,8 +54,6 @@ jobs:
--batch-mode \
--update-snapshots \
deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
wait-for-images:
if: vars.REGISTRY != ''
Expand Down
46 changes: 36 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<github.global.server>github</github.global.server>
</properties>

<modules>
Expand Down Expand Up @@ -49,25 +50,50 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<altDeploymentRepository>local::default::file://${project.build.directory}/repo</altDeploymentRepository>
</configuration>
</plugin>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
<configuration>
<message>Deploy ${project.groupId}:${project.artifactId}:${project.version}</message>
<outputDirectory>${project.build.directory}/repo</outputDirectory>
<includes>
<include>**/*</include>
</includes>
<repositoryOwner>dogtagpki</repositoryOwner>
<repositoryName>repo</repositoryName>
<branch>refs/heads/maven</branch>
<merge>true</merge>
</configuration>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/OWNER/*</url>
<id>dogtagpki</id>
<url>https://raw.githubusercontent.com/dogtagpki/repo/maven</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
</repository>
</distributionManagement>

</project>

0 comments on commit 9cc46c9

Please sign in to comment.