From dcc2b9b611dac526089439f73dfd68498d1a28f8 Mon Sep 17 00:00:00 2001 From: jandroav Date: Thu, 13 Jul 2023 08:59:57 +0200 Subject: [PATCH 1/3] chore(upload_zip.sh): add script to upload zip file as an asset to a draft release chore(create-release.yml): update sonar-push workflow to version v0.3.4 chore(extension-attach-artifact-release.yml): update extension-release-prepare workflow to version v0.3.4 chore(extension-release-prepare.yml): update maven release preparation steps and add release-rollback workflow chore(extension-release-rollback.yml): update maven release rollback steps chore(os-extension-test.yml): update sonar-pull-request workflow to version v0.3.4 chore(pro-extension-test.yml): update sonar-pull-request workflow to version v0.3.4 --- .github/upload_zip.sh | 54 +++++++++++++++++++ .github/workflows/create-release.yml | 2 +- .../extension-attach-artifact-release.yml | 17 ++++-- .../workflows/extension-release-prepare.yml | 11 +++- .../workflows/extension-release-rollback.yml | 6 ++- .github/workflows/os-extension-test.yml | 2 +- .github/workflows/pro-extension-test.yml | 2 +- 7 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 .github/upload_zip.sh diff --git a/.github/upload_zip.sh b/.github/upload_zip.sh new file mode 100644 index 00000000..5dee32f5 --- /dev/null +++ b/.github/upload_zip.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +set -e + +if [[ -z "$GITHUB_TOKEN" ]]; then + echo "Set the GITHUB_TOKEN env variable." + exit 1 +fi + +if [[ -z "$ASSET_NAME_PREFIX" ]]; then + echo "Set the ASSET_NAME_PREFIX env variable." + exit 1 +fi + +if [[ -z "$ASSET_DIR" ]]; then + echo "Set the ASSET_DIR env variable." + exit 1 +fi + +VERSION=$1 +if [[ -z "$VERSION" ]]; then + echo "Set the VERSION parameter." + exit 1 +fi + +_DIR=$(dirname "$0") +UPLOAD_URL=$($_DIR/get_draft_release.sh UPLOAD_URL) + +upload_asset() { + local file=$1 + local size=$2 + local content_type=$3 + echo "Uploading $file ($size bytes) to $UPLOAD_URL" + curl \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Content-Length: $size"\ + -H "Content-Type: $content_type" \ + --data-binary @$file "$UPLOAD_URL?name=$(basename $file)" +} + +EXTENSION=".zip" +FILE=$ASSET_DIR/$ASSET_NAME_PREFIX$VERSION$EXTENSION +# Skip if zip files do not exist (some extensions do not generate examples in zip format) +if [[ ! -f "$FILE" && "$FILE" != *".zip" ]]; then + echo "$FILE does not exist." +fi +SIZE=$(wc -c $FILE | awk '{print $1}') +if [[ $SIZE -eq 0 ]]; then + echo "$FILE is empty." +fi +MIME=$(file -b --mime-type $FILE) +upload_asset $FILE $SIZE $MIME + + diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 7f172f26..a59513e9 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.3.3 + uses: liquibase/build-logic/.github/workflows/sonar-push.yml@v0.3.4 secrets: inherit create-release: diff --git a/.github/workflows/extension-attach-artifact-release.yml b/.github/workflows/extension-attach-artifact-release.yml index ea639e56..e8de6207 100644 --- a/.github/workflows/extension-attach-artifact-release.yml +++ b/.github/workflows/extension-attach-artifact-release.yml @@ -16,7 +16,7 @@ on: jobs: release-prepare: - uses: liquibase/build-logic/.github/workflows/extension-release-prepare.yml@v0.3.3 + uses: liquibase/build-logic/.github/workflows/extension-release-prepare.yml@v0.3.4 secrets: inherit attach-to-release: @@ -29,9 +29,9 @@ jobs: - name: Get Reusable Script Files run: | - curl -o $PWD/.github/get_draft_release.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.3/.github/get_draft_release.sh - curl -o $PWD/.github/sign_artifact.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.3/.github/sign_artifact.sh - curl -o $PWD/.github/upload_asset.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.3/.github/upload_asset.sh + curl -o $PWD/.github/get_draft_release.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.github/get_draft_release.sh + curl -o $PWD/.github/sign_artifact.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.github/sign_artifact.sh + curl -o $PWD/.github/upload_asset.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.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 @@ -88,3 +88,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} ASSET_NAME_PREFIX: "${{ env.artifact_id }}-" ASSET_DIR: ./target + + - name: Attach Zip File to Draft Release + id: upload-release-zip + run: ./.github/upload_zip.sh $(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} + ASSET_NAME_PREFIX: "${{ env.artifact_id }}-" + ASSET_DIR: ./target diff --git a/.github/workflows/extension-release-prepare.yml b/.github/workflows/extension-release-prepare.yml index 8f43d6ad..803a31a2 100644 --- a/.github/workflows/extension-release-prepare.yml +++ b/.github/workflows/extension-release-prepare.yml @@ -27,7 +27,10 @@ jobs: - name: Prepare Maven Release run: | - mvn -B release:clean release:prepare -Dusername=liquibot -Dpassword=$GITHUB_TOKEN -Darguments="-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true -Dmaven.deploy.skip=true" -DreleaseVersion=${{ github.event.inputs.liquibaseVersion }} + mvn -B build-helper:parse-version versions:set release:clean release:prepare \ + -Dusername=liquibot -Dpassword=$GITHUB_TOKEN \ + -Darguments="-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true -Dmaven.deploy.skip=true" \ + -DdevelopmentVersion =\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0-SNAPSHOT -DreleaseVersion=${{ github.event.inputs.liquibaseVersion }} - name: Save Release files uses: actions/upload-artifact@v3 @@ -36,3 +39,9 @@ jobs: path: | **/pom.xml.* **/release.properties + + release-rollback: + needs: prepare-release + if: ${{ always() && contains(needs.*.result, 'failure') }} + uses: liquibase/build-logic/.github/workflows/extension-release-rollback.yml@v0.3.4 + secrets: inherit diff --git a/.github/workflows/extension-release-rollback.yml b/.github/workflows/extension-release-rollback.yml index da5ccdb2..a3f01ba9 100644 --- a/.github/workflows/extension-release-rollback.yml +++ b/.github/workflows/extension-release-rollback.yml @@ -23,4 +23,8 @@ jobs: - name: Perform Maven Release Rollback run: | - mvn -B release:rollback -Dusername=liquibot -Dpassword=$GITHUB_TOKEN -Darguments="-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true -Dmaven.deploy.skip=true" -DreleaseVersion=${{ github.event.inputs.liquibaseVersion }} -DconnectionUrl=scm:git:https://github.com/${{ github.repository }}.git -Dtag=${{ github.event.inputs.liquibaseVersion }} \ No newline at end of file + mvn -B release:rollback \ + -Dusername=liquibot -Dpassword=$GITHUB_TOKEN \ + -Darguments="-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true -Dmaven.deploy.skip=true" \ + -DdevelopmentVersion =\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0-SNAPSHOT -DreleaseVersion=${{ github.event.inputs.liquibaseVersion }} \ + -DconnectionUrl=scm:git:https://github.com/${{ github.repository }}.git -Dtag=${{ github.event.inputs.liquibaseVersion }} \ No newline at end of file diff --git a/.github/workflows/os-extension-test.yml b/.github/workflows/os-extension-test.yml index 4e33987c..beacf2ca 100644 --- a/.github/workflows/os-extension-test.yml +++ b/.github/workflows/os-extension-test.yml @@ -78,5 +78,5 @@ jobs: sonar-pr: needs: [ unit-test ] - uses: liquibase/build-logic/.github/workflows/sonar-pull-request.yml@v0.3.3 + uses: liquibase/build-logic/.github/workflows/sonar-pull-request.yml@v0.3.4 secrets: inherit diff --git a/.github/workflows/pro-extension-test.yml b/.github/workflows/pro-extension-test.yml index 831be56b..9e612633 100644 --- a/.github/workflows/pro-extension-test.yml +++ b/.github/workflows/pro-extension-test.yml @@ -98,5 +98,5 @@ jobs: sonar-pr: needs: [ unit-test ] - uses: liquibase/build-logic/.github/workflows/sonar-pull-request.yml@v0.3.3 + uses: liquibase/build-logic/.github/workflows/sonar-pull-request.yml@v0.3.4 secrets: inherit From 3d5ecb8b28328f02328b9ee891fa186c113aafa3 Mon Sep 17 00:00:00 2001 From: jandroav Date: Fri, 14 Jul 2023 08:03:24 +0200 Subject: [PATCH 2/3] chore(extension-attach-artifact-release.yml): add support for uploading zip artifact in addition to other artifacts --- .github/workflows/extension-attach-artifact-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/extension-attach-artifact-release.yml b/.github/workflows/extension-attach-artifact-release.yml index e8de6207..1e6a292d 100644 --- a/.github/workflows/extension-attach-artifact-release.yml +++ b/.github/workflows/extension-attach-artifact-release.yml @@ -32,6 +32,7 @@ jobs: curl -o $PWD/.github/get_draft_release.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.github/get_draft_release.sh curl -o $PWD/.github/sign_artifact.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.github/sign_artifact.sh curl -o $PWD/.github/upload_asset.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.github/upload_asset.sh + curl -o $PWD/.github/upload_asset.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.github/upload_zip.sh chmod +x $PWD/.github/get_draft_release.sh chmod +x $PWD/.github/sign_artifact.sh chmod +x $PWD/.github/upload_asset.sh From 6f1884bca047c05602d688df49f61001d56206ca Mon Sep 17 00:00:00 2001 From: jandroav Date: Fri, 14 Jul 2023 08:03:52 +0200 Subject: [PATCH 3/3] fix(extension-attach-artifact-release.yml): fix typo in curl command to download upload_zip.sh script feat(extension-attach-artifact-release.yml): add execution permission to upload_zip.sh script --- .github/workflows/extension-attach-artifact-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/extension-attach-artifact-release.yml b/.github/workflows/extension-attach-artifact-release.yml index 1e6a292d..e764c4d7 100644 --- a/.github/workflows/extension-attach-artifact-release.yml +++ b/.github/workflows/extension-attach-artifact-release.yml @@ -32,10 +32,11 @@ jobs: curl -o $PWD/.github/get_draft_release.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.github/get_draft_release.sh curl -o $PWD/.github/sign_artifact.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.github/sign_artifact.sh curl -o $PWD/.github/upload_asset.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.github/upload_asset.sh - curl -o $PWD/.github/upload_asset.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.github/upload_zip.sh + curl -o $PWD/.github/upload_zip.sh https://raw.githubusercontent.com/liquibase/build-logic/v0.3.4/.github/upload_zip.sh chmod +x $PWD/.github/get_draft_release.sh chmod +x $PWD/.github/sign_artifact.sh chmod +x $PWD/.github/upload_asset.sh + chmod +x $PWD/.github/upload_zip.sh - name: Update branch with latest commits # needed for getting the latest pom.xml generated by release-prepare step run: |