feat(ci): remove Cgo dependencies, cross compile without QEMU, upload static binaries

This commit is contained in:
sentriz
2025-09-29 14:41:40 +01:00
parent 58c2933355
commit e3db819d8f
7 changed files with 73 additions and 130 deletions

No files matched your search

+49 -22
View File
@@ -8,16 +8,12 @@ jobs:
name: Lint and test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v5
with:
go-version-file: go.mod
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y -qq build-essential git sqlite3 libtag1-dev ffmpeg mpv zlib1g-dev
- name: Lint
uses: golangci/golangci-lint-action@v8
with:
@@ -43,32 +39,61 @@ jobs:
release-type: simple
changelog-path: CHANGELOG.md
package-name: gonic
build-release:
build-binaries:
name: Build binaries
runs-on: ubuntu-latest
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created }}
strategy:
matrix:
os: [linux, windows, darwin]
arch: [amd64, arm64, 386]
exclude:
- os: darwin
arch: 386
# https://github.com/natefinch/npipe/issues/33 (required by mpvipc)
- os: windows
arch: arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v5
with:
go-version-file: go.mod
- name: Build
run: |
set -e
CGO_ENABLED=0 GOOS="${{ matrix.os }}" GOARCH="${{ matrix.arch }}" go build -o out/ ./cmd/...
[[ "${{ matrix.os }}" = "windows" ]] && suff=".exe"
cd out/
for p in *; do
mv "$p" "${p%.*}-${{ matrix.os }}-${{ matrix.arch }}-${{ needs.release-please.outputs.tag_name }}$suff"
done
cd -
- name: Upload
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.CR_PAT }}
file: out/*
file_glob: true
tag: ${{ needs.release-please.outputs.tag_name }}
build-docker:
name: Build, tag, and publish Docker image
runs-on: ubuntu-latest
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
version: latest
driver-opts: image=moby/buildkit:master
- name: Login into DockerHub
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Login into GitHub Container Registry
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and Push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
@@ -79,6 +104,8 @@ jobs:
ghcr.io/${{ github.repository }}:latest
${{ github.repository }}:${{ needs.release-please.outputs.tag_name }}
${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
notify-irc:
needs: [release-please]
name: Notify IRC