evcc-io/.github/workflows/build.yml
2021-01-27 15:59:23 +01:00

160 lines
3.5 KiB
YAML

name: Build
on:
push:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Setup
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
**/node_modules
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-go-
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install tools
run: make install
- name: Assets & UI
run: make npm assets
- name: Porcelain
run: |
go mod tidy
test -z "$(git status --porcelain)" || (git status; git diff; false)
- name: Build
run: make build
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.33
- name: Test
run: make test
dockerlatest:
name: Publish :latest
if: |
startsWith(github.ref, 'refs/heads/master')
&& ! contains(github.head_ref, 'refs/heads/chore/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install
run: curl -sfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sudo bash -s -- -b $GOPATH/bin v0.5.1
- name: Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Publish
run: make publish-latest
dockerrelease:
name: Publish :release
if: "startsWith(github.ref, 'refs/tags')"
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: refs/heads/master # force master
fetch-depth: 0
- name: Install
run: curl -sfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sudo bash -s -- -b $GOPATH/bin v0.5.1
- name: Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Publish
run: make publish-images
release:
name: Release
if: "startsWith(github.ref, 'refs/tags')"
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
**/node_modules
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go
- name: Prepare Image
run: |
make prepare-image
sed -i -e 's#-ld.*$#& -X github.com/andig/evcc/server/updater.Password=${{ secrets.IMAGE_PASS }}#' buildflags/github.com/andig/evcc/buildflags.txt
mkdir /home/runner/.config/gokrazy
echo ${{ secrets.IMAGE_PASS }}> /home/runner/.config/gokrazy/http-password.txt
- name: Build Image
run: make image
- name: Build Root Filesystem
run: make image-rootfs
- name: Clean git
run: |
git checkout go.*
rmdir flags buildflags
- name: Create Github Release
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}