mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-17 13:11:42 +03:00
ff23d7b6d7
* CI revamped and other enhancements GoReleaser for multi-arch binaries Switch to GitHub Actions (more versatile) with 2 workflows Docker multi-manifest image with buildx Fix eslint run script Go sum fixer Use tools.go paradigm for external dependencies (packr) Use go generate for packr * Update workflows * Add Slack notification * Rebase * Enhanced Dockerfile * Fix go generate * Fix Golangci lint * Fix npm cache with v2 cache action * Fix Dockerfile * Trigger notif * Issue with packr * s390x platform not supported by packr * Enhance layers * Fix go modules Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
260 lines
7.5 KiB
YAML
260 lines
7.5 KiB
YAML
name: build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
tags:
|
|
- v*
|
|
pull_request:
|
|
|
|
jobs:
|
|
|
|
test:
|
|
runs-on: ${{ matrix.os }}
|
|
env:
|
|
GO111MODULE: on
|
|
GOPROXY: https://goproxy.io
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- ubuntu-latest
|
|
- macOS-latest
|
|
- windows-latest
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v2
|
|
-
|
|
name: Set up Go
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: 1.14
|
|
-
|
|
name: Set up Node
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 13
|
|
-
|
|
name: Set up Go modules cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
-
|
|
name: Get npm cache directory
|
|
id: npm-cache
|
|
run: |
|
|
echo "::set-output name=dir::$(npm config get cache)"
|
|
-
|
|
name: Set up npm cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ${{ steps.npm-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-node-${{ hashFiles('client/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
-
|
|
name: Run node build-prod
|
|
shell: bash
|
|
run: |
|
|
npm --prefix client ci
|
|
npm --prefix client run build-prod
|
|
-
|
|
name: Download modules and generate
|
|
shell: bash
|
|
run: |
|
|
go mod download
|
|
go generate ./...
|
|
-
|
|
name: Golangci-lint
|
|
if: matrix.os != 'windows-latest'
|
|
shell: bash
|
|
run: |
|
|
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.23.8
|
|
golangci-lint --version
|
|
golangci-lint run
|
|
-
|
|
name: Go test
|
|
run: |
|
|
go test -race -v -bench=. -coverprofile=coverage.txt -covermode=atomic ./...
|
|
-
|
|
name: Upload coverage
|
|
uses: codecov/codecov-action@v1
|
|
if: success()
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
file: ./coverage.txt
|
|
|
|
app:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v2
|
|
-
|
|
name: Prepare
|
|
id: prepare
|
|
run: |
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
echo ::set-output name=tag_name::${GITHUB_REF#refs/tags/}
|
|
echo ::set-output name=channel::release
|
|
else
|
|
echo ::set-output name=channel::none
|
|
fi
|
|
-
|
|
name: Set up Go
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: 1.14
|
|
-
|
|
name: Set up Node
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 13
|
|
-
|
|
name: Set up Go modules cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
-
|
|
name: Get npm cache directory
|
|
id: npm-cache
|
|
run: |
|
|
echo "::set-output name=dir::$(npm config get cache)"
|
|
-
|
|
name: Set up node_modules cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ${{ steps.npm-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-node-${{ hashFiles('client/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
-
|
|
name: Set up Snapcraft
|
|
run: |
|
|
sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft
|
|
-
|
|
name: Run node build-prod
|
|
run: |
|
|
npm --prefix client ci
|
|
npm --prefix client run build-prod
|
|
-
|
|
name: Snapcraft Login
|
|
if: success() && startsWith(github.ref, 'refs/tags/v')
|
|
env:
|
|
SNAPCRAFT_LOGIN: ${{ secrets.SNAPCRAFT_LOGIN }}
|
|
run: |
|
|
snapcraft login --with <(echo "$SNAPCRAFT_LOGIN")
|
|
-
|
|
name: GoReleaser
|
|
uses: goreleaser/goreleaser-action@v2
|
|
with:
|
|
version: latest
|
|
args: release --parallelism 2
|
|
env:
|
|
CHANNEL: ${{ steps.prepare.outputs.channel }}
|
|
-
|
|
name: GitHub Release
|
|
uses: softprops/action-gh-release@v1
|
|
if: success() && startsWith(github.ref, 'refs/tags/v')
|
|
with:
|
|
draft: true
|
|
files: |
|
|
dist/checksums.txt
|
|
dist/*.tar.gz
|
|
dist/*.zip
|
|
name: AdGuard Home ${{ steps.prepare.outputs.tag_name }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
-
|
|
name: Prepare
|
|
id: prepare
|
|
run: |
|
|
DOCKER_IMAGE=adguard/adguardhome
|
|
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
|
|
VERSION=edge
|
|
CHANNEL=none
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
VERSION=${GITHUB_REF#refs/tags/v}
|
|
CHANNEL=release
|
|
fi
|
|
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
|
|
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
|
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
|
|
fi
|
|
|
|
echo ::set-output name=docker_image::${DOCKER_IMAGE}
|
|
echo ::set-output name=version::${VERSION}
|
|
echo ::set-output name=channel::${CHANNEL}
|
|
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
|
|
--build-arg VERSION=${VERSION} \
|
|
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
|
|
--build-arg VCS_REF=${GITHUB_SHA::8} \
|
|
${TAGS} \
|
|
--file Dockerfile .
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: crazy-max/ghaction-docker-buildx@v1
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v2
|
|
-
|
|
name: Docker Buildx (build)
|
|
run: |
|
|
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
|
|
-
|
|
name: Docker Login
|
|
if: success() && startsWith(github.ref, 'refs/tags/v')
|
|
env:
|
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
run: |
|
|
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
|
|
-
|
|
name: Docker Buildx (push)
|
|
if: success() && startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
|
|
-
|
|
name: Docker Check Manifest
|
|
if: always() && startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
|
|
-
|
|
name: Clear
|
|
if: always() && startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
rm -f ${HOME}/.docker/config.json
|
|
|
|
notify:
|
|
needs: [app, docker]
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Conclusion
|
|
uses: technote-space/workflow-conclusion-action@v1
|
|
-
|
|
name: Send Slack notif
|
|
uses: 8398a7/action-slack@v3
|
|
with:
|
|
status: ${{ env.WORKFLOW_CONCLUSION }}
|
|
fields: repo,message,commit,author
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|