Skip to content

Commit

Permalink
Publish Maven artifacts to dogtagpki/repo
Browse files Browse the repository at this point in the history
Previously PKI'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 10, 2024
1 parent f92a3f0 commit fe9416f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 19 deletions.
26 changes: 18 additions & 8 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,22 @@ jobs:
java-version: '17'
distribution: 'adopt'

- name: Check settings.xml
- name: Configure settings.xml
run: |
cat ~/.m2/settings.xml
xmlstarlet edit --inplace \
-u "/_:settings/_:servers/_:server[_:id='github']/_:password" \
-v "$REPO_TOKEN" \
~/.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/pki/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 @@ -43,8 +55,6 @@ jobs:
--update-snapshots \
-DskipTests \
deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
wait-for-images:
if: vars.REGISTRY != ''
Expand Down
4 changes: 3 additions & 1 deletion pki.spec
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,10 @@ fi
%pom_disable_module console base
%endif

# flatten-maven-plugin is not available in RPM
# remove plugins not needed to build RPM
%pom_remove_plugin org.codehaus.mojo:flatten-maven-plugin
%pom_remove_plugin org.apache.maven.plugins:maven-deploy-plugin
%pom_remove_plugin com.github.github:site-maven-plugin

# specify Maven artifact locations
%mvn_file org.dogtagpki.pki:pki-common pki/pki-common
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 @@ -69,25 +70,50 @@
</execution>
</executions>
</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 fe9416f

Please sign in to comment.