Skip to content

Build

Build #512

Workflow file for this run

name: Build
on:
schedule:
- cron: '0 5 * * *'
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
goreleaser:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
issues: write
steps:
# prepare
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v4
with:
go-version: stable
- uses: docker/setup-qemu-action@v2
# registry
- uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# build
- name: Snapshot on non-tag
uses: goreleaser/goreleaser-action@v4
if: startsWith(github.ref, 'refs/tags/') == false
with:
version: latest
args: release --snapshot --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release on tag
uses: goreleaser/goreleaser-action@v4
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# cache
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-cache-mod
- uses: actions/cache@v3
with:
path: .task/**/*
key: ${{ runner.os }}-go-task
# artifacts
- name: Artifact Linux
uses: actions/upload-artifact@v3
with:
name: build_linux
path: dist/*linux*
- name: Artifact Darwin
uses: actions/upload-artifact@v3
with:
name: build_darwin
path: dist/*darwin*
- name: Artifact Windows
uses: actions/upload-artifact@v3
with:
name: build_windows
path: dist/*windows*