Skip to content

chore: for release test pg from 14 to 17 #34

chore: for release test pg from 14 to 17

chore: for release test pg from 14 to 17 #34

Workflow file for this run

name: Release Binary and Docker Versioned
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: linux-amd64
goos: linux
goarch: amd64
- os: macos-latest
target: darwin-arm64
goos: darwin
goarch: arm64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Read version
id: version
run: echo "version=$(cat internal/version/VERSION)" >> $GITHUB_OUTPUT
- name: Run tests
run: |
if [[ "${{ matrix.target }}" == "linux-amd64" ]]; then
# Test with all PostgreSQL versions on linux-amd64
for version in 14 15 16 17; do
echo "Testing with PostgreSQL $version"
PGSCHEMA_POSTGRES_VERSION=$version go test -v ./...
done
else
go test -short -v ./...
fi
- name: Build binary
run: |
# Get git info
GIT_COMMIT=$(git rev-parse --short HEAD)
BUILD_DATE=$(date -u +"%Y-%m-%d %H:%M:%S")
# Build for target platform
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build \
-ldflags "-X github.com/pgschema/pgschema/cmd.GitCommit=${GIT_COMMIT} -X 'github.com/pgschema/pgschema/cmd.BuildDate=${BUILD_DATE}'" \
-o pgschema-${{ matrix.target }} .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: pgschema-${{ matrix.target }}
path: pgschema-${{ matrix.target }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Read version
id: version
run: echo "version=$(cat internal/version/VERSION)" >> $GITHUB_OUTPUT
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: binaries
- name: Create release
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631
with:
# go install requires tags to be prefixed with v.
tag_name: v${{ steps.version.outputs.version }}
name: Release v${{ steps.version.outputs.version }}
generate_release_notes: true
files: |
binaries/pgschema-linux-amd64/pgschema-linux-amd64
binaries/pgschema-linux-arm64/pgschema-linux-arm64
binaries/pgschema-darwin-amd64/pgschema-darwin-amd64
binaries/pgschema-darwin-arm64/pgschema-darwin-arm64
docker:
needs: release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
REGISTRY: docker.io
IMAGE_NAME: pgschema/pgschema
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Read version
id: version
run: echo "version=$(cat internal/version/VERSION)" >> $GITHUB_OUTPUT
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=v${{ steps.version.outputs.version }}
- name: Get build info
id: build_info
run: |
echo "GIT_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "BUILD_DATE=$(date -u +"%Y-%m-%d %H:%M:%S")" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
GIT_COMMIT=${{ steps.build_info.outputs.GIT_COMMIT }}
BUILD_DATE=${{ steps.build_info.outputs.BUILD_DATE }}