name: Build on: [push, pull_request] jobs: build: name: Build runs-on: ubuntu-latest steps: - name: Setup uses: actions/setup-go@v2 with: go-version: ^1.16 id: go - name: Cache Go modules uses: actions/cache@v2 with: path: | ~/go/pkg/mod ~/.cache/go-build key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-${{ matrix.go-version }}-go- - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Install tools run: make install - name: Assets run: make 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.37 - name: Test run: make test build-ui: name: Build UI runs-on: ubuntu-latest steps: - name: Cache NPM modules uses: actions/cache@v2 with: path: | **/node_modules key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- - name: Checkout uses: actions/checkout@v2 - name: Install tools run: make install-ui - name: Build run: make ui - name: Lint run: make lint-ui - name: Porcelain run: | test -z "$(git status --porcelain)" || (git status; git diff; false) dockerlatest: name: Publish :latest if: | startsWith(github.ref, 'refs/heads/master') && ! contains(github.head_ref, 'refs/heads/chore/') needs: - build - build-ui runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Install env: SEIHON_VERSION: v0.8.4 run: curl -sfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sudo bash -s -- -b $GOPATH/bin ${SEIHON_VERSION} - name: Login uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_PASS }} - name: Publish run: make publish-latest-ci dockerrelease: name: Publish :release if: "startsWith(github.ref, 'refs/tags')" needs: - build - build-ui 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 - build-ui runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Cache Go modules uses: actions/cache@v2 with: path: | ~/go/pkg/mod ~/.cache/go-build key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-${{ matrix.go-version }}-go- - name: Set up Go uses: actions/setup-go@v2 with: go-version: ^1.16 id: go - name: Prepare Image run: | make prepare-image sed -i -e 's#-ld.*$#& -X github.com/evcc-io/evcc/server/updater.Password=${{ secrets.IMAGE_PASS }}#' buildflags/github.com/evcc-io/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.* rm -rf flags buildflags - name: Create Github Release uses: goreleaser/goreleaser-action@v2 with: version: latest args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}