diff --git a/.github/workflows/build-and-publish-develop.yml b/.github/workflows/build-and-publish-develop.yml index a091a76..8f4c565 100644 --- a/.github/workflows/build-and-publish-develop.yml +++ b/.github/workflows/build-and-publish-develop.yml @@ -7,6 +7,11 @@ on: - develop env: + NEXUS_USERNAME: 'edward' + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + MAVEN_PUBLIC_REPOSITORY_URL: ${{ secrets.MAVEN_PUBLIC_REPOSITORY_URL }} + SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }} + RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }} REGISTRY_IMAGE: edeedeeed/ec-config-server jobs: @@ -22,19 +27,44 @@ jobs: with: fetch-depth: 0 - uses: actions/setup-java@v4.2.2 + if: ${{ hashFiles('**/pom.xml') }} with: - distribution: zulu java-version: 17 + distribution: zulu + cache: 'maven' + - name: maven-settings-xml-action + uses: whelk-io/maven-settings-xml-action@v22 + with: + profiles: > + [{ + "id": "homelab", + "properties": { + "altSnapshotDeploymentRepository": "nexus-snapshot::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL}", + "altReleaseDeploymentRepository": "nexus-release::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL}" + } + }] + repositories: > + [{ + "id": "maven-public", + "url": "${env.MAVEN_PUBLIC_REPOSITORY_URL}", + "snapshots": { + "enabled": "true" + } + }] + servers: > + [{ + "id": "nexus-snapshot", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }, + { + "id": "nexus-release", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }] - name: Maven Publish - env: - NEXUS_USERNAME: 'edward' - NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }} - RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }} run: | - mvn -B deploy \ - -P homelab \ - --settings=${{ github.workspace }}/.mvn/settings.xml + mvn -B deploy -P homelab build-docker: runs-on: ubuntu-latest strategy: @@ -48,19 +78,44 @@ jobs: with: fetch-depth: 0 - uses: actions/setup-java@v4.2.2 + if: ${{ hashFiles('**/pom.xml') }} with: - distribution: zulu java-version: 17 + distribution: zulu + cache: 'maven' + - name: maven-settings-xml-action + uses: whelk-io/maven-settings-xml-action@v22 + with: + profiles: > + [{ + "id": "homelab", + "properties": { + "altSnapshotDeploymentRepository": "nexus-snapshot::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL}", + "altReleaseDeploymentRepository": "nexus-release::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL}" + } + }] + repositories: > + [{ + "id": "maven-public", + "url": "${env.MAVEN_PUBLIC_REPOSITORY_URL}", + "snapshots": { + "enabled": "true" + } + }] + servers: > + [{ + "id": "nexus-snapshot", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }, + { + "id": "nexus-release", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }] - name: Maven Package - env: - NEXUS_USERNAME: 'edward' - NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }} - RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }} run: | - mvn -B package \ - -P homelab \ - --settings=${{ github.workspace }}/.mvn/settings.xml + mvn -B package -P homelab - name: Prepare run: | platform=${{ matrix.platform }} @@ -108,18 +163,45 @@ jobs: with: fetch-depth: 0 - uses: actions/setup-java@v4.2.2 + if: ${{ hashFiles('**/pom.xml') }} with: - distribution: zulu java-version: 17 + distribution: zulu + cache: 'maven' + - name: maven-settings-xml-action + uses: whelk-io/maven-settings-xml-action@v22 + with: + profiles: > + [{ + "id": "homelab", + "properties": { + "altSnapshotDeploymentRepository": "nexus-snapshot::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL}", + "altReleaseDeploymentRepository": "nexus-release::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL}" + } + }] + repositories: > + [{ + "id": "maven-public", + "url": "${env.MAVEN_PUBLIC_REPOSITORY_URL}", + "snapshots": { + "enabled": "true" + } + }] + servers: > + [{ + "id": "nexus-snapshot", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }, + { + "id": "nexus-release", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }] - name: Extract Maven project version id: project-version - env: - NEXUS_USERNAME: 'edward' - NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }} - RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }} run: | - VERSION=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout -P homelab --settings=${{ github.workspace }}/.mvn/settings.xml) + VERSION=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout -P homelab ) echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Show extracted Maven project version run: echo ${{ steps.project-version.outputs.version }} diff --git a/.github/workflows/build-and-publish-release.yml b/.github/workflows/build-and-publish-release.yml index 57308f4..257b401 100644 --- a/.github/workflows/build-and-publish-release.yml +++ b/.github/workflows/build-and-publish-release.yml @@ -7,6 +7,11 @@ on: - main env: + NEXUS_USERNAME: 'edward' + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + MAVEN_PUBLIC_REPOSITORY_URL: ${{ secrets.MAVEN_PUBLIC_REPOSITORY_URL }} + SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }} + RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }} REGISTRY_IMAGE: edeedeeed/ec-config-server jobs: @@ -22,48 +27,60 @@ jobs: with: fetch-depth: 0 - uses: actions/setup-java@v4.2.2 + if: ${{ hashFiles('**/pom.xml') }} with: - distribution: zulu java-version: 17 + distribution: zulu + cache: 'maven' + - name: maven-settings-xml-action + uses: whelk-io/maven-settings-xml-action@v22 + with: + profiles: > + [{ + "id": "homelab", + "properties": { + "altSnapshotDeploymentRepository": "nexus-snapshot::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL}", + "altReleaseDeploymentRepository": "nexus-release::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL}" + } + }] + repositories: > + [{ + "id": "maven-public", + "url": "${env.MAVEN_PUBLIC_REPOSITORY_URL}", + "snapshots": { + "enabled": "true" + } + }] + servers: > + [{ + "id": "nexus-snapshot", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }, + { + "id": "nexus-release", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }] - 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 - env: - NEXUS_USERNAME: 'edward' - NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }} - RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }} run: | mvn -X gitflow:release-start -B -DpushRemote=true -DallowSnapshots=true \ - -P homelab \ - --settings=${{ github.workspace }}/.mvn/settings.xml + -P homelab - name: Maven Publish - env: - NEXUS_USERNAME: 'edward' - NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }} - RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }} run: | - mvn -B deploy \ - -P homelab \ - --settings=${{ github.workspace }}/.mvn/settings.xml + mvn -B deploy -P homelab - name: Finish release env: GITHUB_ACTOR: 3dwardch3ng GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - NEXUS_USERNAME: 'edward' - NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }} - RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }} run: | - mvn -X gitflow:release-finish -B -DpushRemote=true -DallowSnapshots=true \ - -P homelab \ - --settings=${{ github.workspace }}/.mvn/settings.xml + mvn -X gitflow:release-finish -B -DpushRemote=true -DallowSnapshots=true -P homelab build-docker: - if: false runs-on: ubuntu-latest strategy: fail-fast: false @@ -76,19 +93,44 @@ jobs: with: fetch-depth: 0 - uses: actions/setup-java@v4.2.2 + if: ${{ hashFiles('**/pom.xml') }} with: - distribution: zulu java-version: 17 + distribution: zulu + cache: 'maven' + - name: maven-settings-xml-action + uses: whelk-io/maven-settings-xml-action@v22 + with: + profiles: > + [{ + "id": "homelab", + "properties": { + "altSnapshotDeploymentRepository": "nexus-snapshot::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL}", + "altReleaseDeploymentRepository": "nexus-release::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL}" + } + }] + repositories: > + [{ + "id": "maven-public", + "url": "${env.MAVEN_PUBLIC_REPOSITORY_URL}", + "snapshots": { + "enabled": "true" + } + }] + servers: > + [{ + "id": "nexus-snapshot", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }, + { + "id": "nexus-release", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }] - name: Maven Package - env: - NEXUS_USERNAME: 'edward' - NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }} - RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }} run: | - mvn -B package \ - -P homelab \ - --settings=${{ github.workspace }}/.mvn/settings.xml + mvn -B package -P homelab - name: Prepare run: | platform=${{ matrix.platform }} @@ -128,7 +170,6 @@ jobs: if-no-files-found: error retention-days: 1 merge-docker: - if: false runs-on: ubuntu-latest needs: - build-docker @@ -137,18 +178,45 @@ jobs: with: fetch-depth: 0 - uses: actions/setup-java@v4.2.2 + if: ${{ hashFiles('**/pom.xml') }} with: - distribution: zulu java-version: 17 + distribution: zulu + cache: 'maven' + - name: maven-settings-xml-action + uses: whelk-io/maven-settings-xml-action@v22 + with: + profiles: > + [{ + "id": "homelab", + "properties": { + "altSnapshotDeploymentRepository": "nexus-snapshot::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL}", + "altReleaseDeploymentRepository": "nexus-release::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL}" + } + }] + repositories: > + [{ + "id": "maven-public", + "url": "${env.MAVEN_PUBLIC_REPOSITORY_URL}", + "snapshots": { + "enabled": "true" + } + }] + servers: > + [{ + "id": "nexus-snapshot", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }, + { + "id": "nexus-release", + "username": "${env.NEXUS_USERNAME}", + "password": "${env.NEXUS_PASSWORD}" + }] - name: Extract Maven project version id: project-version - env: - NEXUS_USERNAME: 'edward' - NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - SNAPSHOT_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL }} - RELEASE_DEPLOYMENT_REPOSITORY_URL: ${{ secrets.RELEASE_DEPLOYMENT_REPOSITORY_URL }} run: | - VERSION=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout -P homelab --settings=${{ github.workspace }}/.mvn/settings.xml) + VERSION=$( mvn help:evaluate -Dexpression=project.version -q -DforceStdout -P homelab) echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Show extracted Maven project version run: echo ${{ steps.project-version.outputs.version }} @@ -173,6 +241,7 @@ jobs: type=raw,value={{branch}}-{{date 'YYYYMMDD'}} type=raw,value={{branch}}-${{ steps.project-version.outputs.version }} type=raw,value=${{ steps.project-version.outputs.version }} + type=raw,value=latest - name: Login to Docker Hub uses: docker/login-action@v3 with: diff --git a/.mvn/settings.xml b/.mvn/settings.xml deleted file mode 100644 index 03ef155..0000000 --- a/.mvn/settings.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - homelab - - nexus-snapshot::${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL} - nexus-release::${env.RELEASE_DEPLOYMENT_REPOSITORY_URL} - - - - nexus-snapshot - Home Lab Nexus Snapshot - - false - - - true - always - warn - - ${env.SNAPSHOT_DEPLOYMENT_REPOSITORY_URL} - default - - - nexus-release - Home Lab Nexus Release - - true - always - warn - - - false - - ${env.RELEASE_DEPLOYMENT_REPOSITORY_URL} - default - - - - - - - nexus-snapshot - ${env.NEXUS_USERNAME} - ${env.NEXUS_PASSWORD} - - - nexus-release - ${env.NEXUS_USERNAME} - ${env.NEXUS_PASSWORD} - - - \ No newline at end of file