Add deb package and nightly distribution (#1977)

- Add publishing automated debian package releases via Cloudsmith.io, which allows evcc to be installed and updated via `apt`
- Add nightly docker (:latest) and deb distribution
- Disable docker builds for every commit on master
- Allow nightly builds to be triggered manually
This commit is contained in:
Andreas Linde 2021-12-04 13:05:18 +01:00 • committed by GitHub
parent 533731bf95
commit 54a4fe72ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 459 additions and 208 deletions

View file

@ -1,204 +0,0 @@
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: latest
skip-go-installation: true
skip-pkg-cache: true
skip-build-cache: true
- 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: Test
run: make test-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 }}

89
.github/workflows/default.yml vendored Normal file
View file

@ -0,0 +1,89 @@
name: Default
on: [push, pull_request, workflow_call]
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: latest
skip-go-installation: true
skip-pkg-cache: true
skip-build-cache: true
- 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: Test
run: make test-ui
- name: Porcelain
run: |
test -z "$(git status --porcelain)" || (git status; git diff; false)

113
.github/workflows/nightly.yml vendored Normal file
View file

@ -0,0 +1,113 @@
name: Nightly Build
on:
schedule: # runs on the default branch: master
- cron: '0 2 * * *' # run at 2 AM UTC
workflow_dispatch:
jobs:
check_date:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- uses: actions/checkout@v2
- name: print latest_commit
run: echo ${{ github.sha }}
- id: should_run
continue-on-error: true
name: check latest commit is less than a day
if: ${{ github.event_name == 'schedule' }}
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false"
call-build-workflow:
name: Call Build
needs: check_date
if: |
${{ needs.check_date.outputs.should_run != 'false' }}
&& startsWith(github.ref, 'refs/heads/master')
&& ! contains(github.head_ref, 'refs/heads/chore/')
uses: evcc-io/evcc/.github/workflows/default.yml@master
dockerlatest:
name: Publish Docker :latest
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
nightly:
name: Publish APT nightly
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: Install Cloudsmith CLI
run: pip install --upgrade cloudsmith-cli
- name: Clean git
run: |
git checkout go.*
rm -rf flags buildflags
- name: Create nightly build
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release -f .goreleaser-nightly.yml --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish .deb to Cloudsmith
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
run: |
for filename in dist/*.deb; do
echo "Pushing $filename to 'unstable'"
cloudsmith push deb evcc/unstable/any-distro/any-version $filename
done

103
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,103 @@
name: Release
on: [push]
jobs:
call-build-workflow:
if: "startsWith(github.ref, 'refs/tags')"
uses: evcc-io/evcc/.github/workflows/default.yml@master
dockerrelease:
name: Publish Docker :release
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: Publish Github & APT release
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: Install Cloudsmith CLI
run: pip install --upgrade cloudsmith-cli
# gokrazy image
# - 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 }}
- name: Publish .deb to Cloudsmith
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
run: |
for filename in dist/*.deb; do
echo "Pushing $filename to 'stable'"
cloudsmith push deb evcc/stable/any-distro/any-version $filename
done