Skip to content

Commit

Permalink
Merge pull request #247 from liquibase/DAT-15825
Browse files Browse the repository at this point in the history
DAT-15825 docker fixes
  • Loading branch information
jnewton03 authored Sep 14, 2023
2 parents 509cd9f + 27c2852 commit f436e0c
Showing 1 changed file with 44 additions and 29 deletions.
73 changes: 44 additions & 29 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ on:
required: false

jobs:
setup-update-draft-build:
name: Release ${{ matrix.image.name }} Version ${{ inputs.liquibaseVersion}} ${{ matrix.image.suffix }}

update-dockerfiles:
name: "Update Dockerfiles"
runs-on: ubuntu-latest
strategy:
matrix:
image: [
{dockerfile: Dockerfile, name: liquibase/liquibase, suffix: ""},
{dockerfile: Dockerfile.alpine, name: liquibase/liquibase, suffix: "-alpine"},
]
outputs:
liquibaseVersion: ${{ steps.collect-data.outputs.liquibaseVersion }}
extensionVersion: ${{ steps.collect-data.outputs.extensionVersion }}
minorVersion: ${{ steps.collect-data.outputs.minorVersion }}
steps:
- name: Collect Data
id: collect-data
Expand All @@ -46,11 +45,11 @@ jobs:
} else {
core.setFailed('Unknown event type')
}
- run: |
echo "Saw Liquibase version ${{ steps.collect-data.outputs.liquibaseVersion }}"
echo "Saw Extension version ${{ steps.collect-data.outputs.extensionVersion }}"
- uses: actions/checkout@v3
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
Expand All @@ -69,40 +68,56 @@ jobs:
- name: Update Dockerfile and commit changes
run: |
file_list=("Dockerfile" "Dockerfile.alpine")
LIQUIBASE_SHA=`curl -LsS https://github.com/liquibase/liquibase/releases/download/v${{ steps.collect-data.outputs.liquibaseVersion }}/liquibase-${{ steps.collect-data.outputs.liquibaseVersion }}.tar.gz | sha256sum | awk '{ print $1 }'`
sed -i 's/^ARG LIQUIBASE_VERSION=.*/ARG LIQUIBASE_VERSION='"${{ steps.collect-data.outputs.liquibaseVersion }}"'/' ${{ github.workspace }}/${{ matrix.image.dockerfile }}
sed -i 's/^ARG LB_SHA256=.*/ARG LB_SHA256='"$LIQUIBASE_SHA"'/' ${{ github.workspace }}/${{ matrix.image.dockerfile }}
git add ${{ matrix.image.dockerfile }}
for file in "${file_list[@]}"; do
sed -i 's/^ARG LIQUIBASE_VERSION=.*/ARG LIQUIBASE_VERSION='"${{ steps.collect-data.outputs.liquibaseVersion }}"'/' "${{ github.workspace }}/${file}"
sed -i 's/^ARG LB_SHA256=.*/ARG LB_SHA256='"$LIQUIBASE_SHA"'/' "${{ github.workspace }}/${file}"
git add "${file}"
done
if git diff-index --cached --quiet HEAD --
then
echo "Nothing new to commit"
else
git commit -m "Liquibase Version Bumped to ${{ steps.collect-data.outputs.extensionVersion }} for ${{ matrix.image.name }} ${{ matrix.image.suffix }}"
git commit -m "Liquibase Version Bumped to ${{ steps.collect-data.outputs.extensionVersion }}"
git tag -fa -m "Version Bumped to ${{ steps.collect-data.outputs.extensionVersion }}" v${{ steps.collect-data.outputs.extensionVersion }}
git push -f "https://liquibot:[email protected]/$GITHUB_REPOSITORY.git" HEAD:${{ github.ref }} --follow-tags --tags
fi
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}

- name: Get release SHA
id: get-release-sha
run: echo "{releaseSha}=$(git rev-parse HEAD)" >> GITHUB_OUPUT


setup-update-draft-build:
name: "${{ matrix.image.name }}:${{ inputs.liquibaseVersion}}${{ matrix.image.suffix }}"
needs: update-dockerfiles
runs-on: ubuntu-latest
strategy:
matrix:
image: [
{dockerfile: Dockerfile, name: liquibase/liquibase, suffix: ""},
{dockerfile: Dockerfile.alpine, name: liquibase/liquibase, suffix: "-alpine"},
]
steps:
- uses: actions/checkout@v3
- name: Release
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: "8"
distribution: "adopt"

- name: Release Notes
uses: softprops/action-gh-release@v1
with:
target_commitish: ${{ steps.get-release-sha.outputs.releaseSha }}
name: v${{ steps.collect-data.outputs.extensionVersion }}
tag_name: v${{ steps.collect-data.outputs.extensionVersion }}
name: v${{ needs.update-dockerfiles.outputs.extensionVersion}}
tag_name: v${{ needs.update-dockerfiles.outputs.extensionVersion }}
draft: true
body: Support for Liquibase ${{ steps.collect-data.outputs.liquibaseVersion }}.
body: Support for Liquibase ${{ needs.update-dockerfiles.outputs.liquibaseVersion }}.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v3 # Checkout the SHA of the updated Dockerfile from the setup step
with:
ref: ${{ steps.get-release-sha.outputs.releaseSha }}

- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
Expand All @@ -129,4 +144,4 @@ jobs:
no-cache: true
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ matrix.image.name }}:latest${{ matrix.image.suffix }},${{ matrix.image.name }}:${{ steps.collect-data.outputs.extensionVersion }}${{ matrix.image.suffix }},${{ matrix.image.name }}:${{ steps.collect-data.outputs.minorVersion }}${{ matrix.image.suffix }},${{ env.ECR_REGISTRY }}:latest${{ matrix.image.suffix }},${{ env.ECR_REGISTRY }}:${{ steps.collect-data.outputs.extensionVersion }}${{ matrix.image.suffix }},${{ env.ECR_REGISTRY }}:${{ steps.collect-data.outputs.minorVersion }}${{ matrix.image.suffix }}
tags: ${{ matrix.image.name }}:latest${{ matrix.image.suffix }},${{ matrix.image.name }}:${{ needs.update-dockerfiles.outputs.extensionVersion }}${{ matrix.image.suffix }},${{ matrix.image.name }}:${{ needs.update-dockerfiles.outputs.minorVersion }}${{ matrix.image.suffix }},${{ env.ECR_REGISTRY }}:latest${{ matrix.image.suffix }},${{ env.ECR_REGISTRY }}:${{ needs.update-dockerfiles.outputs.extensionVersion }}${{ matrix.image.suffix }},${{ env.ECR_REGISTRY }}:${{ needs.update-dockerfiles.outputs.minorVersion }}${{ matrix.image.suffix }}

0 comments on commit f436e0c

Please sign in to comment.