setup maven settings and github action pipilines for publish

This commit is contained in:
2024-08-28 18:29:15 +10:00
parent 2f3d719953
commit dce8ac0eb7
3 changed files with 112 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
name: RELEASE - Build and Publish
on:
workflow_dispatch:
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
packages: write
name: Build and Publish
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3.13.0
with:
distribution: zulu
java-version: 17
- name: Config Git
run: |
git config --global user.email "edward@cheng.sydney"
git config --global user.name "3dwardch3ng"
git config --global core.autocrlf input
- name: Start release
run: mvn gitflow:release-start -B -DpushRemote=true -DallowSnapshots=true
- name: Maven Publish
env:
GITHUB_ACTOR: '3dwardch3ng'
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NEXUS_USERNAME: 'edward'
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
DEPLOYMENT_REPOSITORY_ID: ${{ secrets.DEPLOYMENT_REPOSITORY_ID }}
SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }}
RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }}
run: |
mvn -X -B deploy -P publish \
--settings=${{ github.workspace }}/.mvn/settings.xml
- name: Finish release
run: mvn gitflow:release-finish -B -DpushRemote=true -DallowSnapshots=true
env:
GITHUB_ACTOR: 3dwardch3ng
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- uses: actions/upload-artifact@v3.1.3
if: always()
with:
name: Java Artifacts
path: ${{ github.workspace }}/**/target/*.*

View File

@@ -0,0 +1,40 @@
name: SNAPSHOT - Build and Publish
on:
workflow_dispatch:
push:
branches:
- develop
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
packages: write
name: Build and Publish
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3.13.0
with:
distribution: zulu
java-version: 17
- name: Maven Publish
env:
GITHUB_ACTOR: '3dwardch3ng'
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NEXUS_USERNAME: 'edward'
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
DEPLOYMENT_REPOSITORY_ID: ${{ secrets.DEPLOYMENT_REPOSITORY_ID }}
SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }}
RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }}
run: |
mvn -X -B deploy -P publish \
--settings=${{ github.workspace }}/.mvn/settings.xml
- uses: actions/upload-artifact@v3.1.3
if: always()
with:
name: Java Artifacts
path: ${{ github.workspace }}/**/target/*.*

23
.mvn/settings.xml Normal file
View File

@@ -0,0 +1,23 @@
<settings>
<profiles>
<profile>
<id>publish</id>
<properties>
<altSnapshotDeploymentRepository>maven-snapshots::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL}</altSnapshotDeploymentRepository>
<altReleaseDeploymentRepository>maven-releases::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL}</altReleaseDeploymentRepository>
</properties>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
<server>
<id>nexus</id>
<username>${env.NEXUS_USERNAME}</username>
<password>${env.NEXUS_PASSWORD}</password>
</server>
</servers>
</settings>