-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37a8870
commit 7aa7d46
Showing
6 changed files
with
159 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,52 +11,51 @@ jobs: | |
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15.x | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Run linters | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: v1.29 | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.x | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Run linters | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: v1.29 | ||
|
||
test: | ||
strategy: | ||
matrix: | ||
go-version: [1.15.x] | ||
go-version: [1.17.x] | ||
platform: [ubuntu-latest, macos-latest, windows-latest] | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- name: Install Go | ||
if: success() | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Run tests | ||
run: go test -v -covermode=count | ||
- name: Install Go | ||
if: success() | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Run tests | ||
run: go test -v -covermode=count | ||
|
||
coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Go | ||
if: success() | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15.x | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Calc coverage | ||
run: | | ||
go test -v -covermode=count -coverprofile=coverage.out | ||
- name: Convert coverage.out to coverage.lcov | ||
uses: jandelgado/[email protected] | ||
- name: Coveralls | ||
uses: coverallsapp/[email protected] | ||
with: | ||
- name: Install Go | ||
if: success() | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.x | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Calc coverage | ||
run: | | ||
go test -v -covermode=count -coverprofile=coverage.out | ||
- name: Convert coverage.out to coverage.lcov | ||
uses: jandelgado/[email protected] | ||
- name: Coveralls | ||
uses: coverallsapp/[email protected] | ||
with: | ||
github-token: ${{ secrets.github_token }} | ||
path-to-lcov: coverage.lcov | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,55 @@ | ||
on: | ||
release: | ||
types: [created] | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
name: Upload release assets after release is created | ||
name: Upload release assets after tagging | ||
jobs: | ||
build: | ||
name: build binaries | ||
name: create assets | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15.x | ||
go-version: 1.17.x | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: build | ||
run: | | ||
echo "GO111MODULE=on" >> $GITHUB_ENV | ||
GOOS=windows GOARCH=amd64 go build -o bin/ci-test-windows-amd64.exe | ||
GOOS=linux GOARCH=amd64 go build -o bin/ci-test-linux-amd64 | ||
GOOS=darwin GOARCH=amd64 go build -o bin/ci-test-macos-amd64 | ||
- name: upload artifacts | ||
uses: actions/upload-artifact@master | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
name: binaries | ||
path: bin/ | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
upload: | ||
name: Upload release assets | ||
docker-image: | ||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
name: create docker image | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
steps: | ||
|
||
- name: Branch name | ||
id: branch_name | ||
run: | | ||
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/} | ||
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/} | ||
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Download build artefacts | ||
uses: actions/download-artifact@v1 | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
name: binaries | ||
path: bin/ | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: build Docker image | ||
run: | | ||
VERSION=$(git describe --tags) | ||
docker build --build-arg "version=$VERSION" --tag ${IMAGE_NAME} . | ||
- name: Create asset zips | ||
env: | ||
SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }} | ||
- name: push Docker image | ||
run: | | ||
mkdir assets | ||
zip assets/ci-test-${SOURCE_TAG}-windows-amd64.zip bin/ci-test-windows-amd64.exe README.md | ||
zip assets/ci-test-${SOURCE_TAG}-linux-amd64.zip bin/ci-test-linux-amd64 README.md | ||
zip assets/ci-test-${SOURCE_TAG}-darwin-amd64.zip bin/ci-test-darwin-amd64 README.md | ||
sha256sum assets/*zip > assets/SHASUMS256.txt | ||
TAG=$(git describe --tags) | ||
docker tag ${IMAGE_NAME} ${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA} | ||
docker tag ${IMAGE_NAME} ${REGISTRY}/${IMAGE_NAME}:${TAG} | ||
docker tag ${IMAGE_NAME} ${REGISTRY}/${IMAGE_NAME}:latest | ||
docker push ${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA} | ||
docker push ${REGISTRY}/${IMAGE_NAME}:${TAG} | ||
docker push ${REGISTRY}/${IMAGE_NAME}:latest | ||
- name: Upload release assets | ||
uses: skx/github-action-publish-binaries@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
args: './assets/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This is an example .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
before: | ||
hooks: | ||
# You may remove this if you don't use go modules. | ||
- go mod tidy | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
dir: . | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
- freebsd | ||
archives: | ||
- files: | ||
- README.md | ||
- LICENSE | ||
replacements: | ||
darwin: Darwin | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ incpatch .Version }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# example docker image for | ||
# https://github.com/jandelgado/golang-ci-template-github-actions/ | ||
|
||
FROM golang:1.17-alpine as builder | ||
ARG version | ||
|
||
WORKDIR /go/src/app | ||
ADD . /go/src/app | ||
|
||
RUN CGO_ENABLED=0 \ | ||
go build -ldflags "-s -w" -o app | ||
|
||
FROM gcr.io/distroless/base-debian10 | ||
LABEL maintainer="Jan Delgado <[email protected]>" | ||
|
||
COPY --from=builder /go/src/app/app / | ||
ENTRYPOINT ["/app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module github.com/jandelgado/golang-ci-template-github-actions | ||
|
||
go 1.12 | ||
go 1.17 |