diff --git a/.github/workflows/extension-attach-artifact-release.yml b/.github/workflows/extension-attach-artifact-release.yml index 1b27254f..633e806a 100644 --- a/.github/workflows/extension-attach-artifact-release.yml +++ b/.github/workflows/extension-attach-artifact-release.yml @@ -101,22 +101,46 @@ jobs: git config user.name "liquibot" git config user.email "liquibot@liquibase.org" + - name: Get Artifact ID + id: get-artifact-id + run: echo "artifact_id=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV + - name: Run extra command - if: inputs.extraCommand != '' + if: inputs.extraCommand run: | ${{ inputs.extraCommand }} + - name: Check and download artifacts from GPM + id: check-download-artifacts + env: + ARTIFACT_NAME: ${{ github.event.repository.name }} + run: | + RELEASE_VERSION=$(grep -m2 '' pom.xml | tail -n 1 | awk -F'[><]' '{print $3}' | sed 's/-SNAPSHOT//') + echo "RELEASE_VERSION=$RELEASE_VERSION" + mvn dependency:get -DgroupId=org.liquibase.ext -DartifactId=${{ env.ARTIFACT_NAME }} -Dversion=$RELEASE_VERSION -Dtransitive=false || echo "Failed to download artifact" + mvn dependency:get -DgroupId=org.liquibase.ext -DartifactId=${{ env.ARTIFACT_NAME }} -Dversion=$RELEASE_VERSION -Dpackaging=pom -Dtransitive=false || echo "Failed to download pom artifact" + mvn dependency:get -DgroupId=org.liquibase.ext -DartifactId=${{ env.ARTIFACT_NAME }} -Dversion=$RELEASE_VERSION -Dclassifier=sources -Dtransitive=false || echo "Failed to download sources artifact" + mvn dependency:get -DgroupId=org.liquibase.ext -DartifactId=${{ env.ARTIFACT_NAME }} -Dversion=$RELEASE_VERSION -Dclassifier=javadoc -Dtransitive=false || echo "Failed to download javadoc artifact" + rm -rf ~/.m2/repository/org/liquibase/ext/${{ env.ARTIFACT_NAME }}/$RELEASE_VERSION/*.lastUpdated + ARTIFACT_FOUND=$(ls -1 ~/.m2/repository/org/liquibase/ext/${{ env.ARTIFACT_NAME }}/$RELEASE_VERSION/ 2>/dev/null | wc -l) + echo "ARTIFACT_FOUND=$ARTIFACT_FOUND" >> $GITHUB_ENV + if [ $ARTIFACT_FOUND -eq 0 ]; then + echo "No artifact found" + else + echo "Artifact found" + rm -rf ./target && mkdir -p ./target + mv ~/.m2/repository/org/liquibase/ext/${{ env.ARTIFACT_NAME }}/$RELEASE_VERSION/* ./target + sed -i 's/-SNAPSHOT//g' pom.xml + fi + - name: Build release artifacts + if: env.ARTIFACT_FOUND == '0' id: build-release-artifacts run: | mvn -B release:clean release:prepare -Darguments="-Dusername=liquibot -Dpassword=$GITHUB_TOKEN -Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true -Dmaven.deploy.skip=true" -DreleaseVersion=${{ github.event.inputs.liquibaseVersion }} -DpushChanges=false -P '${{ inputs.mavenProfiles }}' git reset HEAD~ --hard mvn clean install -DskipTests -P '${{ inputs.mavenProfiles }}' - - name: Get Artifact ID - id: get-artifact-id - run: echo "artifact_id=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV - - name: Get latest draft release ID id: get-release run: |