Skip to content

fix: improve error messages for backend validation and configuration … #42

fix: improve error messages for backend validation and configuration …

fix: improve error messages for backend validation and configuration … #42

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-binaries:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libpam0g-dev
- name: Install xgo for cross-compilation
run: |
go install src.techknowlogick.com/xgo@latest
- name: Build main binaries for all architectures
working-directory: ./v2
run: |
# Ensure all dependencies are properly downloaded and verified
GOWORK=off go mod download
GOWORK=off go mod verify
GOWORK=off go mod tidy
# Explicitly get the missing dependency that causes issues in xgo
GOWORK=off go get github.com/munnerz/goautoneg
GOWORK=off go get github.com/prometheus/common/expfmt@v0.65.0
# Update go.sum and mod files after adding dependencies
GOWORK=off go mod tidy
# List module status for debugging
echo "Go module status:"
GOWORK=off go list -m all | grep -E "(prometheus|munnerz)" || true
# Store the exact Go version and build flags
GO_RELEASE_V=$(go version | { read _ _ v _; echo ${v#go}; })
echo "GO_VERSION=$GO_RELEASE_V" >> $GITHUB_ENV
echo "BUILD_LDFLAGS=-s -w" >> $GITHUB_ENV
echo "XGO_IMAGE=techknowlogick/xgo:latest" >> $GITHUB_ENV
# Build main binaries using xgo with embedded database support
# Database handlers are now embedded, no separate plugins needed
xgo -image techknowlogick/xgo:latest -v -ldflags="-s -w" -go $GO_RELEASE_V -out glauth -dest bin \
-targets="linux/amd64,linux/386,linux/arm64,linux/arm-7,darwin/amd64,darwin/arm64,windows/amd64,windows/386" \
-env="GO111MODULE=on,GOPROXY=https://proxy.golang.org,direct,GOWORK=off" .
# Fix ownership and permissions for files created by xgo (which runs as root in docker)
sudo chown -R $USER:$USER bin/ 2>/dev/null || true
chmod -R 755 bin/ 2>/dev/null || true
# Create sha256 files for each binary
cd bin
for binary in glauth-*; do
if [[ -f "$binary" ]]; then
echo "Creating sha256 for $binary"
sha256sum "$binary" > "$binary.sha256"
fi
done
- name: List all built artifacts
working-directory: ./v2/bin
run: |
echo "Built artifacts:"
ls -la
echo ""
echo "SHA256 files:"
ls -la *.sha256 2>/dev/null || echo "No SHA256 files found yet"
# Ensure all files have proper permissions and ownership
sudo chown -R runner:runner . 2>/dev/null || true
chmod -R 644 *.sha256 2>/dev/null || true
chmod -R 755 glauth-* 2>/dev/null || true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: v2/bin/
build-docker-and-release:
needs: build-binaries
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: v2/bin/
- name: Extract tag name
id: tag
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Prepare Docker assets
working-directory: ./v2
run: |
# Create platform-specific directories for Docker build
mkdir -p docker/assets/linux/amd64 docker/assets/linux/arm64 docker/assets/linux/arm/v7
# Copy binaries with embedded database support
if [[ -f "bin/glauth-linux-amd64" ]]; then
cp bin/glauth-linux-amd64 docker/assets/linux/amd64/glauth
chmod +x docker/assets/linux/amd64/glauth
fi
if [[ -f "bin/glauth-linux-arm64" ]]; then
cp bin/glauth-linux-arm64 docker/assets/linux/arm64/glauth
chmod +x docker/assets/linux/arm64/glauth
fi
if [[ -f "bin/glauth-linux-arm-7" ]]; then
cp bin/glauth-linux-arm-7 docker/assets/linux/arm/v7/glauth
chmod +x docker/assets/linux/arm/v7/glauth
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
org.opencontainers.image.title=GLAuth
org.opencontainers.image.description=A simple LDAP server for development, home use, or CI pipelines with embedded database support
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.licenses=MIT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./v2/docker
file: ./v2/docker/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: List available files for release
working-directory: ./v2/bin
run: |
echo "Files available for release:"
ls -la
echo ""
echo "Main binaries:"
ls -la glauth-* 2>/dev/null || echo "No main binaries found"
echo ""
echo "SHA256 files:"
ls -la *.sha256 2>/dev/null || echo "No SHA256 files found"
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: Release ${{ steps.tag.outputs.tag }}
draft: false
prerelease: false
generate_release_notes: true
files: v2/bin/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}