Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/aws-actions/config…
Browse files Browse the repository at this point in the history
…ure-aws-credentials-3
  • Loading branch information
jandroav authored Sep 4, 2023
2 parents db3b9b5 + 4d31322 commit f7d83e1
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 2 deletions.
54 changes: 54 additions & 0 deletions .github/upload_zip.sh
Original file line number Diff line number Diff line change
@@ -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


10 changes: 10 additions & 0 deletions .github/workflows/extension-attach-artifact-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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
11 changes: 10 additions & 1 deletion .github/workflows/extension-release-prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/[email protected]
secrets: inherit
6 changes: 5 additions & 1 deletion .github/workflows/extension-release-rollback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
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 }}

0 comments on commit f7d83e1

Please sign in to comment.