mirror of
https://github.com/wagoodman/dive
synced 2026-03-14 22:35:50 +01:00
enhance gha pipeline for release
This commit is contained in:
parent
9a34db493b
commit
7a5992fe18
7 changed files with 186 additions and 133 deletions
130
.github/workflows/pipeline.yml
vendored
Normal file
130
.github/workflows/pipeline.yml
vendored
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
name: 'app-pipeline'
|
||||
on: [ push, pull_request ]
|
||||
env:
|
||||
DOCKER_CLI_VERSION: "19.03.1"
|
||||
jobs:
|
||||
unit-test:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.12.x, 1.13.x]
|
||||
# todo: support windows
|
||||
platform: [ubuntu-latest, macos-latest]
|
||||
# platform: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
|
||||
- uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Cache go dependencies
|
||||
id: unit-cache-go-dependencies
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Install go dependencies
|
||||
if: steps.unit-cache-go-dependencies.outputs.cache-hit != 'true'
|
||||
run: go get ./...
|
||||
|
||||
- name: Test
|
||||
run: make ci-test
|
||||
|
||||
build-artifacts:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.13.x'
|
||||
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Install go tools
|
||||
run: make ci-install-go-tools
|
||||
|
||||
- name: Cache go dependencies
|
||||
id: package-cache-go-dependencies
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.package-cache-go-dependencies.outputs.cache-hit != 'true'
|
||||
run: go get ./...
|
||||
|
||||
# todo: test gofmt
|
||||
|
||||
- name: Lint
|
||||
run: golangci-lint run -v
|
||||
|
||||
- name: Build snapshot artifacts
|
||||
uses: goreleaser/goreleaser-action@v1
|
||||
with:
|
||||
version: latest
|
||||
args: release --snapshot --skip-publish --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- run: docker images wagoodman/dive
|
||||
|
||||
# todo: compare against known json output in shared volume
|
||||
- name: Test production image
|
||||
run: make ci-test-production-image
|
||||
|
||||
- uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: artifacts
|
||||
path: dist
|
||||
|
||||
release:
|
||||
needs: [ build-artifacts, unit-test ]
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
steps:
|
||||
|
||||
- uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.13.x'
|
||||
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Cache go dependencies
|
||||
id: release-cache-go-dependencies
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.release-cache-go-dependencies.outputs.cache-hit != 'true'
|
||||
run: go get ./...
|
||||
|
||||
- name: Docker login
|
||||
run: make ci-docker-login
|
||||
env:
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Publish GitHub release
|
||||
uses: goreleaser/goreleaser-action@v1
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Docker logout
|
||||
run: make ci-docker-logout
|
||||
|
||||
- name: Smoke test published image
|
||||
run: make ci-test-production-image
|
||||
38
.github/workflows/push.yml
vendored
38
.github/workflows/push.yml
vendored
|
|
@ -1,38 +0,0 @@
|
|||
name: 'snapshot'
|
||||
on: [ push, pull_request ]
|
||||
jobs:
|
||||
pkg:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.13.x'
|
||||
- uses: actions/checkout@v1
|
||||
- name: install deps
|
||||
run: |
|
||||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sudo sh -s -- -b /usr/local/bin/ latest
|
||||
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sudo sh -s -- -b /usr/local/bin/ latest
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libdevmapper-dev libgpgme11-dev
|
||||
- run: go get ./...
|
||||
- run: golangci-lint run -v
|
||||
- run: goreleaser --snapshot --skip-publish --rm-dist
|
||||
- uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: ubuntu
|
||||
path: dist
|
||||
|
||||
docker:
|
||||
needs: [ pkg ]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.13.x'
|
||||
- uses: actions/checkout@v1
|
||||
- run: ./docker.sh
|
||||
- run: docker images
|
||||
- uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: alpine
|
||||
path: dist
|
||||
Loading…
Add table
Add a link
Reference in a new issue