Skip to content

Commit

Permalink
Add GH action workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
jon5477 committed Nov 27, 2024
1 parent e7fbad6 commit 33b3846
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created

name: Maven Package and Deploy to GitHub Packages

on:
push:
branches: ['master']
release:
types: [created]

jobs:
build:

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'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
12 changes: 12 additions & 0 deletions .github/workflows/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
<connection>scm:git:git@github.com:jon5477/consul-api.git</connection>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>github</id>
<name>GitHub Apache Maven Packages</name>
<url>https://maven.pkg.github.com/jon5477/consul-api</url>
<layout>default</layout>
</repository>
</distributionManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
Expand Down

0 comments on commit 33b3846

Please sign in to comment.