Files
gibidify/.github/workflows/ci.yml

64 lines
1.6 KiB
YAML

---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build and Publish
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ created ]
jobs:
build:
name: Build Binaries
runs-on: ubuntu-latest
strategy:
matrix:
goos: [ "linux", "darwin" ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build binary for ${{ matrix.goos }}
shell: bash
run: |
GOOS=${{ matrix.goos }} GOARCH=amd64 go build \
-ldflags "-X main.Version=dev-$(date -u +%Y%m%d%H%M)" \
-o gibidify-${{ matrix.goos }} \
.
- name: Upload artifact for ${{ matrix.goos }}
uses: actions/upload-artifact@v4
with:
name: gibidify-${{ matrix.goos }}
path: gibidify-${{ matrix.goos }}
docker:
name: Build and Publish Docker Image
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Linux binary artifact
uses: actions/download-artifact@v4
with:
name: gibidify-linux
path: .
- name: Build Docker image
shell: bash
run: |
cp ./gibidify-linux ./gibidify
chmod +x ./gibidify
docker build -t ghcr.io/${{ github.repository }}/gibidify:${{ github.ref_name }} .