113 lines
2.8 KiB
YAML
113 lines
2.8 KiB
YAML
name: ci
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
tests:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Run tests
|
|
run: make test
|
|
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v6
|
|
|
|
- name: Run pre-commit
|
|
uses: https://git.iamthefij.com/iamthefij/pre-commit-action@v3.1.0
|
|
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
if: "${{ github.event_name != 'pull_request' }}"
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Build binaries
|
|
env:
|
|
VERSION: "${{ github.REF_NAME }}"
|
|
run: make all
|
|
|
|
# Package binaries and create release if this is a tagged build
|
|
- name: Compress binaries
|
|
if: "${{ github.ref_type == 'tag' }}"
|
|
run: find ./dist -type f -executable -execdir tar -czvf {}.tar.gz {} \;
|
|
|
|
- name: Upload release
|
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
|
if: "${{ github.ref_type == 'tag' }}"
|
|
with:
|
|
files: |-
|
|
dist/*.tar.gz
|
|
md5sum: true
|
|
sha256sum: true
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
# list of Docker images to use as base name for tags
|
|
images: |
|
|
${{ github.REPOSITORY }}
|
|
# generate Docker tags based on the following events/attributes
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
if: "${{ github.event_name != 'pull_request' }}"
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
# Use path context so we can access pre-compiled binaries
|
|
context: .
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
platforms: |
|
|
linux/amd64
|
|
linux/arm64
|
|
linux/arm/v7
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|