chatai/.github/workflows/build.yaml
2024-12-25 17:53:53 +00:00

61 lines
1.8 KiB
YAML

name: Build
on:
push:
branches:
- main
tags:
- v*
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
pull-requests: read
checks: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- uses: golangci/golangci-lint-action@v6
with:
version: v1.60
- name: Build
run: make -j8 all && tree bin
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: builds-${{ github.sha }}
path: |
bin/*.zip
bin/*.tar.gz
bin/*.sha256sum
- name: Upload Release Asset
if: startsWith(github.ref, 'refs/tags/')
run: |
gh release create ${GIT_TAG} bin/*.zip bin/*.tar.gz bin/*.sha256sum
env:
GIT_TAG: ${{ github.ref_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/riscv64,linux/386
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ startsWith(github.ref, 'refs/tags/') && 'latest' || 'dev' }}
ghcr.io/${{ github.repository }}:${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }}