Skip to content

fix: Dockerfile to support multiple arch and check that the migration… #5

fix: Dockerfile to support multiple arch and check that the migration…

fix: Dockerfile to support multiple arch and check that the migration… #5

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
jobs:
build:
name: Build and Release
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
cache: true
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build for all platforms
run: |
# Create build directory
mkdir -p build
# Build for MacOS (both ARM and AMD64)
GOOS=darwin GOARCH=arm64 go build -o build/migrationdb-darwin-arm64 main.go
GOOS=darwin GOARCH=amd64 go build -o build/migrationdb-darwin-amd64 main.go
# Build for Linux
GOOS=linux GOARCH=amd64 go build -o build/migrationdb-linux-amd64 main.go
GOOS=linux GOARCH=arm64 go build -o build/migrationdb-linux-arm64 main.go
# Build for Windows
GOOS=windows GOARCH=amd64 go build -o build/migrationdb-windows-amd64.exe main.go
# Create ZIP archives for each binary
cd build
for file in *; do
zip "${file}.zip" "$file"
done
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
build/*.zip
name: Release ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Convert repository name to lowercase
id: repo_name
run: echo "REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ steps.repo_name.outputs.REPO }}:latest
ghcr.io/${{ steps.repo_name.outputs.REPO }}:${{ steps.get_version.outputs.VERSION }}