Adekabang 8eaee0be8c refactor: update project references from Adekabang to khairul169
- Change Docker image references in docker-compose.yml and documentation
- Update Go module path and import statements in backend code
- Modify build script to reflect new image name
- Remove outdated copyright information from LICENSE file
2025-09-29 20:26:44 -04:00

157 lines
4.8 KiB
YAML

name: Release
on:
push:
tags:
- 'v*.*.*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DOCKER_HUB_REGISTRY: khairul169/garage-webui
jobs:
build-and-push-image:
name: Build and push Docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Optional: Log in to Docker Hub if you want to push there too
# Uncomment and configure secrets in your GitHub repository settings
# - name: Log in to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
#
# - name: Add Docker Hub as additional image target
# if: ${{ success() && secrets.DOCKERHUB_USERNAME != '' }}
# run: |
# docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }} ${{ env.DOCKER_HUB_REGISTRY }}:${{ steps.get_version.outputs.VERSION }}
# docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }} ${{ env.DOCKER_HUB_REGISTRY }}:latest
# docker push ${{ env.DOCKER_HUB_REGISTRY }}:${{ steps.get_version.outputs.VERSION }}
# docker push ${{ env.DOCKER_HUB_REGISTRY }}:latest
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.get_version.outputs.VERSION }}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
- 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 }}
build-args: |
VERSION=${{ steps.get_version.outputs.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-binaries:
name: Build binaries
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Set up PNPM
uses: pnpm/action-setup@v2
with:
version: 8
- name: Install dependencies
run: pnpm install
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create version.txt file with tag version
run: echo "${{ steps.get_version.outputs.VERSION }}" > version.txt
- name: Create custom build script for tag-based versioning
run: |
cat > misc/tag-build.sh << 'EOF'
#!/bin/sh
set -e
BINARY=garage-webui
VERSION=$(cat version.txt)
PLATFORMS="linux"
ARCHITECTURES="386 amd64 arm arm64"
echo "Building version $VERSION"
pnpm run build
cd backend && rm -rf dist && mkdir -p dist && rm -rf ./ui/dist && cp -r ../dist ./ui/dist
for PLATFORM in $PLATFORMS; do
for ARCH in $ARCHITECTURES; do
echo "Building $PLATFORM-$ARCH"
GOOS=$PLATFORM GOARCH=$ARCH go build -o "dist/$BINARY-v$VERSION-$PLATFORM-$ARCH" -tags="prod" main.go
done
done
EOF
chmod +x misc/tag-build.sh
- name: Build binaries
run: |
./misc/tag-build.sh
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
files: |
backend/dist/garage-webui-*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}