diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 1a30898..4e24c63 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -42,6 +42,17 @@ jobs: java-version: '21' distribution: 'corretto' + - name: Clone curh schemas + run: | + git clone git@devops.pravilanovait.hr:curh-backend/curh-schemas.git + cd curh-schemas + git checkout $BRANCH + cd src/main/resources + mkdir -p /opt/rizik + cp -R xsd/ /opt/rizik/ + env: + BRANCH: ${{ github.ref }} + - name: Set up JDK from ENV if: github.ref != 'refs/heads/feature/T2900-java21' && github.ref != 'refs/heads/feature/T2900-java-21' uses: actions/setup-java@v4 @@ -73,18 +84,35 @@ jobs: CODEARTIFACT_AUTH_TOKEN: ${{ secrets.AWS_CA_TOKEN }} - name: Upload snapshot to nexus - if: github.ref != 'refs/heads/feature/T2900-java21' run: | GROUP_ID=$(mvn help:evaluate -Dexpression="project.groupId" -q -DforceStdout) ARTIFACT_ID=$(mvn help:evaluate -Dexpression="project.artifactId" -q -DforceStdout) VERSION=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout) - echo "Uploading artifact for $GROUP_ID:$ARTIFACT_ID:$VERSION" - mvn deploy:deploy-file \ - -Durl=https://devops.pravilanovait.hr/nexus/repository/maven-snapshots \ - -Dpackaging=jar -DgroupId=$GROUP_ID -DartifactId=$ARTIFACT_ID \ - -Dversion=$VERSION -DrepositoryId=local-nexus \ - -Dfile=target/$ARTIFACT_ID-$VERSION.jar -# curl --request DELETE --user "admin:$NEXUS_ADMIN_PASSWORD" https://devops.pravilanovait.hr/nexus/service/rest/v1/repositories/maven/proxy/amazon-codeartifact/content/$GROUP_ID/$ARTIFACT_ID/$VERSION/$ARTIFACT_ID-$VERSION.jar -# curl --request POST --user "admin:$NEXUS_ADMIN_PASSWORD" https://devops.pravilanovait.hr/nexus/service/rest/v1/repositories/maven/proxy/amazon-codeartifact/invalidate-cache + FINAL_NAME=$(mvn help:evaluate -Dexpression="project.build.finalName" -q -DforceStdout) + if [[ $VERSION == *SNAPSHOT ]]; + then + echo "Version $VERSION is snapshot version, proceeding with upload to local-nexus snapshots" + PACKAGING=$(mvn help:evaluate -Dexpression="project.packaging" -q -DforceStdout) + echo "Uploading artifact for $GROUP_ID:$ARTIFACT_ID:$VERSION" + if [ $PACKAGING == "pom" ]; + then + echo "Packaging is pom, uploading pom.xml" + mvn deploy:deploy-file \ + -Durl=https://devops.pravilanovait.hr/nexus/repository/maven-snapshots \ + -Dpackaging=pom -DgroupId=$GROUP_ID -DartifactId=$ARTIFACT_ID \ + -Dversion=$VERSION -DrepositoryId=local-nexus \ + -Dfile=pom.xml + else + echo "Packaging is $PACKAGING, uploading target/$ARTIFACT_ID-$VERSION.$PACKAGING" + mvn deploy:deploy-file \ + -Durl=https://devops.pravilanovait.hr/nexus/repository/maven-snapshots \ + -Dpackaging=$PACKAGING -DgroupId=$GROUP_ID -DartifactId=$ARTIFACT_ID \ + -Dversion=$VERSION -DrepositoryId=local-nexus \ + -Dfile=target/$FINAL_NAME.$PACKAGING + fi + else + echo "Version $VERSION is not snapshot version, not uploading to local-nexus snapshots" + fi + env: NEXUS_ADMIN_PASSWORD: ${{ secrets.NEXUS_ADMIN_PASSWORD }}