kodflow/kitsune

View on GitHub
.github/workflows/main.yml

Summary

Maintainability
Test Coverage
name: Main

on:
  push:
    branches: main

jobs:
  Binary:
    outputs:
      version: ${{ steps.semver.outputs.next }}
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: remove test
      run: |
        find . -name '*_test.go' -type f -exec rm -f {} \;
      shell: bash
    - name: Get next version
      id: semver
      uses: ietf-tools/semver-action@v1
      with:
        token: ${{ github.token }}
        branch: main
        skipInvalidTags: true
    - name: Set up Go
      uses: actions/setup-go@v5
      with:
        go-version: 1.21
    - name: Build binaries for all platforms
      env:
        VERSION: ${{ steps.semver.outputs.next }}
      run: make build
    - name: Build Kitsune Framework
      uses: ncipollo/release-action@v1
      with:
        name: Kitsune Framework
        makeLatest: true
        tag: ${{ steps.semver.outputs.next }}
        artifacts: ".generated/bin/*,.generated/services/*"
        allowUpdates: true
        replacesArtifacts: true
        removeArtifacts: true
        token: ${{ secrets.GITHUB_TOKEN }}

  Services:
    needs: Binary
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v3
      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: Login to GitHub Packages
      uses: docker/login-action@v3
      with:
        registry: ghcr.io
        username: ${{ github.repository_owner }}
        password: ${{ secrets.GITHUB_TOKEN }}
    - name: Build Image Kitsune
      uses: docker/build-push-action@v5
      with:
        file: .github/build/Dockerfile.alpine
        context: .
        platforms: linux/amd64,linux/arm64
        push: true
        build-args: |
          BINARY_VERSION=${{ needs.Binary.outputs.version }}
        tags: |
          ghcr.io/${{ github.repository_owner }}/kitsune:latest
          ghcr.io/${{ github.repository_owner }}/kitsune:${{ needs.Binary.outputs.version }}

    - name: Login to DockerHub Packages
      uses: docker/login-action@v3
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_TOKEN }}
    - name: Build Image Kitsune
      uses: docker/build-push-action@v5
      with:
        file: .github/build/Dockerfile.scratch
        context: .
        platforms: linux/amd64,linux/arm64
        push: true
        build-args: |
          BINARY_VERSION=${{ needs.Binary.outputs.version }}
        tags: |
          kodmain/kitsune:latest
          kodmain/kitsune:${{ needs.Binary.outputs.version }}