diff --git a/.github/get_draft_release.sh b/.github/get_draft_release.sh deleted file mode 100755 index 0e68e78e..00000000 --- a/.github/get_draft_release.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -set -e - -KEY=$1 - -if [[ -z "$GITHUB_TOKEN" ]]; then - echo "Set the GITHUB_TOKEN env variable." - exit 1 -fi - -if [[ -z "$GITHUB_REPOSITORY" ]]; then - echo "Set the GITHUB_REPOSITORY env variable." - exit 1 -fi - -RELEASE=$(curl -s \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/repos/$GITHUB_REPOSITORY/releases" | - jq -r ".[] | select(.draft == true)") - -if [[ "${#RELEASE}" -eq 0 ]]; then - echo "Draft release not found." - exit 1; -fi - -case $KEY in - TAG) - HTML_URL=$(echo $RELEASE | jq -r ".html_url") - echo "$HTML_URL" | rev | cut -d "/" -f1 | rev - ;; - UPLOAD_URL) - UPLOAD_URL=$(echo $RELEASE | jq -r ".upload_url") - echo "${UPLOAD_URL//{?name,label\}}" - ;; -esac \ No newline at end of file diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index a9800847..1fad5e9d 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -5,7 +5,7 @@ on: jobs: sonar: - uses: liquibase/build-logic/.github/workflows/sonar-push.yml@v0.4.7 + uses: liquibase/build-logic/.github/workflows/sonar-push.yml@v0.4.8 secrets: inherit create-release: diff --git a/.github/workflows/extension-attach-artifact-release.yml b/.github/workflows/extension-attach-artifact-release.yml index 78a05408..c63855f7 100644 --- a/.github/workflows/extension-attach-artifact-release.yml +++ b/.github/workflows/extension-attach-artifact-release.yml @@ -37,9 +37,9 @@ jobs: - name: Get Reusable Script Files run: | - curl -o $PWD/.github/get_draft_release.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.4.7/.github/get_draft_release.sh - curl -o $PWD/.github/sign_artifact.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.4.7/.github/sign_artifact.sh - curl -o $PWD/.github/upload_asset.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.4.7/.github/upload_asset.sh + curl -o $PWD/.github/get_draft_release.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.4.8/.github/get_draft_release.sh + curl -o $PWD/.github/sign_artifact.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.4.8/.github/sign_artifact.sh + curl -o $PWD/.github/upload_asset.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.4.8/.github/upload_asset.sh chmod +x $PWD/.github/get_draft_release.sh chmod +x $PWD/.github/sign_artifact.sh chmod +x $PWD/.github/upload_asset.sh @@ -60,21 +60,33 @@ jobs: id: get-artifact-id run: echo "artifact_id=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV - - name: Get Release Tag - id: get-release-tag - run: echo "release_tag=$(./.github/get_draft_release.sh TAG)" >> $GITHUB_ENV - env: - GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} + - name: Get latest draft release ID + id: get-release + run: | + LATEST_DRAFT_RELEASE=$(curl -X GET -H "Authorization: token ${{ secrets.BOT_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases?per_page=1" | jq -r 'if .[].draft == true then .[].id else empty end') + echo "Latest Draft Release ID: $LATEST_DRAFT_RELEASE" + echo "RELEASE_ID=$LATEST_DRAFT_RELEASE" >> $GITHUB_ENV - - name: Delete Outdated Files from Draft Release - id: delete-outdated-release-asset - uses: mknejp/delete-release-assets@v1 - with: - token: ${{ secrets.BOT_TOKEN }} - tag: ${{ env.release_tag }} - fail-if-no-assets: false - fail-if-no-release: false - assets: '*.*' + - name: List artifacts in release + if: env.RELEASE_ID != '' && env.RELEASE_ID != null + id: list-artifacts + run: | + RELEASE_ID="${{ env.RELEASE_ID }}" + ARTIFACTS=$(curl -X GET -H "Authorization: token ${{ secrets.BOT_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets" | jq -r '.[].id') + echo "Artifacts to delete: $ARTIFACTS" + ARTIFACTS_CLEANED=$(echo "$ARTIFACTS" | tr -s '[:space:]' ',' | sed 's/,$//') + echo "ARTIFACTS_TO_DELETE=$ARTIFACTS_CLEANED" >> $GITHUB_ENV + + - name: Delete artifacts + if: env.ARTIFACTS_TO_DELETE != null + run: | + RELEASE_ID="${{ env.RELEASE_ID }}" + ARTIFACTS_TO_DELETE="${{ env.ARTIFACTS_TO_DELETE }}" + IFS=',' read -ra values <<< "$ARTIFACTS_TO_DELETE" + for value in "${values[@]}"; do + curl -X DELETE -H "Authorization: token ${{ secrets.BOT_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/assets/$value" + echo "Deleted artifact ID: $value" + done - name: Import GPG key id: import_gpg @@ -103,7 +115,7 @@ jobs: - name: Get upload_zip.sh Script File if: inputs.zip == 'true' run: | - curl -o $PWD/.github/upload_zip.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.4.7/.github/upload_zip.sh + curl -o $PWD/.github/upload_zip.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.4.8/.github/upload_zip.sh chmod +x $PWD/.github/upload_zip.sh - name: Attach Zip File to Draft Release diff --git a/.github/workflows/extension-release-prepare.yml b/.github/workflows/extension-release-prepare.yml index 8f60f486..258a29f3 100644 --- a/.github/workflows/extension-release-prepare.yml +++ b/.github/workflows/extension-release-prepare.yml @@ -51,5 +51,5 @@ jobs: release-rollback: needs: prepare-release if: ${{ always() && contains(needs.*.result, 'failure') }} - uses: liquibase/build-logic/.github/workflows/extension-release-rollback.yml@v0.4.7 + uses: liquibase/build-logic/.github/workflows/extension-release-rollback.yml@v0.4.8 secrets: inherit diff --git a/.github/workflows/extension-release-published.yml b/.github/workflows/extension-release-published.yml index c9d599d3..4468f673 100644 --- a/.github/workflows/extension-release-published.yml +++ b/.github/workflows/extension-release-published.yml @@ -68,5 +68,5 @@ jobs: maven-release: needs: release - uses: liquibase/build-logic/.github/workflows/extension-release-prepare.yml@v0.4.7 + uses: liquibase/build-logic/.github/workflows/extension-release-prepare.yml@v0.4.8 secrets: inherit \ No newline at end of file diff --git a/.github/workflows/os-extension-test.yml b/.github/workflows/os-extension-test.yml index 75776ed7..15da65f6 100644 --- a/.github/workflows/os-extension-test.yml +++ b/.github/workflows/os-extension-test.yml @@ -98,5 +98,5 @@ jobs: sonar-pr: needs: [ unit-test ] - uses: liquibase/build-logic/.github/workflows/sonar-pull-request.yml@v0.4.7 + uses: liquibase/build-logic/.github/workflows/sonar-pull-request.yml@v0.4.8 secrets: inherit diff --git a/.github/workflows/package-deb.yml b/.github/workflows/package-deb.yml index d58e7ee4..84fcf31e 100644 --- a/.github/workflows/package-deb.yml +++ b/.github/workflows/package-deb.yml @@ -54,10 +54,10 @@ jobs: # Under the src folder is where specific packages files live. The GitHub action inputs will modify the universal package-deb-pom.xml to tell the process which assets to use during the packaging step mkdir -p $PWD/.github/src/${{ inputs.artifactId }}/deb/control mkdir -p $PWD/.github/src/${{ inputs.artifactId }}/main/archive - curl -o $PWD/.github/src/${{ inputs.artifactId }}/deb/control/control https://raw.githubusercontent.com/liquibase/build-logic/v0.4.7/src/${{ inputs.artifactId }}/deb/control/control - curl -o $PWD/.github/src/${{ inputs.artifactId }}/deb/control/postinst https://raw.githubusercontent.com/liquibase/build-logic/v0.4.7/src/${{ inputs.artifactId }}/deb/control/postinst - curl -o $PWD/.github/src/${{ inputs.artifactId }}/main/archive/${{ inputs.artifactId }}-env.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.4.7/src/${{ inputs.artifactId }}/main/archive/${{ inputs.artifactId }}-env.sh - curl -o $PWD/.github/package-deb-pom.xml https://raw.githubusercontent.com/liquibase/build-logic/v0.4.7/.github/package-deb-pom.xml + curl -o $PWD/.github/src/${{ inputs.artifactId }}/deb/control/control https://raw.githubusercontent.com/liquibase/build-logic/v0.4.8/src/${{ inputs.artifactId }}/deb/control/control + curl -o $PWD/.github/src/${{ inputs.artifactId }}/deb/control/postinst https://raw.githubusercontent.com/liquibase/build-logic/v0.4.8/src/${{ inputs.artifactId }}/deb/control/postinst + curl -o $PWD/.github/src/${{ inputs.artifactId }}/main/archive/${{ inputs.artifactId }}-env.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.4.8/src/${{ inputs.artifactId }}/main/archive/${{ inputs.artifactId }}-env.sh + curl -o $PWD/.github/package-deb-pom.xml https://raw.githubusercontent.com/liquibase/build-logic/v0.4.8/.github/package-deb-pom.xml - name: Set up Maven uses: stCarolas/setup-maven@v4.5 diff --git a/.github/workflows/pom-release-published.yml b/.github/workflows/pom-release-published.yml index 1566001a..4b8c3c21 100644 --- a/.github/workflows/pom-release-published.yml +++ b/.github/workflows/pom-release-published.yml @@ -68,5 +68,5 @@ jobs: maven-release: needs: release - uses: liquibase/build-logic/.github/workflows/extension-release-prepare.yml@v0.4.7 + uses: liquibase/build-logic/.github/workflows/extension-release-prepare.yml@v0.4.8 secrets: inherit \ No newline at end of file diff --git a/.github/workflows/pro-extension-test.yml b/.github/workflows/pro-extension-test.yml index 6627ea16..371bc7df 100644 --- a/.github/workflows/pro-extension-test.yml +++ b/.github/workflows/pro-extension-test.yml @@ -204,5 +204,5 @@ jobs: sonar-pr: needs: [ unit-test ] - uses: liquibase/build-logic/.github/workflows/sonar-pull-request.yml@v0.4.7 + uses: liquibase/build-logic/.github/workflows/sonar-pull-request.yml@v0.4.8 secrets: inherit