134
.github/workflows/build.yml
vendored
Normal file
134
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- edited
|
||||
|
||||
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.15
|
||||
- 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
|
||||
|
||||
# build
|
||||
- name: build
|
||||
if: startsWith(github.ref, 'refs/tags/') == false
|
||||
run: |
|
||||
make snapshot
|
||||
|
||||
# get tag name
|
||||
- name: tag_name
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: little-core-labs/get-git-tag@v3.0.2
|
||||
with:
|
||||
tagRegex: "v?(.+)"
|
||||
|
||||
# publish
|
||||
- name: publish
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
env:
|
||||
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: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
registry: docker.pkg.github.com
|
||||
repository: l3uddz/nabarr/nabarr
|
||||
dockerfile: docker/Dockerfile
|
||||
tags: latest
|
||||
tag_with_ref: true
|
||||
tag_with_sha: true
|
||||
always_pull: true
|
||||
|
||||
# docker build (master)
|
||||
- name: docker - build master
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
registry: docker.pkg.github.com
|
||||
repository: l3uddz/nabarr/nabarr
|
||||
dockerfile: docker/Dockerfile
|
||||
tags: master
|
||||
tag_with_sha: true
|
||||
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: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
registry: docker.pkg.github.com
|
||||
repository: l3uddz/nabarr/nabarr
|
||||
dockerfile: docker/Dockerfile
|
||||
tag_with_ref: true
|
||||
tag_with_sha: false
|
||||
always_pull: true
|
||||
Reference in New Issue
Block a user