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/extension-attach-artifact-release.yml b/.github/workflows/extension-attach-artifact-release.yml index 3b8d627b..81f76977 100644 --- a/.github/workflows/extension-attach-artifact-release.yml +++ b/.github/workflows/extension-attach-artifact-release.yml @@ -37,6 +37,7 @@ jobs: 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: Configure Git run: | @@ -93,3 +94,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 65aa227d..4f2fe9bf 100644 --- a/.github/workflows/extension-release-prepare.yml +++ b/.github/workflows/extension-release-prepare.yml @@ -29,7 +29,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 @@ -38,3 +41,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