From dce8ac0eb77a8b9f8333090cbd488eb94cfad1f0 Mon Sep 17 00:00:00 2001 From: Edward Cheng Date: Wed, 28 Aug 2024 18:29:15 +1000 Subject: [PATCH] setup maven settings and github action pipilines for publish --- .../workflows/build-and-publish-release.yml | 49 +++++++++++++++++++ .../workflows/build-and-publish-snapshot.yml | 40 +++++++++++++++ .mvn/settings.xml | 23 +++++++++ 3 files changed, 112 insertions(+) create mode 100644 .github/workflows/build-and-publish-release.yml create mode 100644 .github/workflows/build-and-publish-snapshot.yml create mode 100644 .mvn/settings.xml diff --git a/.github/workflows/build-and-publish-release.yml b/.github/workflows/build-and-publish-release.yml new file mode 100644 index 0000000..38366c8 --- /dev/null +++ b/.github/workflows/build-and-publish-release.yml @@ -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/*.* \ No newline at end of file diff --git a/.github/workflows/build-and-publish-snapshot.yml b/.github/workflows/build-and-publish-snapshot.yml new file mode 100644 index 0000000..e21841d --- /dev/null +++ b/.github/workflows/build-and-publish-snapshot.yml @@ -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/*.* \ No newline at end of file diff --git a/.mvn/settings.xml b/.mvn/settings.xml new file mode 100644 index 0000000..a585242 --- /dev/null +++ b/.mvn/settings.xml @@ -0,0 +1,23 @@ + + + + publish + + maven-snapshots::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL} + maven-releases::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL} + + + + + + github + ${env.GITHUB_ACTOR} + ${env.GITHUB_TOKEN} + + + nexus + ${env.NEXUS_USERNAME} + ${env.NEXUS_PASSWORD} + + + \ No newline at end of file