Skip to content

Commit

Permalink
Setup Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
SkYNewZ committed Apr 6, 2020
1 parent 834c2a7 commit dd99cbd
Show file tree
Hide file tree
Showing 14 changed files with 422 additions and 92 deletions.
49 changes: 49 additions & 0 deletions .chglog/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{ if .Versions -}}
<a name="unreleased"></a>
## [Unreleased]

{{ if .Unreleased.CommitGroups -}}
{{ range .Unreleased.CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}

{{- if .RevertCommits -}}
### Reverts
{{ range .RevertCommits -}}
- {{ .Revert.Header }}
{{ end }}
{{ end -}}

{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{- if .Versions }}
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
{{ range .Versions -}}
{{ if .Tag.Previous -}}
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
{{ end -}}
{{ end -}}
{{ end -}}
28 changes: 28 additions & 0 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/SkYNewZ/radarr-go
options:
commits:
# filters:
# Type:
# - feat
# - fix
# - perf
# - refactor
commit_groups:
# title_maps:
# feat: Features
# fix: Bug Fixes
# perf: Performance Improvements
# refactor: Code Refactoring
header:
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
pattern_maps:
- Type
- Scope
- Subject
notes:
keywords:
- BREAKING CHANGE
104 changes: 104 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Push

on:
push:
branches-ignore: [master]

jobs:
lint:
name: Lint code
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Install golint
run: go get -u -v golang.org/x/lint/golint

- name: Lint!
run: |
export PATH=$PATH:$(go env GOPATH)/bin
golint -set_exit_status ./...
format:
name: Go format
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Test gogmt
run: test $(gofmt -l -e . | wc -l) -eq 0

- name: Print gofmt errors
if: failure()
run: gofmt -d .

test:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Execute local tests
run: go test -v -coverprofile=cover.out -cover ./...

- name: Generate coverage report
run: go tool cover -html=cover.out -o coverage.html

- name: Upload code coverage report
uses: actions/upload-artifact@v1
with:
name: code-coverage-report
path: coverage.html

install:
name: Install
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Go install
run: go install .

install:
name: Install
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Go install
run: go install .
168 changes: 168 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: Release package

on:
pull_request:
branches: [master]
push:
tags:
- "v*.*.*"
- "!v*.*.*-*"

jobs:
lint:
name: Lint code
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Install golint
run: go get -u -v golang.org/x/lint/golint

- name: Lint!
run: |
export PATH=$PATH:$(go env GOPATH)/bin
golint -set_exit_status ./...
format:
name: Go format
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Test gogmt
run: test $(gofmt -l -e . | wc -l) -eq 0

- name: Print gofmt errors
if: failure()
run: gofmt -d .

test:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Execute local tests
run: go test -v -coverprofile=cover.out -cover ./...

- name: Generate coverage report
run: go tool cover -html=cover.out -o coverage.html

- name: Upload code coverage report
uses: actions/upload-artifact@v1
with:
name: code-coverage-report
path: coverage.html

install:
name: Install
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Go install
run: go install .

build:
name: Build
needs:
- lint
- format
- test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Setup gox
run: go get github.com/mitchellh/gox

- name: Build
run: |
REPO_ROOT=$(git rev-parse --show-toplevel)
export PATH=$PATH:$(go env GOPATH)/bin
export VERSION=$(git describe --tags --exact-match 2>/dev/null)
(cd ./cmd/radarr; gox -os="darwin linux windows" -arch="amd64" -output="$REPO_ROOT/bin/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags "-X main.Version=${VERSION}")
- name: Upload them as artifacts
uses: actions/upload-artifact@v1
with:
name: binaries
path: bin

release:
name: Github Release
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Set up Go 1.14
if: startsWith(github.ref, 'refs/tags/')
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Checkout code
if: startsWith(github.ref, 'refs/tags/')
uses: actions/checkout@v2

- name: Get back artifacts
if: startsWith(github.ref, 'refs/tags/')
uses: actions/download-artifact@v1
with:
name: binaries

- name: Install git-chglog
if: startsWith(github.ref, 'refs/tags/')
run: go get -u github.com/git-chglog/git-chglog/cmd/git-chglog

- name: Generate changelog
if: startsWith(github.ref, 'refs/tags/')
run: |
export PATH=$PATH:$(go env GOPATH)/bin
git-chglog -o CHANGELOG.md
- name: Create a new release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: binaries/radarr*
body_path: CHANGELOG.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
coverage.html

# Dependency directories (remove the comment below to include it)
# vendor/
Expand Down
Loading

0 comments on commit dd99cbd

Please sign in to comment.