build #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "**/*.go" | |
- "!**/*_test.go" | |
- ".dockerignore" | |
- "Dockerfile" | |
pull_request: | |
branches: | |
- main | |
paths: | |
- "**/*.go" | |
- "!**/*_test.go" | |
- ".dockerignore" | |
- "Dockerfile" | |
workflow_dispatch: {} | |
jobs: | |
build: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: "1.23.3" | |
- name: Test | |
run: | | |
go test ./... | |
go build -o ./bring | |
./bring version | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Login GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Prepare | |
id: prepare | |
run: | | |
export BRING_VERSION="$(gh release list --exclude-drafts --json tagName --jq '.[0].tagName')-run.${{ github.run_id }}" | |
echo "version=$BRING_VERSION" | tee -a $GITHUB_OUTPUT | |
./scripts/gen-version-file.sh | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Image meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/lesomnus/bring | |
tags: | | |
type=edge | |
type=version,value=${{ steps.prepare.outputs.version }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name == 'push' }} |