Skip to content

Commit

Permalink
build: build binaries and upload to release
Browse files Browse the repository at this point in the history
  • Loading branch information
jj-style committed Apr 13, 2024
1 parent 01f59bc commit cbd7387
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 5 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: binaries
on:
workflow_dispatch:
push:
tags:
- v*

permissions:
contents: write

jobs:
build:
name: Build ${{ matrix.pkg }} for ${{ matrix.goos }}-${{ matrix.goarch }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
pkg: gobal-player-tui
artifact_name: gobal-player-tui-linux-amd64
- os: ubuntu-latest
goos: linux
goarch: amd64
pkg: gobal-player-server
artifact_name: gobal-player-server-linux-amd64
- os: ubuntu-latest
goos: linux
goarch: arm64
pkg: gobal-player-server
artifact_name: gobal-player-server-linux-arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: taiki-e/install-action@just

- name: Run tests and publish coverage
run: just containerize "GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} just build-pkg ${{ matrix.pkg }}"

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: bin/${{ matrix.artifact_name }}*
file_glob: true
asset_name: ${{ matrix.artifact_name }}
tag: ${{ github.ref }}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: taiki-e/install-action@just

- name: Run tests and publish coverage
run: just test-cover-ci
run: just containerize "just test-cover"

- name: Code Coverage Summary Report
uses: irongut/[email protected]
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions docker/go.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ FROM golang:1.22-bookworm
RUN apt update && apt install -y libvlc-dev vlc-plugin-base vlc-plugin-video-output curl && rm -rf /var/lib/apt/lists/*

RUN curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /bin

ENV GOCACHE=/tmp/go
20 changes: 16 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ test-cover: mocks
go install github.com/AlekSi/gocov-xml@latest
gocov test `go list ./... | grep -v mocks` | gocov-xml > coverage.xml

# run unit tests and produce coverage report (docker)
test-cover-ci:
docker compose -f docker/docker-compose.build.yml run --rm -v $(pwd):/work -w /work go sh -c "just test-cover"

# tidy modules
tidy:
go mod tidy
Expand All @@ -33,6 +29,12 @@ build:
@mkdir -p bin/
go build -o bin/ ./...

# build a specific package
build-pkg pkg:
@mkdir -p bin/
go build -o bin/{{pkg}}-${GOOS}-${GOARCH} ./cmd/{{pkg}}
@cd bin && sha256sum {{pkg}}-${GOOS}-${GOARCH} > {{pkg}}-${GOOS}-${GOARCH}.sha256

# generate mocks
mocks:
@go install github.com/vektra/mockery/v2@v2.42.0
Expand Down Expand Up @@ -64,3 +66,13 @@ hooks:
go install -v github.com/go-critic/go-critic/cmd/gocritic@latest
command -v pre-commit
pre-commit install

# run a command in a containerized environment
containerize +CMD:
docker compose \
-f docker/docker-compose.build.yml run \
--rm \
-v $(pwd):/work \
-w /work \
-u `id -u`:`id -g` \
go sh -c "{{CMD}}"

0 comments on commit cbd7387

Please sign in to comment.