Skip to content

feat: upgrade to 0.4.11 #90

feat: upgrade to 0.4.11

feat: upgrade to 0.4.11 #90

# Workflow to build and publish Docker images for DBHub
#
# This workflow:
# 1. Always pushes to the 'latest' tag when changes are pushed to the main branch
# 2. If package.json version changes, also pushes a version-specific tag
# 3. Builds for both amd64 and arm64 architectures
# 4. Builds Oracle thick mode image for Oracle 11g compatibility
name: Publish to docker hub
on:
push:
branches: ["main"]
env:
IMAGE_NAME: bytebase/dbhub
ORACLE_THICK_IMAGE_NAME: bytebase/dbhub-oracle-thick
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2 # Fetch two commits to detect changes in package.json
- name: Check for package.json version changes
id: check-version
run: |
# Get current and previous package.json content
git show HEAD:package.json > package.json.current
git show HEAD~1:package.json > package.json.previous 2>/dev/null || cp package.json.current package.json.previous
# Extract versions
CURRENT_VERSION=$(jq -r '.version' package.json.current)
PREVIOUS_VERSION=$(jq -r '.version' package.json.previous)
echo "Current version: $CURRENT_VERSION"
echo "Previous version: $PREVIOUS_VERSION"
# Set output based on whether version changed
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
echo "VERSION_CHANGED=true" >> $GITHUB_OUTPUT
echo "VERSION=$CURRENT_VERSION" >> $GITHUB_OUTPUT
else
echo "Version unchanged: $CURRENT_VERSION"
echo "VERSION_CHANGED=false" >> $GITHUB_OUTPUT
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Prepare Docker tags
id: prep
run: |
# Always include latest tag
TAGS="${{ env.IMAGE_NAME }}:latest"
# Add version tag if version changed
if [[ "${{ steps.check-version.outputs.VERSION_CHANGED }}" == "true" ]]; then
VERSION="${{ steps.check-version.outputs.VERSION }}"
TAGS="$TAGS,${{ env.IMAGE_NAME }}:$VERSION"
echo "Publishing with tags: latest, $VERSION"
else
echo "Publishing with tag: latest only"
fi
echo "TAGS=$TAGS" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.prep.outputs.TAGS }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Prepare Oracle Thick mode Docker tags
id: prep-oracle
run: |
# Always include latest tag
ORACLE_TAGS="${{ env.ORACLE_THICK_IMAGE_NAME }}:latest"
# Add version tag if version changed
if [[ "${{ steps.check-version.outputs.VERSION_CHANGED }}" == "true" ]]; then
VERSION="${{ steps.check-version.outputs.VERSION }}"
ORACLE_TAGS="$ORACLE_TAGS,${{ env.ORACLE_THICK_IMAGE_NAME }}:$VERSION"
echo "Publishing Oracle image with tags: latest, $VERSION"
else
echo "Publishing Oracle image with tag: latest only"
fi
echo "ORACLE_TAGS=$ORACLE_TAGS" >> $GITHUB_OUTPUT
- name: Build and push Oracle thick client Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.oracle-thick
push: true
platforms: linux/amd64
tags: ${{ steps.prep-oracle.outputs.ORACLE_TAGS }}
cache-from: type=gha,scope=oracle-build
cache-to: type=gha,scope=oracle-build,mode=max