Skip to content

Commit

Permalink
Merge pull request #120 from prymitive/fix-actions
Browse files Browse the repository at this point in the history
fix(ci): split actions into multiple jobs
  • Loading branch information
prymitive authored Nov 16, 2020
2 parents 77542ba + 4b594f0 commit 8c06c5d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Docker image
name: Docker

on:
push:
Expand All @@ -23,21 +23,26 @@ jobs:
- name: Build Docker image
run: docker build . --file Dockerfile --tag ${DOCKER_IMAGE}:latest

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Extract git tag
if: github.event_name == 'release'
id: git_ref
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}

- name: Tag Docker image
if: startsWith(github.ref, '/refs/tags/v.+')
if: github.event_name == 'release'
run: docker tag ${DOCKER_IMAGE}:latest ${DOCKER_IMAGE}:${{ steps.git_ref.outputs.TAG }}

- name: Login to Docker Hub
if: ${{ github.ref == 'refs/heads/master' }}
if: github.event_name == 'release'
shell: bash
run: echo "${DOCKER_HUB_PASSWORD}" | docker login -u lmierzwa --password-stdin
env:
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Push Docker image
if: ${{ github.ref == 'refs/heads/master' }}
if: github.event_name == 'release'
run: docker push ${DOCKER_IMAGE}
60 changes: 42 additions & 18 deletions .github/workflows/build.yml → .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Go binary
name: Go

on:
push:
Expand All @@ -12,50 +12,74 @@ on:
- published

jobs:
build:
golangci-lint:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.15
go-version: 1.15.5

- name: Cache Go modules
- name: Cache Go modules and build cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-mod-
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-

- name: Check out code
uses: actions/checkout@v2

- name: Install GolangCI
run: go install -modfile=tools/golangci-lint/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint

- name: Lint Go code
run: golangci-lint run

build:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15.5

- name: Cache Go build cache
- name: Cache Go modules and build cache
uses: actions/cache@v2
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-cache-
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-

- name: Check out code
uses: actions/checkout@v2

- name: Crosscompile binaries
run: make crosscompile -j 2

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Extract git tag
if: github.event_name == 'release'
id: git_ref
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}

- name: Crosscompile binaries
run: make crosscompile -j 2

- name: Compress binaries
if: startsWith(github.ref, '/refs/tags/v.+')
if: github.event_name == 'release'
run: |
mkdir -p artifacts
export SOURCE_DATE_EPOCH=$(git show -s --format=%ci ${{ steps.git_ref.outputs.TAG }}^${GITHUB_SHA})
for i in kthxbye-*; do tar --mtime="${SOURCE_DATE_EPOCH}" --owner=0 --group=0 --numeric-owner -c $i | gzip -n - > artifacts/$i.tar.gz; done
shasum -a 512 kthxbye-*.tar.gz | tee artifacts/sha512sum.txt
- name: Upload binaries to GitHub release
if: startsWith(github.ref, '/refs/tags/v.+')
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/lint.yml

This file was deleted.

16 changes: 11 additions & 5 deletions .github/workflows/tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,26 @@ on:
- master

jobs:
build:
tidy:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.15
go-version: 1.15.5

- name: Cache Go modules and build cache
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-

- name: Check out code
uses: actions/checkout@v2

- name: Fetch Go code
run: go get -d -v ./...

- name: Go mod tidy
run: go mod tidy

Expand Down

0 comments on commit 8c06c5d

Please sign in to comment.