Skip to content

Release Extension (v2) #108

Release Extension (v2)

Release Extension (v2) #108

Workflow file for this run

name: Release Extension (v2)
on:
repository_dispatch:
types: [liquibase-release]
workflow_dispatch:
inputs:
liquibaseVersion:
description: "Liquibase Version"
required: true
lpmVersion:
description: "lpm Version"
required: true
default: "0.2.4"
extensionVersion:
description: "Container Version (Defaults to Liquibase Version)"
required: false
jobs:
update-dockerfiles:
name: "Update Dockerfiles"
runs-on: ubuntu-latest
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
uses: actions/github-script@v7
with:
script: |
const getMinorVersion = (liquibaseVersion) => {
const arr = liquibaseVersion.split(".")
return `${arr[0]}.${arr[1]}`
}
if (context.payload.client_payload) {
const liquibaseVersion = context.payload.client_payload.liquibaseVersion
const minorVersion = getMinorVersion(liquibaseVersion)
core.setOutput("liquibaseVersion", liquibaseVersion);
core.setOutput("extensionVersion", liquibaseVersion);
core.setOutput("minorVersion", minorVersion);
} else if (context.payload.inputs) {
const liquibaseVersion = context.payload.inputs.liquibaseVersion
const minorVersion = getMinorVersion(liquibaseVersion)
core.setOutput("liquibaseVersion", liquibaseVersion);
core.setOutput("extensionVersion", context.payload.inputs.extensionVersion || liquibaseVersion);
core.setOutput("minorVersion", minorVersion);
} 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@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
ref: ${{ github.ref }}
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: "8"
distribution: "adopt"
- name: Configure git user
run: |
git config user.name "liquibot"
git config user.email "[email protected]"
- 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 }'`
LPM_SHA=`curl -LsS https://github.com/liquibase/liquibase-package-manager/releases/download/v${{ inputs.lpmVersion }}/lpm-${{ inputs.lpmVersion }}-linux.zip | sha256sum | awk '{ print $1 }'`
cat LPM_SHA
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}"
sed -i 's/^ARG LPM_SHA256=.*/ARG LPM_SHA256='"$LPM_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 }}"
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 }}