124 lines
3.1 KiB
YAML
124 lines
3.1 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '*'
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# dependencies
|
|
- name: dependencies
|
|
run: |
|
|
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sudo sh -s -- -b /usr/local/bin
|
|
|
|
# checkout
|
|
- name: checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
# setup go
|
|
- name: go
|
|
uses: actions/setup-go@v1
|
|
with:
|
|
go-version: 1.16
|
|
- run: go version
|
|
- run: go env
|
|
|
|
# cache
|
|
- name: cache
|
|
uses: actions/cache@v1
|
|
with:
|
|
path: vendor
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
|
|
# vendor
|
|
- name: vendor
|
|
run: |
|
|
make vendor
|
|
|
|
# git status
|
|
- run: git status
|
|
|
|
# build
|
|
- name: build
|
|
if: startsWith(github.ref, 'refs/tags/') == false
|
|
run: |
|
|
make snapshot
|
|
|
|
# publish
|
|
- name: publish
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
GITHUB_REF: ${{ github.ref }}
|
|
run: |
|
|
make publish
|
|
|
|
# artifacts
|
|
- name: artifact_linux
|
|
uses: actions/upload-artifact@v2-preview
|
|
with:
|
|
name: build_linux
|
|
path: dist/*linux*
|
|
|
|
- name: artifact_darwin
|
|
uses: actions/upload-artifact@v2-preview
|
|
with:
|
|
name: build_darwin
|
|
path: dist/*darwin*
|
|
|
|
- name: artifact_windows
|
|
uses: actions/upload-artifact@v2-preview
|
|
with:
|
|
name: build_windows
|
|
path: dist/*windows*
|
|
|
|
# docker build (latest & tag)
|
|
- name: docker - build latest
|
|
if: startsWith(github.ref, 'refs/tags/') == true
|
|
uses: docker/build-push-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
repository: cloudb0x/nabarr
|
|
dockerfile: docker/Dockerfile
|
|
tags: latest
|
|
tag_with_ref: true
|
|
tag_with_sha: false
|
|
always_pull: true
|
|
|
|
# docker build (master)
|
|
- name: docker - build master
|
|
if: github.ref == 'refs/heads/master'
|
|
uses: docker/build-push-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
repository: cloudb0x/nabarr
|
|
dockerfile: docker/Dockerfile
|
|
tags: master
|
|
tag_with_ref: false
|
|
tag_with_sha: false
|
|
always_pull: true
|
|
|
|
# docker build (branch)
|
|
- name: docker - build other
|
|
if: startsWith(github.ref, 'refs/heads/master') == false
|
|
uses: docker/build-push-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
repository: cloudb0x/nabarr
|
|
dockerfile: docker/Dockerfile
|
|
tag_with_ref: true
|
|
tag_with_sha: false
|
|
always_pull: true
|