Compare commits

..

55 Commits

Author SHA1 Message Date
Sebastian
cc22d5d4db Merge pull request #42 from Nightapes/fix/asset
fix(internal/assets): close zip writer before closing zip file
2020-05-21 11:06:24 +02:00
fwiedmann
c84b51d18c fix(internal/assets): close zip writer before closing zip file 2020-05-21 00:45:59 +02:00
Felix Wiedmann
11acc95a34 Merge pull request #41 from Nightapes/fix.assets
fix(assets): when file is zipped, upload zipped file instead of unzipped file
2020-03-25 09:01:03 +01:00
Sebastian Beisch
be35b743b4 fix(assets): when file is zipped, upload zipped file instead of unzipped file 2020-03-25 08:45:27 +01:00
Felix Wiedmann
322455b6d4 Merge pull request #40 from Nightapes/checksum
feat(assets): calculate checksum for all assets and upload it
2020-03-24 21:18:18 +01:00
Nightapes
400a25f950 style(assets): rename container to set 2020-03-24 19:56:57 +01:00
Nightapes
92600059c2 style(assets): rename container to set 2020-03-24 19:51:18 +01:00
Nightapes
666716d627 refactor(assets): check asset only on release 2020-03-21 16:04:18 +01:00
Nightapes
6fd34d3e0a feat(assets): calculate checksum for all assets and upload it 2020-03-21 15:47:03 +01:00
Sebastian
cc957cb3f2 Merge pull request #39 from Nightapes/fix/ci
ci(upload-artifacts): always upload artifact and build docker image f…
2020-02-29 16:16:08 +01:00
fwiedmann
cf87c74d1d ci(upload-artifacts): always upload artifact and build docker image for go 1.14 2020-02-28 17:35:23 +01:00
Felix Wiedmann
0aa8146902 Merge pull request #37 from Nightapes/ci.matrix
ci(github): add golang 1.14 and macos
2020-02-27 23:15:19 +01:00
Nightapes
632e6ea2d3 ci(actions): checkout code for release job 2020-02-27 22:19:55 +01:00
Nightapes
460710ff39 ci(actions): make file executable 2020-02-27 22:14:26 +01:00
Nightapes
ba59e8db63 fix(deps): update cobra,net,crypto and sys 2020-02-27 22:12:08 +01:00
Nightapes
5c5ca98978 ci(actions): only use latest artifacts 2020-02-27 21:56:42 +01:00
Nightapes
9954e67e88 ci(actions): fix depends on build 2020-02-27 21:46:09 +01:00
Nightapes
4f728a7984 Merge branch 'ci.matrix' of github.com:Nightapes/go-semantic-release into ci.matrix 2020-02-27 21:44:35 +01:00
Nightapes
a76aec25dd ci(github): add golang 1.14 and macos 2020-02-27 21:43:12 +01:00
Nightapes
1b3687a99d ci(github): add golang 1.14 and macos 2020-02-27 21:40:49 +01:00
Sebastian
875dbdcfc4 dcos(README): add badge 2020-02-19 19:40:24 +01:00
Felix Wiedmann
2208427b65 Merge pull request #35 from Nightapes/feat/currentversion
feat(cli): add current version command
2020-02-18 22:55:16 +01:00
Nightapes
5cb83dead4 chore(deps): update all dependencies 2020-02-18 19:19:22 +01:00
Nightapes
343e660e8e feat(cli): add current version command 2020-02-18 19:19:09 +01:00
Sebastian
95bef6cb2d docs(README): add download info 2020-02-07 16:36:38 +01:00
Felix Wiedmann
a6dcad2b69 Merge pull request #33 from Nightapes/beta
fix(prerelease): calculate right version if branch is set to alpha,beta or rc
2020-01-26 17:16:48 +01:00
Sebastian
af5c8f5ae3 Merge pull request #32 from Nightapes/fix.beta-release
fix(prerelease): calculate right version if branch is set to alpha,beta or rc
2020-01-26 17:11:49 +01:00
Nightapes
c361744a35 fix(prerelease): calculate right version if branch is set to alpha,beta or rc 2020-01-26 17:08:57 +01:00
Felix Wiedmann
6a375f3bab Merge pull request #30 from jthurman42/jthurman/optional-scope
Only print scope if one was defined
2020-01-15 22:58:50 +01:00
Jonathan Thurman
d4627a9d46 fix(internal/changelog): Only print scope if one was defined 2020-01-14 19:35:54 -08:00
Felix Wiedmann
af2addbffd Merge pull request #29 from Nightapes/typo
fix(gitutil): fix log message for tags
2020-01-08 22:49:28 +01:00
Nightapes
7157d64b7b style(hooks): fix lint issues 2020-01-06 17:45:52 +01:00
Nightapes
575ba5d5bd fix(hooks): improve cmd execution 2020-01-06 17:41:10 +01:00
Nightapes
a8b68f9182 build(docker): fix github naming 2020-01-06 12:51:01 +01:00
Nightapes
f6a2d837b1 buikd(docker): add github docker registy 2020-01-06 12:47:02 +01:00
Nightapes
279509c922 docs(README): fix typo 2020-01-06 12:44:10 +01:00
Nightapes
d0035d6bca fix(gitutil): fix log message for tags 2020-01-06 12:14:41 +01:00
Felix Wiedmann
1342714579 Merge pull request #28 from Nightapes/git_provider
Git provider and hooks
2020-01-05 21:38:10 +01:00
Nightapes
d92438b339 test(hooks): fix testing 2020-01-05 19:10:07 +01:00
Nightapes
aff2203d66 style(github): fix lint issues 2020-01-05 19:06:15 +01:00
Nightapes
113ddf2b1f build(ci): use new hooks for docker release 2020-01-05 19:02:20 +01:00
Nightapes
8e3c446605 docs(README): add hooks 2020-01-05 18:56:37 +01:00
Nightapes
8ea92efb90 feat(hooks): add pre and post release hooks 2020-01-05 18:56:37 +01:00
Nightapes
42fc522a43 feat(releaser): add git only as releaser, will create a new tag with version only 2020-01-05 18:55:47 +01:00
Felix Wiedmann
6211095c38 Merge pull request #27 from Nightapes/fix_commits
fix(commits):  don't break if commit is found and error happens on ol…
2019-10-08 21:09:43 +02:00
Nightapes
74e895b5ad fix(commits): don't break if commit is found and error happens on older commits and add better error message when git clone --depth is used 2019-10-08 20:46:57 +02:00
Sebastian
a69da92340 Merge pull request #26 from Nightapes/fix/build
build(workflow): fix call of binary
2019-09-25 10:42:44 +02:00
fwiedmann
ff87725801 build(workflow): fix call of binary 2019-09-25 00:20:41 +02:00
Felix Wiedmann
272a9b6e89 Merge pull request #25 from Nightapes/improvements
Improvements
2019-09-25 00:12:09 +02:00
Sebastian
07b606a21a Merge branch 'master' into improvements 2019-09-22 15:52:45 +02:00
Nightapes
44f95969bf feat(template): allow custom changelog template 2019-09-22 15:50:12 +02:00
Nightapes
399a3515f2 feat(docker): add docker image with go-semantic-release 2019-09-22 15:49:06 +02:00
Nightapes
2074877a3b build(pages): add jemoji plugin 2019-09-22 15:42:08 +02:00
Sebastian
b5551d8432 Set theme jekyll-theme-cayman 2019-09-22 15:34:33 +02:00
Sebastian
c92020d3ac Set theme jekyll-theme-slate 2019-09-22 15:33:05 +02:00
41 changed files with 1479 additions and 511 deletions

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
*
!build/

View File

@@ -1,16 +1,17 @@
name: Go name: Go
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
build: build:
name: Build strategy:
matrix:
go: ["1.13", "1.14"]
name: Build with go version ${{ matrix.go }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Go 1.14
- name: Set up Go 1.13
uses: actions/setup-go@v1 uses: actions/setup-go@v1
with: with:
go-version: 1.13 go-version: ${{ matrix.go }}
id: go id: go
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
@@ -31,10 +32,40 @@ jobs:
run: | run: |
go build -o build/go-semantic-release-temp ./cmd/go-semantic-release/ go build -o build/go-semantic-release-temp ./cmd/go-semantic-release/
./build/go-semantic-release-temp next --no-cache --loglevel trace ./build/go-semantic-release-temp next --no-cache --loglevel trace
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o build/go-semantic-release -ldflags "-w -s --X main.version=`./build/go-semantic-release-temp next`" ./cmd/go-semantic-release/ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o build/go-semantic-release.linux_x86_64 -ldflags "-w -s --X main.version=`./build/go-semantic-release-temp next`" ./cmd/go-semantic-release/
GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -o build/go-semantic-release.exe -ldflags "-w -s -X main.version=`./build/go-semantic-release-temp next`" ./cmd/go-semantic-release/ GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -o build/go-semantic-release.windows_i386.exe -ldflags "-w -s -X main.version=`./build/go-semantic-release-temp next`" ./cmd/go-semantic-release/
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o build/go-semantic-release.windows_x86_64.exe -ldflags "-w -s -X main.version=`./build/go-semantic-release-temp next`" ./cmd/go-semantic-release/
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o build/go-semantic-release.darwin_x86_64 -ldflags "-w -s -X main.version=`./build/go-semantic-release-temp next`" ./cmd/go-semantic-release/
- name: Build Docker image
if: matrix.go == '1.14'
run: |
docker login -u nightapes -p ${{ secrets.DOCKER_PASSWORD }}
docker login -u nightapes -p ${{ secrets.GITHUB_TOKEN }} docker.pkg.github.com
docker build -t nightapes/go-semantic-release:development-${{matrix.go}} .
docker push nightapes/go-semantic-release:development-${{matrix.go}}
docker tag nightapes/go-semantic-release:development-${{matrix.go}} docker.pkg.github.com/nightapes/go-semantic-release/go-semantic-release:development-${{matrix.go}}
docker push docker.pkg.github.com/nightapes/go-semantic-release/go-semantic-release:development-${{matrix.go}}
- uses: actions/upload-artifact@v1
if: matrix.go == '1.14'
with:
name: build
path: build
release:
name: Release
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- uses: actions/download-artifact@v1
with:
name: build
path: build
- name: Release - name: Release
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./build/go-semantic-release-temp release --loglevel trace run: |
chmod -R +x build
docker login -u nightapes -p ${{ secrets.DOCKER_PASSWORD }}
docker login -u nightapes -p $GITHUB_TOKEN docker.pkg.github.com
./build/go-semantic-release-temp release --loglevel trace

1
.gitignore vendored
View File

@@ -17,3 +17,4 @@ go-semantic-release
CHANGELOG.md CHANGELOG.md
cover.html cover.html
build/ build/
.idea/

View File

@@ -1,12 +1,30 @@
release: 'github' release: "github"
github: github:
repo: "go-semantic-release" repo: "go-semantic-release"
user: "nightapes" user: "nightapes"
commitFormat: angular commitFormat: angular
branch: branch:
master: release master: release
beta: beta
assets: assets:
- name: ./build/go-semantic-release - name: ./build/go-semantic-release.linux_x86_64
compress: false compress: true
- name: ./build/go-semantic-release.exe - name: ./build/go-semantic-release.windows_i386.exe
compress: false compress: true
- name: ./build/go-semantic-release.windows_x86_64.exe
compress: true
- name: ./build/go-semantic-release.darwin_x86_64
compress: true
changelog:
docker:
latest: true
repository: "nightapes/go-semantic-release"
hooks:
preRelease:
- docker build -t nightapes/go-semantic-release:latest .
- docker tag nightapes/go-semantic-release:latest docker.pkg.github.com/nightapes/go-semantic-release/go-semantic-release:$RELEASE_VERSION
- docker tag nightapes/go-semantic-release:latest nightapes/go-semantic-release:$RELEASE_VERSION
postRelease:
- docker push nightapes/go-semantic-release:latest
- docker push nightapes/go-semantic-release:$RELEASE_VERSION
- docker push docker.pkg.github.com/nightapes/go-semantic-release/go-semantic-release:$RELEASE_VERSION

9
Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM alpine:3.10.2
WORKDIR /code
COPY ./build/go-semantic-release.linux_x86_64 .
USER 1000
ENTRYPOINT [ "./go-semantic-release.linux_x86_64" ]

View File

@@ -1,13 +1,15 @@
# go-semantic-release # go-semantic-release
![go-semantic-release](https://github.com/Nightapes/go-semantic-release/workflows/Go/badge.svg)
## Release Types ## Release Types
| Type | Implemendet | Git tag | Changelog | Release | Write access git | Api token | | Type | Implemendet | Git tag | Changelog | Release | Write access git | Api token |
| ---------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | | ----------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: |
| `github` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | `github` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: |
| `gitlab` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | `gitlab` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: |
| `git` | Comming soon | :white_check_mark: | | | :white_check_mark: | | | `git` | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | |
| `bitbuckt` | Comming soon | :white_check_mark: | | | :white_check_mark: | | | `bitbucket` | Comming soon | :white_check_mark: | | | :white_check_mark: | |
## Supported CI Pipelines ## Supported CI Pipelines
@@ -17,6 +19,18 @@
* Travis CI * Travis CI
* Custom CI, set enviroment `CI=true` * Custom CI, set enviroment `CI=true`
## Download
You can download the newest version under [releases](https://github.com/Nightapes/go-semantic-release/releases)
or
you can use a Docker image
`docker pull nightapes/go-semantic-release:<VERSION>` or `docker pull docker.pkg.github.com/nightapes/go-semantic-release/go-semantic-release:<VERSION>`
## How to use ## How to use
`go-semantic-release` config file `go-semantic-release` config file
@@ -37,6 +51,11 @@ assets:
compress: false compress: false
- name: ./build/go-semantic-release.exe - name: ./build/go-semantic-release.exe
compress: false compress: false
hooks:
preRelease:
- name: echo $RELEASE_VERSION
postRelease:
- name: echo $RELEASE_VERSION
``` ```
#### CommitFormat #### CommitFormat
@@ -65,7 +84,7 @@ branch:
<branch-name>: <kind> <branch-name>: <kind>
``` ```
#### Relase #### Release
At the moment we support releases to gitlab and github. At the moment we support releases to gitlab and github.
@@ -95,6 +114,20 @@ gitlab:
customUrl: <https://your.gitlab> customUrl: <https://your.gitlab>
``` ```
##### Git only
Only via https at the moment. You need write access to your git repository
```yml
release: 'git'
git:
email: "<email>" # Used for creating tag
user: "<user>" : # Used for creating tag and pushing
auth: "<token>" # Used for pushing, can be env "$GIT_TOKEN", will be replaced with env
```
#### Assets #### Assets
You can upload assets to a release You can upload assets to a release
@@ -108,11 +141,26 @@ assets:
compress: false compress: false
``` ```
#### Hooks
Hooks will run when calling `release`. Hooks run only if a release will be triggered.
#### Changelog #### Changelog
Following variables can be used for templates:
* `Commits` string
* `Version` string
* `Now` time.Time
* `Backtick` string
* `HasDocker` bool
* `HasDockerLatest` bool
* `DockerRepository` string
```yml ```yml
changelog: changelog:
printAll: false ## Print all valid commits to changelog printAll: false ## Print all valid commits to changelog
title: "v{{.Version}} ({{.Now.Format "2006-01-02"}})" ## Used for releases (go template)
templatePath: "./examples/changelog.tmpl" ## Path to a template file (go template)
``` ```
##### Docker ##### Docker
@@ -148,7 +196,8 @@ following command:
Print the next version, can be used to add version to your program Print the next version, can be used to add version to your program
```bash ```bash
./go-semantic-release next ./go-semantic-release next // show next version (calculated by new commits since last version)
./go-semantic-release last // show last released version
``` ```
Example with go-lang Example with go-lang

3
_config.yml Normal file
View File

@@ -0,0 +1,3 @@
theme: jekyll-theme-cayman
plugins:
- jemoji

View File

@@ -35,7 +35,12 @@ var changelogCmd = &cobra.Command{
return err return err
} }
s, err := semanticrelease.New(readConfig(config), repository) ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
if err != nil {
return err
}
s, err := semanticrelease.New(readConfig(config), repository, !ignoreConfigChecks)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -0,0 +1,64 @@
package commands
import (
"github.com/Nightapes/go-semantic-release/internal/hooks"
"github.com/Nightapes/go-semantic-release/pkg/semanticrelease"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(hooksCmd)
}
var hooksCmd = &cobra.Command{
Use: "hooks",
Short: "Run all hooks",
RunE: func(cmd *cobra.Command, args []string) error {
config, err := cmd.Flags().GetString("config")
if err != nil {
return err
}
repository, err := cmd.Flags().GetString("repository")
if err != nil {
return err
}
force, err := cmd.Flags().GetBool("no-cache")
if err != nil {
return err
}
ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
if err != nil {
return err
}
releaseConfig := readConfig(config)
s, err := semanticrelease.New(releaseConfig, repository, !ignoreConfigChecks)
if err != nil {
return err
}
provider, err := s.GetCIProvider()
if err != nil {
return err
}
releaseVersion, err := s.GetNextVersion(provider, force)
if err != nil {
return err
}
hook := hooks.New(releaseConfig, releaseVersion)
err = hook.PreRelease()
if err != nil {
return err
}
return hook.PostRelease()
},
}

View File

@@ -0,0 +1,58 @@
package commands
import (
"fmt"
"github.com/Nightapes/go-semantic-release/pkg/semanticrelease"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(lastCmd)
}
var lastCmd = &cobra.Command{
Use: "last",
Short: "Get last version",
RunE: func(cmd *cobra.Command, args []string) error {
config, err := cmd.Flags().GetString("config")
if err != nil {
return err
}
repository, err := cmd.Flags().GetString("repository")
if err != nil {
return err
}
force, err := cmd.Flags().GetBool("no-cache")
if err != nil {
return err
}
ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
if err != nil {
return err
}
s, err := semanticrelease.New(readConfig(config), repository, !ignoreConfigChecks)
if err != nil {
return err
}
provider, err := s.GetCIProvider()
if err != nil {
log.Infof("Will not calculate version, set fake version. Could not find CI Provider, if running locally, set env CI=true")
fmt.Println("0.0.0-fake.0")
return nil
}
releaseVersion, err := s.GetNextVersion(provider, force)
if err != nil {
return err
}
fmt.Println(releaseVersion.Last.Version.String())
return nil
},
}

View File

@@ -30,7 +30,12 @@ var nextCmd = &cobra.Command{
return err return err
} }
s, err := semanticrelease.New(readConfig(config), repository) ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
if err != nil {
return err
}
s, err := semanticrelease.New(readConfig(config), repository, !ignoreConfigChecks)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -28,7 +28,12 @@ var releaseCmd = &cobra.Command{
return err return err
} }
s, err := semanticrelease.New(readConfig(config), repository) ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
if err != nil {
return err
}
s, err := semanticrelease.New(readConfig(config), repository, !ignoreConfigChecks)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -35,6 +35,7 @@ func init() {
rootCmd.PersistentFlags().StringP("loglevel", "l", "error", "Set loglevel") rootCmd.PersistentFlags().StringP("loglevel", "l", "error", "Set loglevel")
rootCmd.PersistentFlags().StringP("config", "c", ".release.yml", "Path to config file") rootCmd.PersistentFlags().StringP("config", "c", ".release.yml", "Path to config file")
rootCmd.PersistentFlags().Bool("no-cache", false, "Ignore cache, don't use in ci build") rootCmd.PersistentFlags().Bool("no-cache", false, "Ignore cache, don't use in ci build")
rootCmd.PersistentFlags().Bool("no-checks", false, "Ignore missing values and envs")
} }
func readConfig(file string) *config.ReleaseConfig { func readConfig(file string) *config.ReleaseConfig {

View File

@@ -26,7 +26,12 @@ var setCmd = &cobra.Command{
return err return err
} }
s, err := semanticrelease.New(readConfig(config), repository) ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
if err != nil {
return err
}
s, err := semanticrelease.New(readConfig(config), repository, !ignoreConfigChecks)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -6,6 +6,7 @@ import (
) )
func init() { func init() {
zipCmd.Flags().StringP("algorithm", "a", "sha256", "Algorithm for checksum (crc32,md5,sha1,sha224,sha384,sha256,sha512)")
rootCmd.AddCommand(zipCmd) rootCmd.AddCommand(zipCmd)
} }
@@ -23,7 +24,12 @@ var zipCmd = &cobra.Command{
return err return err
} }
s, err := semanticrelease.New(readConfig(config), repository) ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
if err != nil {
return err
}
s, err := semanticrelease.New(readConfig(config), repository, !ignoreConfigChecks)
if err != nil { if err != nil {
return err return err
} }

16
examples/changelog.tmpl Normal file
View File

@@ -0,0 +1,16 @@
# My custom release template v{{$.Version}} ({{.Now.Format "2006-01-02"}})
{{ .Commits -}}
{{ if .HasDocker}}
## Docker image
New docker image is released under {{$.Backtick}}{{.DockerRepository}}:{{.Version}}{{$.Backtick}}
### Usage
{{$.Backtick}}docker run {{.DockerRepository}}:{{.Version}}{{$.Backtick}}
{{ if .HasDockerLatest}}
or
{{$.Backtick}}docker run {{.DockerRepository}}:latest{{$.Backtick}}
{{ end -}}
{{ end -}}

30
go.mod
View File

@@ -3,20 +3,22 @@ module github.com/Nightapes/go-semantic-release
go 1.13 go 1.13
require ( require (
github.com/Masterminds/semver v1.4.2 github.com/Masterminds/semver v1.5.0
github.com/gliderlabs/ssh v0.2.2 // indirect github.com/golang/protobuf v1.3.4 // indirect
github.com/google/go-cmp v0.3.0 // indirect
github.com/google/go-github/v25 v25.1.3 github.com/google/go-github/v25 v25.1.3
github.com/kevinburke/ssh_config v0.0.0-20190630040420-2e50c441276c // indirect github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/pkg/errors v0.9.1
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sirupsen/logrus v1.4.2 github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v0.0.5 github.com/spf13/cobra v0.0.6
github.com/stretchr/testify v1.3.0 github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect github.com/stretchr/testify v1.4.0
golang.org/x/net v0.0.0-20190628185345-da137c7871d7 // indirect golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b // indirect
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb // indirect golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
google.golang.org/appengine v1.6.1 // indirect golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae // indirect
gopkg.in/src-d/go-billy.v4 v4.3.1 google.golang.org/appengine v1.6.5 // indirect
gopkg.in/src-d/go-git.v4 v4.12.0 gopkg.in/src-d/go-billy.v4 v4.3.2
gopkg.in/yaml.v2 v2.2.2 gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v2 v2.2.8
) )

191
go.sum
View File

@@ -1,35 +1,57 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gliderlabs/ssh v0.1.3/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
@@ -37,120 +59,169 @@ github.com/google/go-github/v25 v25.1.3 h1:Ht4YIQgUh4l4lc80fvGnw60khXysXvlgPxPP8
github.com/google/go-github/v25 v25.1.3/go.mod h1:6z5pC69qHtrPJ0sXPsj4BLnd82b+r6sLB7qcBoRZqpw= github.com/google/go-github/v25 v25.1.3/go.mod h1:6z5pC69qHtrPJ0sXPsj4BLnd82b+r6sLB7qcBoRZqpw=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e h1:RgQk53JHp/Cjunrr1WlsXSZpqXn+uREuHvUVcK82CV8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kevinburke/ssh_config v0.0.0-20190630040420-2e50c441276c h1:VAx3LRNjVNvjtgO7KFRuT/3aye/0zJvwn01rHSfoolo= github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
github.com/kevinburke/ssh_config v0.0.0-20190630040420-2e50c441276c/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/pelletier/go-buffruneio v0.2.0 h1:U4t4R6YkofJ5xHm3dJzuRpPZ0mr5MMCoAWooScCR7aA= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= github.com/spf13/cobra v0.0.6 h1:breEStsVwemnKh2/s6gMvSdMEkwW0sK8vGStnlVBMCs=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4= github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI= github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190502183928-7f726cade0ab/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8j4DQRpdYMnGn/bJUEU= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9 h1:lkiLiLBHGoH3XnqSLUIaBsilGMUjI+Uy2Xu2JLUtTas= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb h1:fgwFCsaw9buMuxNd6+DQfAuSFqbNiQZpcgJQAgJsK6k= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I= google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/src-d/go-billy.v4 v4.3.1 h1:OkK1DmefDy1Z6Veu82wdNj/cLpYORhdX4qdaYCPwc7s= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/src-d/go-billy.v4 v4.3.1/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg= gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g= gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
gopkg.in/src-d/go-git.v4 v4.12.0 h1:CKgvBCJCcdfNnyXPYI4Cp8PaDDAmAPEN0CtfEdEAbd8= gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
gopkg.in/src-d/go-git.v4 v4.12.0/go.mod h1:zjlNnzc1Wjn43v3Mtii7RVxiReNP0fIu9npcXKzuNp4= gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

179
internal/assets/asset.go Normal file
View File

@@ -0,0 +1,179 @@
package assets
import (
"archive/zip"
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"fmt"
"hash"
"hash/crc32"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"github.com/Nightapes/go-semantic-release/pkg/config"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
// Asset struct
type Asset struct {
name string
path string
zippedPath string
algorithm string
isCompressed bool
}
//NewAsset from a config
func NewAsset(repository string, assetConfig config.Asset, algorithm string) (*Asset, error) {
filePath := assetConfig.Path
if assetConfig.Name != "" && assetConfig.Path == "" {
filePath = assetConfig.Name
log.Warn("Name is deprecated. Please update your config. See https://nightapes.github.io/go-semantic-release/")
}
realPath := path.Join(repository, filePath)
file, err := os.Open(realPath)
if err != nil {
file.Close()
return nil, errors.Wrapf(err, "Could not open file %s", realPath)
}
defer file.Close()
name := assetConfig.Rename
if assetConfig.Rename == "" {
info, _ := file.Stat()
name = info.Name()
}
asset := &Asset{
path: realPath,
name: name,
isCompressed: assetConfig.Compress,
algorithm: algorithm,
}
return asset, nil
}
func (a *Asset) getChecksum() (string, error) {
path, err := a.GetPath()
if err != nil {
return "", nil
}
log.Debugf("Calculating checksum for %s", path)
file, err := os.Open(path)
if err != nil {
return "", errors.Wrapf(err, "Failed to open file %s to calculate checksum", a.name)
}
defer file.Close() // nolint: errcheck
var hash hash.Hash
switch a.algorithm {
case "crc32":
hash = crc32.NewIEEE()
case "md5":
hash = md5.New()
case "sha1":
hash = sha1.New()
case "sha224":
hash = sha256.New224()
case "sha384":
hash = sha512.New384()
case "sha256":
hash = sha256.New()
case "sha512":
hash = sha512.New()
default:
hash = sha256.New()
}
_, err = io.Copy(hash, file)
if err != nil {
return "", err
}
return hex.EncodeToString(hash.Sum(nil)), nil
}
// GetPath where the file is located, if zipped true, it will compress it and give you the new location
func (a *Asset) GetPath() (string, error) {
if a.isCompressed {
return a.ZipFile()
}
return a.path, nil
}
// GetName of asset
func (a *Asset) GetName() string {
if a.isCompressed {
return fmt.Sprintf("%s.zip", a.name)
}
return a.name
}
// IsCompressed return true if file was zipped
func (a *Asset) IsCompressed() bool {
return a.isCompressed
}
// ZipFile compress given file in zip format
func (a *Asset) ZipFile() (string, error) {
if a.zippedPath != "" {
return a.zippedPath, nil
}
path := a.path
fileToZip, err := os.Open(path)
if err != nil {
return "", errors.Wrapf(err, "Could not open file %s", path)
}
defer fileToZip.Close()
zipFile, err := ioutil.TempFile(os.TempDir(), "asset.*.zip")
if err != nil {
return "", errors.Wrap(err, "Could not generate tmp file")
}
log.Debugf("Created zipfile %s", zipFile.Name())
fileToZipInfo, err := fileToZip.Stat()
if err != nil {
return "", errors.Wrap(err, "Could not read file infos")
}
zipWriter := zip.NewWriter(zipFile)
fileToZipHeader, err := zip.FileInfoHeader(fileToZipInfo)
if err != nil {
return "", errors.Wrap(err, "Could not add file infos to zip handler")
}
fileToZipHeader.Name = fileToZipInfo.Name()
fileToZipWriter, err := zipWriter.CreateHeader(fileToZipHeader)
if err != nil {
return "", errors.Wrap(err, "Could not create zip header")
}
if _, err = io.Copy(fileToZipWriter, fileToZip); err != nil {
return "", errors.Wrap(err, "Could not zip file")
}
if err := zipWriter.Close(); err != nil {
return "", errors.Wrap(err, fmt.Sprintf("Could not close zipwriter for zip %s", a.path))
}
if err := zipFile.Close(); err != nil {
return "", errors.Wrap(err, "Could not close file")
}
a.zippedPath, err = filepath.Abs(zipFile.Name())
return a.zippedPath, err
}

79
internal/assets/assets.go Normal file
View File

@@ -0,0 +1,79 @@
package assets
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/Nightapes/go-semantic-release/pkg/config"
"github.com/pkg/errors"
)
// Set struct
type Set struct {
assets []*Asset
repository string
algorithm string
}
//New container for assets
func New(repository, algorithm string) *Set {
return &Set{
assets: []*Asset{},
repository: repository,
algorithm: algorithm,
}
}
// Add assets to the list
func (s *Set) Add(assetConfigs ...config.Asset) error {
for _, assetConfig := range assetConfigs {
asset, err := NewAsset(s.repository, assetConfig, s.algorithm)
if err != nil {
return err
}
s.assets = append(s.assets, asset)
}
return nil
}
func (s *Set) All() []*Asset {
return s.assets
}
func (s *Set) GenerateChecksum() error {
checksumFile, err := ioutil.TempFile(os.TempDir(), "checksum.*.txt")
if err != nil {
return errors.Wrap(err, "Could not generate tmp file for checksum")
}
defer checksumFile.Close()
lines := []string{}
for _, asset := range s.assets {
checksum, err := asset.getChecksum()
if err != nil {
return err
}
lines = append(lines, fmt.Sprintf("%s %s", checksum, asset.GetName()))
}
w := bufio.NewWriter(checksumFile)
for _, line := range lines {
fmt.Fprintln(w, line)
}
filePath, err := filepath.Abs(checksumFile.Name())
if err != nil {
return err
}
s.assets = append(s.assets, &Asset{
path: filePath,
name: "checksum.txt",
isCompressed: false,
algorithm: "",
})
return w.Flush()
}

View File

@@ -63,7 +63,7 @@ func TestWriteAndReadCache(t *testing.T) {
Author: "Author", Author: "Author",
Hash: "Hash", Hash: "Hash",
}, },
ParsedMessage: "add gitlab as relase option", ParsedMessage: "add gitlab as release option",
Scope: "releaser", Scope: "releaser",
ParsedBreakingChangeMessage: "", ParsedBreakingChangeMessage: "",
Tag: "feat", Tag: "feat",

View File

@@ -19,9 +19,9 @@ func New() *Calculator {
} }
//IncPrerelease increase prerelease by one //IncPrerelease increase prerelease by one
func (c *Calculator) IncPrerelease(preReleaseType string, version *semver.Version) (semver.Version, error) { func (c *Calculator) IncPrerelease(preReleaseType string, version semver.Version) (semver.Version, error) {
defaultPrerelease := preReleaseType + ".0" defaultPrerelease := preReleaseType + ".0"
if version.Prerelease() == "" || !strings.HasPrefix(version.Prerelease(), preReleaseType) { if !c.hasPrerelease(version, preReleaseType) {
return version.SetPrerelease(defaultPrerelease) return version.SetPrerelease(defaultPrerelease)
} }
@@ -32,19 +32,31 @@ func (c *Calculator) IncPrerelease(preReleaseType string, version *semver.Versio
log.Warnf("Could not parse release tag %s, use version %s", version.Prerelease(), version.String()) log.Warnf("Could not parse release tag %s, use version %s", version.Prerelease(), version.String())
return version.SetPrerelease(defaultPrerelease) return version.SetPrerelease(defaultPrerelease)
} }
return version.SetPrerelease(preReleaseType + "." + strconv.Itoa((i + 1))) return version.SetPrerelease(preReleaseType + "." + strconv.Itoa(i+1))
} }
log.Warnf("Could not parse release tag %s, use version %s", version.Prerelease(), version.String()) log.Warnf("Could not parse release tag %s, use version %s", version.Prerelease(), version.String())
return version.SetPrerelease(defaultPrerelease) return version.SetPrerelease(defaultPrerelease)
} }
func (c *Calculator) hasPrerelease(version semver.Version, preReleaseType string) bool {
if version.Prerelease() == "" || !strings.HasPrefix(version.Prerelease(), preReleaseType) {
return false
}
return true
}
//CalculateNewVersion from given commits and lastversion //CalculateNewVersion from given commits and lastversion
func (c *Calculator) CalculateNewVersion(commits map[shared.Release][]shared.AnalyzedCommit, lastVersion *semver.Version, releaseType string, firstRelease bool) semver.Version { func (c *Calculator) CalculateNewVersion(commits map[shared.Release][]shared.AnalyzedCommit, lastVersion *semver.Version, releaseType string, firstRelease bool) semver.Version {
switch releaseType { switch releaseType {
case "beta", "alpha", "rc": case "beta", "alpha", "rc":
var version = *lastVersion
if !c.hasPrerelease(*lastVersion, releaseType) {
version, _ = c.inc(commits, lastVersion)
}
if len(commits["major"]) > 0 || len(commits["minor"]) > 0 || len(commits["patch"]) > 0 { if len(commits["major"]) > 0 || len(commits["minor"]) > 0 || len(commits["patch"]) > 0 {
version, _ := c.IncPrerelease(releaseType, lastVersion) version, _ := c.IncPrerelease(releaseType, version)
return version return version
} }
case "release": case "release":
@@ -53,16 +65,23 @@ func (c *Calculator) CalculateNewVersion(commits map[shared.Release][]shared.Ana
newVersion, _ := lastVersion.SetPrerelease("") newVersion, _ := lastVersion.SetPrerelease("")
return newVersion return newVersion
} }
version, done := c.inc(commits, lastVersion)
if len(commits["major"]) > 0 { if done {
return lastVersion.IncMajor() return version
} else if len(commits["minor"]) > 0 {
return lastVersion.IncMinor()
} else if len(commits["patch"]) > 0 {
return lastVersion.IncPatch()
} }
} }
} }
return *lastVersion return *lastVersion
} }
func (c *Calculator) inc(commits map[shared.Release][]shared.AnalyzedCommit, lastVersion *semver.Version) (semver.Version, bool) {
if len(commits["major"]) > 0 {
return lastVersion.IncMajor(), true
} else if len(commits["minor"]) > 0 {
return lastVersion.IncMinor(), true
} else if len(commits["patch"]) > 0 {
return lastVersion.IncPatch(), true
}
return semver.Version{}, false
}

View File

@@ -58,9 +58,11 @@ func TestCalculator_IncPrerelease(t *testing.T) {
c := calculator.New() c := calculator.New()
for _, test := range testConfigs { for _, test := range testConfigs {
next, err := c.IncPrerelease(test.preReleaseType, test.lastVersion) t.Run(test.testCase, func(t *testing.T) {
next, err := c.IncPrerelease(test.preReleaseType, *test.lastVersion)
assert.Equalf(t, test.hasError, err != nil, "Testcase %s should have error: %t -> %s", test.testCase, test.hasError, err) assert.Equalf(t, test.hasError, err != nil, "Testcase %s should have error: %t -> %s", test.testCase, test.hasError, err)
assert.Equal(t, test.nextVersion, next.String()) assert.Equal(t, test.nextVersion, next.String())
})
} }
} }
@@ -79,7 +81,7 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
testCase: "version with preRelease alpha", testCase: "version with preRelease alpha",
releaseType: "alpha", releaseType: "alpha",
lastVersion: createVersion("1.0.0"), lastVersion: createVersion("1.0.0"),
nextVersion: "1.0.0-alpha.0", nextVersion: "1.1.0-alpha.0",
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{ analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
"major": []shared.AnalyzedCommit{}, "major": []shared.AnalyzedCommit{},
"minor": []shared.AnalyzedCommit{ "minor": []shared.AnalyzedCommit{
@@ -94,7 +96,7 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
testCase: "version with preRelease beta", testCase: "version with preRelease beta",
releaseType: "beta", releaseType: "beta",
lastVersion: createVersion("1.0.0"), lastVersion: createVersion("1.0.0"),
nextVersion: "1.0.0-beta.0", nextVersion: "1.1.0-beta.0",
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{ analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
"major": []shared.AnalyzedCommit{}, "major": []shared.AnalyzedCommit{},
"minor": []shared.AnalyzedCommit{ "minor": []shared.AnalyzedCommit{
@@ -135,7 +137,7 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
testCase: "version with commits and rc release", testCase: "version with commits and rc release",
releaseType: "rc", releaseType: "rc",
lastVersion: createVersion("1.0.0"), lastVersion: createVersion("1.0.0"),
nextVersion: "1.0.0-rc.0", nextVersion: "2.0.0-rc.0",
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{ analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
"major": []shared.AnalyzedCommit{shared.AnalyzedCommit{}}, "major": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
"minor": []shared.AnalyzedCommit{shared.AnalyzedCommit{}}, "minor": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
@@ -201,8 +203,10 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
c := calculator.New() c := calculator.New()
for _, test := range testConfigs { for _, test := range testConfigs {
t.Run(test.testCase, func(t *testing.T) {
next := c.CalculateNewVersion(test.analyzedCommits, test.lastVersion, test.releaseType, test.isFirst) next := c.CalculateNewVersion(test.analyzedCommits, test.lastVersion, test.releaseType, test.isFirst)
assert.Equalf(t, test.nextVersion, next.String(), "Should have version %s for testcase %s", test.nextVersion, test.testCase) assert.Equalf(t, test.nextVersion, next.String(), "Should have version %s for testcase %s", test.nextVersion, test.testCase)
})
} }
} }

View File

@@ -2,6 +2,7 @@ package changelog
import ( import (
"bytes" "bytes"
"io/ioutil"
"strings" "strings"
"text/template" "text/template"
"time" "time"
@@ -13,24 +14,26 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
const defaultChangelogTitle string = `v{{.Version}} ({{.Now.Format "2006-01-02"}})` const defaultCommitList string = `{{ range $index,$commit := .BreakingChanges -}}
const defaultChangelog string = `# v{{$.Version}} ({{.Now.Format "2006-01-02"}}) {{ if eq $index 0 -}}
{{ range $index,$commit := .BreakingChanges -}}
{{ if eq $index 0 }}
## BREAKING CHANGES ## BREAKING CHANGES
{{ end}}
* **{{$.Backtick}}{{$commit.Scope}}{{$.Backtick}}** {{$commit.ParsedBreakingChangeMessage}}
introduced by commit:
{{$commit.ParsedMessage}} {{if $.HasURL}} ([{{ printf "%.7s" $commit.Commit.Hash}}]({{ replace $.URL "{{hash}}" $commit.Commit.Hash}})) {{end}}
{{ end -}} {{ end -}}
{{ range $key := .Order }} * {{ if $commit.Scope }}**{{$.Backtick}}{{$commit.Scope}}{{$.Backtick}}**{{ end }} {{$commit.ParsedBreakingChangeMessage}}
{{ $commits := index $.Commits $key}} {{if $commits -}} introduced by commit:
{{$commit.ParsedMessage}} {{if $.HasURL}} ([{{ printf "%.7s" $commit.Commit.Hash}}]({{ replace $.URL "{{hash}}" $commit.Commit.Hash}})){{end}}
{{ end -}}
{{ range $key := .Order -}}
{{ $commits := index $.Commits $key -}}
{{ if $commits -}}
### {{ $key }} ### {{ $key }}
{{ range $index,$commit := $commits -}} {{ range $index,$commit := $commits -}}
* **{{$.Backtick}}{{$commit.Scope}}{{$.Backtick}}** {{$commit.ParsedMessage}} {{if $.HasURL}} ([{{ printf "%.7s" $commit.Commit.Hash}}]({{ replace $.URL "{{hash}}" $commit.Commit.Hash}})) {{end}} * {{ if $commit.Scope }}**{{$.Backtick}}{{$commit.Scope}}{{$.Backtick}}** {{end}}{{$commit.ParsedMessage}}{{if $.HasURL}} ([{{ printf "%.7s" $commit.Commit.Hash}}]({{ replace $.URL "{{hash}}" $commit.Commit.Hash}})){{end}}
{{ end -}}
{{ end -}} {{ end -}}
{{ end -}} {{ end -}}
{{ end -}}`
const defaultChangelogTitle string = `v{{.Version}} ({{.Now.Format "2006-01-02"}})`
const defaultChangelog string = `# v{{$.Version}} ({{.Now.Format "2006-01-02"}})
{{ .Commits -}}
{{ if .HasDocker}} {{ if .HasDocker}}
## Docker image ## Docker image
@@ -48,6 +51,16 @@ or
` `
type changelogContent struct { type changelogContent struct {
Commits string
Version string
Now time.Time
Backtick string
HasDocker bool
HasDockerLatest bool
DockerRepository string
}
type commitsContent struct {
Commits map[string][]shared.AnalyzedCommit Commits map[string][]shared.AnalyzedCommit
BreakingChanges []shared.AnalyzedCommit BreakingChanges []shared.AnalyzedCommit
Order []string Order []string
@@ -56,9 +69,6 @@ type changelogContent struct {
Backtick string Backtick string
HasURL bool HasURL bool
URL string URL string
HasDocker bool
HasDockerLatest bool
DockerRepository string
} }
//Changelog struct //Changelog struct
@@ -108,7 +118,7 @@ func (c *Changelog) GenerateChanglog(templateConfig shared.ChangelogTemplateConf
} }
} }
changelogContent := changelogContent{ commitsContent := commitsContent{
Version: templateConfig.Version, Version: templateConfig.Version,
Commits: commitsPerScope, Commits: commitsPerScope,
Now: c.releaseTime, Now: c.releaseTime,
@@ -117,21 +127,52 @@ func (c *Changelog) GenerateChanglog(templateConfig shared.ChangelogTemplateConf
Order: order, Order: order,
HasURL: templateConfig.CommitURL != "", HasURL: templateConfig.CommitURL != "",
URL: templateConfig.CommitURL, URL: templateConfig.CommitURL,
}
changelogContent := changelogContent{
Version: templateConfig.Version,
Now: c.releaseTime,
Backtick: "`",
HasDocker: c.config.Changelog.Docker.Repository != "", HasDocker: c.config.Changelog.Docker.Repository != "",
HasDockerLatest: c.config.Changelog.Docker.Latest, HasDockerLatest: c.config.Changelog.Docker.Latest,
DockerRepository: c.config.Changelog.Docker.Repository, DockerRepository: c.config.Changelog.Docker.Repository,
} }
template := defaultChangelog
title, err := generateTemplate(defaultChangelogTitle, changelogContent) if c.config.Changelog.TemplatePath != "" {
content, err := ioutil.ReadFile(c.config.Changelog.TemplatePath)
if err != nil { if err != nil {
return nil, err return nil, err
} }
content, err := generateTemplate(defaultChangelog, changelogContent) template = string(content)
}
return &shared.GeneratedChangelog{Title: title, Content: content}, err templateTitle := defaultChangelogTitle
if c.config.Changelog.TemplateTitle != "" {
templateTitle = c.config.Changelog.TemplateTitle
}
log.Debugf("Render title")
renderedTitle, err := generateTemplate(templateTitle, changelogContent)
if err != nil {
return nil, err
}
log.Debugf("Render commits")
renderedCommitList, err := generateTemplate(defaultCommitList, commitsContent)
if err != nil {
return nil, err
}
log.Tracef("Commits %s", renderedCommitList)
changelogContent.Commits = renderedCommitList
log.Debugf("Render changelog")
renderedContent, err := generateTemplate(template, changelogContent)
return &shared.GeneratedChangelog{Title: renderedTitle, Content: renderedContent}, err
} }
func generateTemplate(text string, values changelogContent) (string, error) { func generateTemplate(text string, values interface{}) (string, error) {
funcMap := template.FuncMap{ funcMap := template.FuncMap{
"replace": replace, "replace": replace,

View File

@@ -32,7 +32,7 @@ func TestChangelog(t *testing.T) {
"minor": []shared.AnalyzedCommit{ "minor": []shared.AnalyzedCommit{
shared.AnalyzedCommit{ shared.AnalyzedCommit{
Commit: shared.Commit{ Commit: shared.Commit{
Message: "feat(test): my first commit", Message: "feat(internal/changelog): my first commit",
Author: "me", Author: "me",
Hash: "12345667", Hash: "12345667",
}, },
@@ -46,7 +46,30 @@ func TestChangelog(t *testing.T) {
}, },
result: &shared.GeneratedChangelog{ result: &shared.GeneratedChangelog{
Title: "v1.0.0 (2019-07-19)", Title: "v1.0.0 (2019-07-19)",
Content: "# v1.0.0 (2019-07-19)\n\n ### Features\n* **`internal/changelog`** my first commit ([1234566](https://commit.url)) \n\n ", Content: "# v1.0.0 (2019-07-19)\n### Features\n* **`internal/changelog`** my first commit ([1234566](https://commit.url))\n",
},
hasError: false,
},
{
testCase: "feat no scope",
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
"minor": []shared.AnalyzedCommit{
shared.AnalyzedCommit{
Commit: shared.Commit{
Message: "feat: my first commit",
Author: "me",
Hash: "12345667",
},
ParsedMessage: "my first commit",
Tag: "feat",
TagString: "Features",
Print: true,
},
},
},
result: &shared.GeneratedChangelog{
Title: "v1.0.0 (2019-07-19)",
Content: "# v1.0.0 (2019-07-19)\n### Features\n* my first commit ([1234566](https://commit.url))\n",
}, },
hasError: false, hasError: false,
}, },
@@ -56,7 +79,7 @@ func TestChangelog(t *testing.T) {
"minor": []shared.AnalyzedCommit{ "minor": []shared.AnalyzedCommit{
shared.AnalyzedCommit{ shared.AnalyzedCommit{
Commit: shared.Commit{ Commit: shared.Commit{
Message: "feat(test): my first commit", Message: "feat(internal/changelog): my first commit",
Author: "me", Author: "me",
Hash: "12345667", Hash: "12345667",
}, },
@@ -68,7 +91,7 @@ func TestChangelog(t *testing.T) {
}, },
shared.AnalyzedCommit{ shared.AnalyzedCommit{
Commit: shared.Commit{ Commit: shared.Commit{
Message: "feat(test): my first break: BREAKING CHANGE: change api to v2", Message: "feat(internal/changelog): my first break: BREAKING CHANGE: change api to v2",
Author: "me", Author: "me",
Hash: "12345668", Hash: "12345668",
}, },
@@ -83,7 +106,7 @@ func TestChangelog(t *testing.T) {
}, },
result: &shared.GeneratedChangelog{ result: &shared.GeneratedChangelog{
Title: "v1.0.0 (2019-07-19)", Title: "v1.0.0 (2019-07-19)",
Content: "# v1.0.0 (2019-07-19)\n\n## BREAKING CHANGES\n\n* **`internal/changelog`** change api to v2 \nintroduced by commit: \nmy first break ([1234566](https://commit.url)) \n\n ### Features\n* **`internal/changelog`** my first commit ([1234566](https://commit.url)) \n\n ", Content: "# v1.0.0 (2019-07-19)\n## BREAKING CHANGES\n* **`internal/changelog`** change api to v2 \nintroduced by commit: \nmy first break ([1234566](https://commit.url))\n### Features\n* **`internal/changelog`** my first commit ([1234566](https://commit.url))\n",
}, },
hasError: false, hasError: false,
}, },
@@ -111,9 +134,11 @@ func TestChangelog(t *testing.T) {
}, time.Date(2019, 7, 19, 0, 0, 0, 0, time.UTC)) }, time.Date(2019, 7, 19, 0, 0, 0, 0, time.UTC))
for _, config := range testConfigs { for _, config := range testConfigs {
t.Run(config.testCase, func(t *testing.T) {
generatedChangelog, err := cl.GenerateChanglog(templateConfig, config.analyzedCommits) generatedChangelog, err := cl.GenerateChanglog(templateConfig, config.analyzedCommits)
assert.Equalf(t, config.hasError, err != nil, "Testcase %s should have error: %t -> %s", config.testCase, config.hasError, err) assert.Equalf(t, config.hasError, err != nil, "Testcase %s should have error: %t -> %s", config.testCase, config.hasError, err)
assert.Equalf(t, config.result, generatedChangelog, "Testcase %s should have generated changelog", config.testCase) assert.Equalf(t, config.result, generatedChangelog, "Testcase %s should have generated changelog", config.testCase)
})
} }
} }

View File

@@ -39,13 +39,13 @@ func ReadAllEnvs() map[string]string {
} }
//GetCIProvider get provider //GetCIProvider get provider
func GetCIProvider(gitUtil *gitutil.GitUtil, envs map[string]string) (*ProviderConfig, error) { func GetCIProvider(gitUtil *gitutil.GitUtil, configCheck bool, envs map[string]string) (*ProviderConfig, error) {
services := []Service{ services := []Service{
Travis{}, Travis{},
GithubActions{}, GithubActions{},
GitlabCI{}, GitlabCI{},
Git{gitUtil: gitUtil}, // GIt must be the last option to check Git{gitUtil: gitUtil}, // Git must be the last option to check
} }
for _, service := range services { for _, service := range services {
@@ -57,5 +57,9 @@ func GetCIProvider(gitUtil *gitutil.GitUtil, envs map[string]string) (*ProviderC
} }
log.Debugf("%s", err.Error()) log.Debugf("%s", err.Error())
} }
if configCheck {
return nil, fmt.Errorf("could not find any CI, if running locally set env CI=true") return nil, fmt.Errorf("could not find any CI, if running locally set env CI=true")
}
return Git{gitUtil: gitUtil}.detect(map[string]string{"CI": "true"})
} }

View File

@@ -127,7 +127,7 @@ func TestCi(t *testing.T) {
} }
for _, config := range testConfigs { for _, config := range testConfigs {
provider, err := ci.GetCIProvider(gitUtilInMemory, config.envs) provider, err := ci.GetCIProvider(gitUtilInMemory, true, config.envs)
assert.Equalf(t, config.hasError, err != nil, "Service %s should have error: %t -> %s", config.service, config.hasError, err) assert.Equalf(t, config.hasError, err != nil, "Service %s should have error: %t -> %s", config.service, config.hasError, err)
assert.Equalf(t, config.result, provider, "Service %s should have provider", config.service) assert.Equalf(t, config.result, provider, "Service %s should have provider", config.service)
} }

View File

@@ -5,12 +5,15 @@ import (
"fmt" "fmt"
"sort" "sort"
"github.com/pkg/errors"
"github.com/Masterminds/semver" "github.com/Masterminds/semver"
"github.com/Nightapes/go-semantic-release/internal/shared" "github.com/Nightapes/go-semantic-release/internal/shared"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"gopkg.in/src-d/go-git.v4" "gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/object" "gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
) )
// GitUtil struct // GitUtil struct
@@ -87,7 +90,7 @@ func (g *GitUtil) GetLastVersion() (*semver.Version, string, error) {
err = gitTags.ForEach(func(p *plumbing.Reference) error { err = gitTags.ForEach(func(p *plumbing.Reference) error {
v, err := semver.NewVersion(p.Name().Short()) v, err := semver.NewVersion(p.Name().Short())
log.Tracef("Tag %+v with hash: %s", p.Target(), p.Hash()) log.Tracef("Tag %+v with hash: %s", p.Name().Short(), p.Hash())
if err == nil { if err == nil {
tags = append(tags, v) tags = append(tags, v)
@@ -139,7 +142,7 @@ func (g *GitUtil) GetCommits(lastTagHash string) ([]shared.Commit, error) {
if c.Hash.String() == lastTagHash { if c.Hash.String() == lastTagHash {
log.Debugf("Found commit with hash %s, will stop here", c.Hash.String()) log.Debugf("Found commit with hash %s, will stop here", c.Hash.String())
foundEnd = true foundEnd = true
return storer.ErrStop
} }
if !foundEnd { if !foundEnd {
log.Tracef("Found commit with hash %s", c.Hash.String()) log.Tracef("Found commit with hash %s", c.Hash.String())
@@ -153,5 +156,9 @@ func (g *GitUtil) GetCommits(lastTagHash string) ([]shared.Commit, error) {
return nil return nil
}) })
return commits, err if err != nil {
return commits, errors.Wrap(err, "Could not read commits, check git clone depth in your ci")
}
return commits, nil
} }

77
internal/hooks/hooks.go Normal file
View File

@@ -0,0 +1,77 @@
package hooks
import (
"bufio"
"os/exec"
"runtime"
"strings"
"github.com/Nightapes/go-semantic-release/internal/shared"
"github.com/Nightapes/go-semantic-release/pkg/config"
log "github.com/sirupsen/logrus"
)
//Hooks struct
type Hooks struct {
version *shared.ReleaseVersion
config *config.ReleaseConfig
}
// New hooks struct
func New(config *config.ReleaseConfig, version *shared.ReleaseVersion) *Hooks {
return &Hooks{
config: config,
version: version,
}
}
// PreRelease runs before creating release
func (h *Hooks) PreRelease() error {
log.Infof("Run pre release hooks")
for _, cmd := range h.config.Hooks.PreRelease {
log.Debugf("Run %s", cmd)
err := h.runCommand(cmd)
if err != nil {
return err
}
}
return nil
}
// PostRelease runs after creating release
func (h *Hooks) PostRelease() error {
log.Infof("Run post release hooks")
for _, cmd := range h.config.Hooks.PostRelease {
err := h.runCommand(cmd)
if err != nil {
return err
}
}
return nil
}
func (h *Hooks) runCommand(command string) error {
cmdReplaced := strings.ReplaceAll(command, "$RELEASE_VERSION", h.version.Next.Version.String())
var cmd *exec.Cmd
if runtime.GOOS == "windows" {
cmd = exec.Command("cmd.exe", "/C", cmdReplaced)
} else {
cmd = exec.Command("sh", "-c", cmdReplaced)
}
cmdReader, err := cmd.StdoutPipe()
if err != nil {
return err
}
scanner := bufio.NewScanner(cmdReader)
go func() {
for scanner.Scan() {
log.WithField("cmd", strings.Fields(cmdReplaced)[0]).Infof("%s\n", scanner.Text())
}
}()
return cmd.Run()
}

View File

@@ -0,0 +1,103 @@
package hooks_test
import (
"os"
"testing"
"github.com/Masterminds/semver"
"github.com/Nightapes/go-semantic-release/internal/hooks"
"github.com/Nightapes/go-semantic-release/internal/shared"
"github.com/Nightapes/go-semantic-release/pkg/config"
"github.com/stretchr/testify/assert"
)
func TestPreReleaseHooks(t *testing.T) {
os.Setenv("GO_WANT_HELPER_PROCESS", "1")
hooks := hooks.New(&config.ReleaseConfig{
Hooks: config.Hooks{
PreRelease: []string{
"go test -test.run=TestHelperProcess -- " + "$RELEASE_VERSION",
},
},
},
&shared.ReleaseVersion{
Next: shared.ReleaseVersionEntry{
Version: createVersion("1.0.0"),
},
})
err := hooks.PreRelease()
assert.NoError(t, err)
os.Unsetenv("GO_WANT_HELPER_PROCESS")
}
func TestPreReleaseHooksError(t *testing.T) {
hooks := hooks.New(&config.ReleaseConfig{
Hooks: config.Hooks{
PreRelease: []string{
"exit 1",
},
},
},
&shared.ReleaseVersion{
Next: shared.ReleaseVersionEntry{
Version: createVersion("1.0.0"),
},
})
err := hooks.PreRelease()
assert.Error(t, err)
}
func TestPostReleaseHooks(t *testing.T) {
os.Setenv("GO_WANT_HELPER_PROCESS", "1")
hooks := hooks.New(&config.ReleaseConfig{
Hooks: config.Hooks{
PostRelease: []string{
"go test -test.run=TestHelperProcess -- " + "$RELEASE_VERSION",
},
},
},
&shared.ReleaseVersion{
Next: shared.ReleaseVersionEntry{
Version: createVersion("1.0.0"),
},
})
err := hooks.PostRelease()
assert.NoError(t, err)
os.Unsetenv("GO_WANT_HELPER_PROCESS")
}
func TestPostReleaseHooksError(t *testing.T) {
hooks := hooks.New(&config.ReleaseConfig{
Hooks: config.Hooks{
PostRelease: []string{
"exit 1",
},
},
},
&shared.ReleaseVersion{
Next: shared.ReleaseVersionEntry{
Version: createVersion("1.0.0"),
},
})
err := hooks.PostRelease()
assert.Error(t, err)
}
func TestHelperProcess(t *testing.T) {
if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" {
return
}
assert.Contains(t, os.Args, "1.0.0")
}
func createVersion(version string) *semver.Version {
ver, _ := semver.NewVersion(version)
return ver
}

View File

@@ -0,0 +1,102 @@
package git
import (
"fmt"
"time"
"github.com/Nightapes/go-semantic-release/internal/assets"
"github.com/Nightapes/go-semantic-release/internal/gitutil"
"github.com/Nightapes/go-semantic-release/internal/shared"
"github.com/Nightapes/go-semantic-release/pkg/config"
"gopkg.in/src-d/go-git.v4"
gitConfig "gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/transport/http"
log "github.com/sirupsen/logrus"
)
// GITONLY identifer for git interface
const GITONLY = "git"
// Client type struct
type Client struct {
config *config.GitProvider
log *log.Entry
git *gitutil.GitUtil
}
// New initialize a new gitRelease
func New(config *config.GitProvider, git *gitutil.GitUtil, checkConfig bool) (*Client, error) {
logger := log.WithField("releaser", GITONLY)
if config.Email == "" && checkConfig {
return nil, fmt.Errorf("git email not set")
}
if config.Username == "" && checkConfig {
return nil, fmt.Errorf("git username not set")
}
if !config.SSH && config.Auth == "" && checkConfig {
return nil, fmt.Errorf("git auth not set")
}
if config.SSH {
return nil, fmt.Errorf("git ssh not supported yet")
}
return &Client{
config: config,
log: logger,
git: git,
}, nil
}
//GetCommitURL for git
func (g *Client) GetCommitURL() string {
return ""
}
//GetCompareURL for git
func (g *Client) GetCompareURL(oldVersion, newVersion string) string {
return ""
}
// CreateRelease creates release on remote
func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog, _ *assets.Set) error {
tag := "v" + releaseVersion.Next.Version.String()
g.log.Infof("create release with version %s", tag)
head, err := g.git.Repository.Head()
if err != nil {
return err
}
_, err = g.git.Repository.CreateTag(tag, head.Hash(), &git.CreateTagOptions{Message: "Release " + tag, Tagger: &object.Signature{
Name: g.config.Username,
Email: g.config.Email,
When: time.Now(),
}})
if err != nil {
return err
}
g.log.Infof("Created release")
return g.git.Repository.Push(&git.PushOptions{
Auth: &http.BasicAuth{
Username: g.config.Username,
Password: g.config.Auth,
},
RefSpecs: []gitConfig.RefSpec{"refs/tags/*:refs/tags/*"},
})
}
// UploadAssets uploads specified assets
func (g *Client) UploadAssets(repoDir string, assets []config.Asset) error {
return nil
}

View File

@@ -7,6 +7,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/Nightapes/go-semantic-release/internal/assets"
"github.com/Nightapes/go-semantic-release/internal/releaser/util" "github.com/Nightapes/go-semantic-release/internal/releaser/util"
"github.com/Nightapes/go-semantic-release/internal/shared" "github.com/Nightapes/go-semantic-release/internal/shared"
"github.com/Nightapes/go-semantic-release/pkg/config" "github.com/Nightapes/go-semantic-release/pkg/config"
@@ -29,17 +30,27 @@ type Client struct {
} }
// New initialize a new GitHubRelease // New initialize a new GitHubRelease
func New(c *config.GitHubProvider) (*Client, error) { func New(c *config.GitHubProvider, checkConfig bool) (*Client, error) {
var err error
if c.AccessToken, err = util.GetAccessToken("GITHUB_TOKEN"); err != nil { token, err := util.GetAccessToken("GITHUB_TOKEN")
if err != nil && checkConfig {
return &Client{}, err return &Client{}, err
} }
c.AccessToken = token
ctx := context.Background() ctx := context.Background()
httpClient := util.CreateBearerHTTPClient(ctx, c.AccessToken) httpClient := util.CreateBearerHTTPClient(ctx, c.AccessToken)
var client *github.Client var client *github.Client
baseURL := "https://github.com" baseURL := "https://github.com"
if c.Repo == "" && checkConfig {
return nil, fmt.Errorf("github repro is not set")
}
if c.User == "" && checkConfig {
return nil, fmt.Errorf("github user is not set")
}
if c.CustomURL == "" { if c.CustomURL == "" {
client = github.NewClient(httpClient) client = github.NewClient(httpClient)
} else { } else {
@@ -54,7 +65,7 @@ func New(c *config.GitHubProvider) (*Client, error) {
context: ctx, context: ctx,
baseURL: baseURL, baseURL: baseURL,
log: log.WithField("releaser", GITHUB), log: log.WithField("releaser", GITHUB),
}, err }, nil
} }
//GetCommitURL for github //GetCommitURL for github
@@ -67,26 +78,19 @@ func (g *Client) GetCompareURL(oldVersion, newVersion string) string {
return fmt.Sprintf("%s/%s/%s/compare/%s...%s", g.baseURL, g.config.User, g.config.Repo, oldVersion, newVersion) return fmt.Sprintf("%s/%s/%s/compare/%s...%s", g.baseURL, g.config.User, g.config.Repo, oldVersion, newVersion)
} }
//ValidateConfig for github // CreateRelease creates release on remote
func (g *Client) ValidateConfig() error { func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog, assets *assets.Set) error {
g.log.Debugf("validate GitHub provider config") err := g.makeRelease(releaseVersion, generatedChangelog)
if err != nil {
if g.config.Repo == "" { return err
return fmt.Errorf("github Repro is not set")
} }
return g.uploadAssets(assets)
if g.config.User == "" {
return fmt.Errorf("github User is not set")
}
return nil
} }
// CreateRelease creates release on remote // CreateRelease creates release on remote
func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog) error { func (g *Client) makeRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog) error {
tag := releaseVersion.Next.Version.String() tag := "v" + releaseVersion.Next.Version.String()
g.log.Debugf("create release with version %s", tag) g.log.Debugf("create release with version %s", tag)
prerelease := releaseVersion.Next.Version.Prerelease() != "" prerelease := releaseVersion.Next.Version.Prerelease() != ""
@@ -113,27 +117,25 @@ func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedC
} }
// UploadAssets uploads specified assets // UploadAssets uploads specified assets
func (g *Client) UploadAssets(repoDir string, assets []config.Asset) error { func (g *Client) uploadAssets(assets *assets.Set) error {
if g.release != nil { if g.release != nil {
filesToUpload, err := util.PrepareAssets(repoDir, assets) for _, asset := range assets.All() {
path, err := asset.GetPath()
if err != nil { if err != nil {
return err return err
} }
for _, f := range filesToUpload { file, err := os.Open(path)
file, err := os.Open(*f)
if err != nil { if err != nil {
return err return err
} }
fileInfo, _ := file.Stat()
_, resp, err := g.client.Repositories.UploadReleaseAsset(g.context, g.config.User, g.config.Repo, g.release.GetID(), &github.UploadOptions{Name: fileInfo.Name()}, file) _, resp, err := g.client.Repositories.UploadReleaseAsset(g.context, g.config.User, g.config.Repo, g.release.GetID(), &github.UploadOptions{Name: asset.GetName()}, file)
if err != nil { if err != nil {
return err return err
} }
if resp.StatusCode >= http.StatusBadRequest { if resp.StatusCode >= http.StatusBadRequest {
return fmt.Errorf("could not upload asset %s: %s", file.Name(), resp.Status) return fmt.Errorf("could not upload asset %s: %s", asset.GetName(), resp.Status)
} }
} }
} }

View File

@@ -1,4 +1,4 @@
package github_test package github
import ( import (
"fmt" "fmt"
@@ -11,7 +11,6 @@ import (
"github.com/Masterminds/semver" "github.com/Masterminds/semver"
"github.com/Nightapes/go-semantic-release/internal/releaser/github"
"github.com/Nightapes/go-semantic-release/internal/shared" "github.com/Nightapes/go-semantic-release/internal/shared"
"github.com/Nightapes/go-semantic-release/pkg/config" "github.com/Nightapes/go-semantic-release/pkg/config"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@@ -48,29 +47,6 @@ var testNewClient = []testHelperMethodStruct{
}, },
} }
var testHelperMethod = []testHelperMethodStruct{
testHelperMethodStruct{config: config.GitHubProvider{
Repo: "foo",
User: "bar",
},
valid: true,
},
testHelperMethodStruct{config: config.GitHubProvider{
Repo: "",
User: "bar",
},
valid: false,
},
testHelperMethodStruct{config: config.GitHubProvider{
Repo: "foo",
User: "",
},
valid: false,
},
}
var lastVersion, _ = semver.NewVersion("1.0.0") var lastVersion, _ = semver.NewVersion("1.0.0")
var newVersion, _ = semver.NewVersion("2.0.0") var newVersion, _ = semver.NewVersion("2.0.0")
@@ -146,7 +122,7 @@ func TestNew(t *testing.T) {
os.Setenv("GITHUB_TOKEN", "XXX") os.Setenv("GITHUB_TOKEN", "XXX")
} }
_, err := github.New(&testOject.config) _, err := New(&testOject.config, true)
assert.Equal(t, testOject.valid, err == nil) assert.Equal(t, testOject.valid, err == nil)
os.Unsetenv("GITHUB_TOKEN") os.Unsetenv("GITHUB_TOKEN")
@@ -157,7 +133,7 @@ func TestNew(t *testing.T) {
func TestGetCommitURL(t *testing.T) { func TestGetCommitURL(t *testing.T) {
os.Setenv("GITHUB_TOKEN", "XX") os.Setenv("GITHUB_TOKEN", "XX")
for _, testOject := range testNewClient { for _, testOject := range testNewClient {
client, _ := github.New(&testOject.config) client, _ := New(&testOject.config, false)
actualURL := client.GetCommitURL() actualURL := client.GetCommitURL()
if testOject.config.CustomURL != "" { if testOject.config.CustomURL != "" {
expectedURL := fmt.Sprintf("%s/%s/%s/commit/{{hash}}", testOject.config.CustomURL, testOject.config.User, testOject.config.Repo) expectedURL := fmt.Sprintf("%s/%s/%s/commit/{{hash}}", testOject.config.CustomURL, testOject.config.User, testOject.config.Repo)
@@ -175,7 +151,7 @@ func TestGetCommitURL(t *testing.T) {
func TestGetCompareURL(t *testing.T) { func TestGetCompareURL(t *testing.T) {
os.Setenv("GITHUB_TOKEN", "XX") os.Setenv("GITHUB_TOKEN", "XX")
for _, testOject := range testNewClient { for _, testOject := range testNewClient {
client, _ := github.New(&testOject.config) client, _ := New(&testOject.config, false)
actualURL := client.GetCompareURL("1", "2") actualURL := client.GetCompareURL("1", "2")
if testOject.config.CustomURL != "" { if testOject.config.CustomURL != "" {
expectedURL := fmt.Sprintf("%s/%s/%s/compare/%s...%s", testOject.config.CustomURL, testOject.config.User, testOject.config.Repo, "1", "2") expectedURL := fmt.Sprintf("%s/%s/%s/compare/%s...%s", testOject.config.CustomURL, testOject.config.User, testOject.config.Repo, "1", "2")
@@ -190,18 +166,6 @@ func TestGetCompareURL(t *testing.T) {
} }
func TestValidateConfig(t *testing.T) {
os.Setenv("GITHUB_TOKEN", "XX")
for _, testOject := range testHelperMethod {
client, _ := github.New(&testOject.config)
err := client.ValidateConfig()
assert.Equal(t, testOject.valid, err == nil)
}
os.Unsetenv("GITHUB_TOKEN")
}
func TestCreateRelease(t *testing.T) { func TestCreateRelease(t *testing.T) {
os.Setenv("GITHUB_TOKEN", "XX") os.Setenv("GITHUB_TOKEN", "XX")
@@ -209,9 +173,9 @@ func TestCreateRelease(t *testing.T) {
if testObejct.valid { if testObejct.valid {
server := initHTTPServer(testObejct.requestResponseCode, testObejct.requestResponseBody) server := initHTTPServer(testObejct.requestResponseCode, testObejct.requestResponseBody)
testObejct.config.CustomURL = server.URL testObejct.config.CustomURL = server.URL
client, _ := github.New(&testObejct.config) client, _ := New(&testObejct.config, false)
err := client.CreateRelease(testObejct.releaseVersion, testObejct.generatedChangelog) err := client.makeRelease(testObejct.releaseVersion, testObejct.generatedChangelog)
if err != nil { if err != nil {
t.Log(err) t.Log(err)
} }
@@ -221,9 +185,9 @@ func TestCreateRelease(t *testing.T) {
} else { } else {
testObejct.config.CustomURL = "http://foo" testObejct.config.CustomURL = "http://foo"
client, _ := github.New(&testObejct.config) client, _ := New(&testObejct.config, false)
err := client.CreateRelease(testObejct.releaseVersion, testObejct.generatedChangelog) err := client.makeRelease(testObejct.releaseVersion, testObejct.generatedChangelog)
if err != nil { if err != nil {
t.Log(err) t.Log(err)
} }

View File

@@ -12,6 +12,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/Nightapes/go-semantic-release/internal/assets"
"github.com/Nightapes/go-semantic-release/internal/releaser/util" "github.com/Nightapes/go-semantic-release/internal/releaser/util"
"github.com/Nightapes/go-semantic-release/internal/shared" "github.com/Nightapes/go-semantic-release/internal/shared"
"github.com/Nightapes/go-semantic-release/pkg/config" "github.com/Nightapes/go-semantic-release/pkg/config"
@@ -34,9 +35,9 @@ type Client struct {
} }
// New initialize a new gitlabRelease // New initialize a new gitlabRelease
func New(config *config.GitLabProvider) (*Client, error) { func New(config *config.GitLabProvider, checkConfig bool) (*Client, error) {
accessToken, err := util.GetAccessToken(fmt.Sprintf("%s_ACCESS_TOKEN", strings.ToUpper(GITLAB))) accessToken, err := util.GetAccessToken(fmt.Sprintf("%s_ACCESS_TOKEN", strings.ToUpper(GITLAB)))
if err != nil { if err != nil && checkConfig {
return nil, err return nil, err
} }
@@ -52,7 +53,7 @@ func New(config *config.GitLabProvider) (*Client, error) {
logger.Debugf("validate gitlab provider config") logger.Debugf("validate gitlab provider config")
if config.Repo == "" { if config.Repo == "" && checkConfig {
return nil, fmt.Errorf("gitlab Repro is not set") return nil, fmt.Errorf("gitlab Repro is not set")
} }
@@ -85,16 +86,19 @@ func (g *Client) GetCompareURL(oldVersion, newVersion string) string {
return fmt.Sprintf("%s/%s/compare/%s...%s", g.baseURL, g.config.Repo, oldVersion, newVersion) return fmt.Sprintf("%s/%s/compare/%s...%s", g.baseURL, g.config.Repo, oldVersion, newVersion)
} }
//ValidateConfig for gitlab // CreateRelease creates release on remote
func (g *Client) ValidateConfig() error { func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog, assets *assets.Set) error {
return nil err := g.makeRelease(releaseVersion, generatedChangelog)
if err != nil {
return err
}
return g.uploadAssets(assets)
} }
// CreateRelease creates release on remote // CreateRelease creates release on remote
func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog) error { func (g *Client) makeRelease(releaseVersion *shared.ReleaseVersion, generatedChangelog *shared.GeneratedChangelog) error {
tag := releaseVersion.Next.Version.String() tag := "v" + releaseVersion.Next.Version.String()
g.Release = tag g.Release = tag
g.log.Infof("create release with version %s", tag) g.log.Infof("create release with version %s", tag)
url := fmt.Sprintf("%s/projects/%s/releases", g.apiURL, util.PathEscape(g.config.Repo)) url := fmt.Sprintf("%s/projects/%s/releases", g.apiURL, util.PathEscape(g.config.Repo))
@@ -132,23 +136,20 @@ func (g *Client) CreateRelease(releaseVersion *shared.ReleaseVersion, generatedC
return nil return nil
} }
// UploadAssets uploads specified assets func (g *Client) uploadAssets(assets *assets.Set) error {
func (g *Client) UploadAssets(repoDir string, assets []config.Asset) error { for _, asset := range assets.All() {
filesToUpload, err := util.PrepareAssets(repoDir, assets) path, err := asset.GetPath()
if err != nil { if err != nil {
return err return err
} }
for _, f := range filesToUpload { file, err := os.Open(path)
file, err := os.Open(*f)
if err != nil { if err != nil {
return err return err
} }
defer file.Close() defer file.Close()
fileInfo, _ := file.Stat()
result, err := g.uploadFile(fileInfo.Name(), file) result, err := g.uploadFile(asset.GetName(), file)
if err != nil { if err != nil {
return fmt.Errorf("could not upload asset %s: %s", file.Name(), err.Error()) return fmt.Errorf("could not upload asset %s: %s", file.Name(), err.Error())
} }
@@ -157,9 +158,9 @@ func (g *Client) UploadAssets(repoDir string, assets []config.Asset) error {
g.log.Infof("Uploaded file %s to gitlab can be downloaded under %s", file.Name(), downloadURL) g.log.Infof("Uploaded file %s to gitlab can be downloaded under %s", file.Name(), downloadURL)
path := fmt.Sprintf("%s/projects/%s/releases/%s/assets/links?name=%s&url=%s", g.apiURL, util.PathEscape(g.config.Repo), g.Release, util.PathEscape(fileInfo.Name()), downloadURL) uploadURL := fmt.Sprintf("%s/projects/%s/releases/%s/assets/links?name=%s&url=%s", g.apiURL, util.PathEscape(g.config.Repo), g.Release, util.PathEscape(asset.GetName()), downloadURL)
req, err := http.NewRequest("POST", path, nil) req, err := http.NewRequest("POST", uploadURL, nil)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -1,4 +1,4 @@
package gitlab_test package gitlab
import ( import (
"io/ioutil" "io/ioutil"
@@ -13,7 +13,7 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/Nightapes/go-semantic-release/internal/releaser/gitlab" "github.com/Nightapes/go-semantic-release/internal/assets"
"github.com/Nightapes/go-semantic-release/internal/shared" "github.com/Nightapes/go-semantic-release/internal/shared"
"github.com/Nightapes/go-semantic-release/pkg/config" "github.com/Nightapes/go-semantic-release/pkg/config"
) )
@@ -21,10 +21,10 @@ import (
func TestGetCommitURL(t *testing.T) { func TestGetCommitURL(t *testing.T) {
os.Setenv("GITLAB_ACCESS_TOKEN", "XXX") os.Setenv("GITLAB_ACCESS_TOKEN", "XXX")
defer os.Unsetenv("GITLAB_ACCESS_TOKEN") defer os.Unsetenv("GITLAB_ACCESS_TOKEN")
client, err := gitlab.New(&config.GitLabProvider{ client, err := New(&config.GitLabProvider{
CustomURL: "https://localhost/", CustomURL: "https://localhost/",
Repo: "test/test", Repo: "test/test",
}) }, true)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "https://localhost/test/test/commit/{{hash}}", client.GetCommitURL()) assert.Equal(t, "https://localhost/test/test/commit/{{hash}}", client.GetCommitURL())
} }
@@ -32,10 +32,10 @@ func TestGetCommitURL(t *testing.T) {
func TestGetCompareURL(t *testing.T) { func TestGetCompareURL(t *testing.T) {
os.Setenv("GITLAB_ACCESS_TOKEN", "XXX") os.Setenv("GITLAB_ACCESS_TOKEN", "XXX")
defer os.Unsetenv("GITLAB_ACCESS_TOKEN") defer os.Unsetenv("GITLAB_ACCESS_TOKEN")
client, err := gitlab.New(&config.GitLabProvider{ client, err := New(&config.GitLabProvider{
CustomURL: "https://localhost/", CustomURL: "https://localhost/",
Repo: "test/test", Repo: "test/test",
}) }, true)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "https://localhost/test/test/compare/1.0.0...1.0.1", client.GetCompareURL("1.0.0", "1.0.1")) assert.Equal(t, "https://localhost/test/test/compare/1.0.0...1.0.1", client.GetCompareURL("1.0.0", "1.0.1"))
} }
@@ -43,9 +43,9 @@ func TestGetCompareURL(t *testing.T) {
func TestValidateConfig_EmptyRepro(t *testing.T) { func TestValidateConfig_EmptyRepro(t *testing.T) {
os.Setenv("GITLAB_ACCESS_TOKEN", "XXX") os.Setenv("GITLAB_ACCESS_TOKEN", "XXX")
defer os.Unsetenv("GITLAB_ACCESS_TOKEN") defer os.Unsetenv("GITLAB_ACCESS_TOKEN")
_, err := gitlab.New(&config.GitLabProvider{ _, err := New(&config.GitLabProvider{
CustomURL: "https://localhost/", CustomURL: "https://localhost/",
}) }, true)
assert.Error(t, err) assert.Error(t, err)
} }
@@ -55,7 +55,7 @@ func TestValidateConfig_DefaultURL(t *testing.T) {
config := &config.GitLabProvider{ config := &config.GitLabProvider{
Repo: "localhost/test", Repo: "localhost/test",
} }
_, err := gitlab.New(config) _, err := New(config, true)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "https://gitlab.com", config.CustomURL) assert.Equal(t, "https://gitlab.com", config.CustomURL)
} }
@@ -67,7 +67,7 @@ func TestValidateConfig_CustomURL(t *testing.T) {
Repo: "/localhost/test/", Repo: "/localhost/test/",
CustomURL: "https://localhost/", CustomURL: "https://localhost/",
} }
_, err := gitlab.New(config) _, err := New(config, true)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "https://localhost", config.CustomURL) assert.Equal(t, "https://localhost", config.CustomURL)
assert.Equal(t, "localhost/test", config.Repo) assert.Equal(t, "localhost/test", config.Repo)
@@ -108,7 +108,7 @@ func TestCreateRelease(t *testing.T) {
}, },
responseBody: "{}", responseBody: "{}",
responseCode: 200, responseCode: 200,
requestBody: `{"tag_name":"2.0.0","name":"title","ref":"master","description":"content"}`, requestBody: `{"tag_name":"v2.0.0","name":"title","ref":"master","description":"content"}`,
valid: true, valid: true,
}, },
{ {
@@ -132,7 +132,7 @@ func TestCreateRelease(t *testing.T) {
}, },
responseBody: "{}", responseBody: "{}",
responseCode: 500, responseCode: 500,
requestBody: `{"tag_name":"2.0.0","name":"title","ref":"master","description":"content"}`, requestBody: `{"tag_name":"v2.0.0","name":"title","ref":"master","description":"content"}`,
valid: false, valid: false,
}, },
{ {
@@ -157,7 +157,7 @@ func TestCreateRelease(t *testing.T) {
}, },
responseCode: 400, responseCode: 400,
responseBody: "{}", responseBody: "{}",
requestBody: `{"tag_name":"2.0.0","name":"title","ref":"master","description":"content"}`, requestBody: `{"tag_name":"v2.0.0","name":"title","ref":"master","description":"content"}`,
valid: false, valid: false,
}, },
} }
@@ -190,10 +190,10 @@ func TestCreateRelease(t *testing.T) {
} }
os.Setenv("GITLAB_ACCESS_TOKEN", "aToken") os.Setenv("GITLAB_ACCESS_TOKEN", "aToken")
defer os.Unsetenv("GITLAB_ACCESS_TOKEN") defer os.Unsetenv("GITLAB_ACCESS_TOKEN")
client, err := gitlab.New(&testObject.config) client, err := New(&testObject.config, false)
assert.NoError(t, err) assert.NoError(t, err)
err = client.CreateRelease(testObject.releaseVersion, testObject.generatedChangelog) err = client.makeRelease(testObject.releaseVersion, testObject.generatedChangelog)
if err != nil { if err != nil {
t.Log(err) t.Log(err)
} }
@@ -317,11 +317,16 @@ func TestUploadAssets(t *testing.T) {
} }
os.Setenv("GITLAB_ACCESS_TOKEN", "aToken") os.Setenv("GITLAB_ACCESS_TOKEN", "aToken")
defer os.Unsetenv("GITLAB_ACCESS_TOKEN") defer os.Unsetenv("GITLAB_ACCESS_TOKEN")
client, err := gitlab.New(&testObject.config) client, err := New(&testObject.config, false)
assert.NoError(t, err) assert.NoError(t, err)
client.Release = "1.0.0" client.Release = "1.0.0"
err = client.UploadAssets(testObject.testDir, testObject.assets) assets := assets.New(testObject.testDir, "")
err = assets.Add(testObject.assets...)
if err != nil {
t.Log(err)
}
err = client.uploadAssets(assets)
if err != nil { if err != nil {
t.Log(err) t.Log(err)
} }

View File

@@ -3,6 +3,9 @@ package releaser
import ( import (
"fmt" "fmt"
"github.com/Nightapes/go-semantic-release/internal/assets"
"github.com/Nightapes/go-semantic-release/internal/gitutil"
"github.com/Nightapes/go-semantic-release/internal/releaser/git"
"github.com/Nightapes/go-semantic-release/internal/releaser/github" "github.com/Nightapes/go-semantic-release/internal/releaser/github"
"github.com/Nightapes/go-semantic-release/internal/releaser/gitlab" "github.com/Nightapes/go-semantic-release/internal/releaser/gitlab"
"github.com/Nightapes/go-semantic-release/internal/shared" "github.com/Nightapes/go-semantic-release/internal/shared"
@@ -14,33 +17,36 @@ import (
// Releasers struct type // Releasers struct type
type Releasers struct { type Releasers struct {
config *config.ReleaseConfig config *config.ReleaseConfig
git *gitutil.GitUtil
} }
// Releaser interface for providers // Releaser interface for providers
type Releaser interface { type Releaser interface {
ValidateConfig() error CreateRelease(*shared.ReleaseVersion, *shared.GeneratedChangelog, *assets.Set) error
CreateRelease(*shared.ReleaseVersion, *shared.GeneratedChangelog) error
UploadAssets(repoDir string, assets []config.Asset) error
GetCommitURL() string GetCommitURL() string
GetCompareURL(oldVersion, newVersion string) string GetCompareURL(oldVersion, newVersion string) string
} }
// New initialize a Relerser // New initialize a releaser
func New(c *config.ReleaseConfig) *Releasers { func New(c *config.ReleaseConfig, git *gitutil.GitUtil) *Releasers {
return &Releasers{ return &Releasers{
config: c, config: c,
git: git,
} }
} }
//GetReleaser returns an initialized releaser //GetReleaser returns an initialized releaser
func (r *Releasers) GetReleaser() (Releaser, error) { func (r *Releasers) GetReleaser(checkConfig bool) (Releaser, error) {
switch r.config.Release { switch r.config.Release {
case github.GITHUB: case github.GITHUB:
log.Debugf("initialize new %s-provider", github.GITHUB) log.Debugf("initialize new %s-provider", github.GITHUB)
return github.New(&r.config.GitHubProvider) return github.New(&r.config.GitHubProvider, checkConfig)
case gitlab.GITLAB: case gitlab.GITLAB:
log.Debugf("initialize new %s-provider", gitlab.GITLAB) log.Debugf("initialize new %s-provider", gitlab.GITLAB)
return gitlab.New(&r.config.GitLabProvider) return gitlab.New(&r.config.GitLabProvider, checkConfig)
case git.GITONLY:
log.Debugf("initialize new %s-provider", git.GITONLY)
return git.New(&r.config.GitProvider, r.git, checkConfig)
} }
return nil, fmt.Errorf("could not initialize a releaser from this type: %s", r.config.Release) return nil, fmt.Errorf("could not initialize a releaser from this type: %s", r.config.Release)
} }

View File

@@ -1,7 +1,6 @@
package util package util
import ( import (
"archive/zip"
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
@@ -11,7 +10,6 @@ import (
"os" "os"
"strings" "strings"
"github.com/Nightapes/go-semantic-release/pkg/config"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"golang.org/x/oauth2" "golang.org/x/oauth2"
) )
@@ -62,74 +60,78 @@ func GetAccessToken(envName string) (string, error) {
return token, nil return token, nil
} }
// PrepareAssets prepare all files before uploading // // PrepareAssets prepare all files before uploading
func PrepareAssets(repository string, assets []config.Asset) ([]*string, error) { // func PrepareAssets(repository string, assets []config.Asset) ([]*string, error) {
filesToUpload := []*string{} // filesToUpload := []*string{}
for _, asset := range assets { // for _, asset := range assets {
if asset.Name == "" { // if asset.Name != "" && asset.Path == "" {
return nil, fmt.Errorf("asset name declaration is empty, please check your configuration file") // log.Warn("Name is deprecated. Please update your config. See https://nightapes.github.io/go-semantic-release/")
} else if asset.Compress { // }
log.Debugf("Asset %s will now be compressed", asset.Name)
log.Debugf("Repo url %s", repository)
zipNameWithPath, err := zipFile(repository, asset.Name)
if err != nil {
return filesToUpload, err
}
filesToUpload = append(filesToUpload, &zipNameWithPath)
} else {
tmpFileName := fmt.Sprintf("%s/%s", repository, asset.Name)
filesToUpload = append(filesToUpload, &tmpFileName)
}
log.Debugf("Add asset %s to files to upload", asset.Name)
}
return filesToUpload, nil
}
// ZipFile compress given file in zip format // if asset.Path == "" {
func zipFile(repository string, file string) (string, error) { // return nil, fmt.Errorf("asset path declaration is empty, please check your configuration file")
// } else if asset.Compress {
// log.Debugf("Asset %s will now be compressed", asset.Name)
// log.Debugf("Repo url %s", repository)
// zipNameWithPath, err := zipFile(repository, asset.Name)
// if err != nil {
// return filesToUpload, err
// }
// filesToUpload = append(filesToUpload, &zipNameWithPath)
// } else {
// tmpFileName := fmt.Sprintf("%s/%s", repository, asset.Name)
// filesToUpload = append(filesToUpload, &tmpFileName)
// }
// log.Debugf("Add asset %s to files to upload", asset.Name)
// }
// return filesToUpload, nil
// }
fileToZip, err := os.Open(repository + "/" + file) // // ZipFile compress given file in zip format
if err != nil { // func zipFile(repository string, file string) (string, error) {
return "", err
}
defer fileToZip.Close()
zipFileName := fmt.Sprintf("%s/%s.zip", strings.TrimSuffix(repository, "/"), file) // fileToZip, err := os.Open(repository + "/" + file)
zipFile, err := os.Create(zipFileName) // if err != nil {
// return "", err
// }
// defer fileToZip.Close()
if err != nil { // zipFileName := fmt.Sprintf("%s/%s.zip", strings.TrimSuffix(repository, "/"), file)
return "", err // zipFile, err := os.Create(zipFileName)
}
log.Debugf("Created zipfile %s", zipFile.Name())
defer zipFile.Close() // if err != nil {
// return "", err
// }
// log.Debugf("Created zipfile %s", zipFile.Name())
fileToZipInfo, err := fileToZip.Stat() // defer zipFile.Close()
if err != nil {
return "", err
}
zipWriter := zip.NewWriter(zipFile) // fileToZipInfo, err := fileToZip.Stat()
defer zipWriter.Close() // if err != nil {
// return "", err
// }
fileToZipHeader, err := zip.FileInfoHeader(fileToZipInfo) // zipWriter := zip.NewWriter(zipFile)
if err != nil { // defer zipWriter.Close()
return "", err
}
fileToZipHeader.Name = fileToZipInfo.Name() // fileToZipHeader, err := zip.FileInfoHeader(fileToZipInfo)
// if err != nil {
// return "", err
// }
fileToZipWriter, err := zipWriter.CreateHeader(fileToZipHeader) // fileToZipHeader.Name = fileToZipInfo.Name()
if err != nil {
return "", err
}
if _, err = io.Copy(fileToZipWriter, fileToZip); err != nil { // fileToZipWriter, err := zipWriter.CreateHeader(fileToZipHeader)
return "", err // if err != nil {
} // return "", err
// }
return zipFileName, nil // if _, err = io.Copy(fileToZipWriter, fileToZip); err != nil {
} // return "", err
// }
// return zipFileName, nil
// }
//PathEscape to be url save //PathEscape to be url save
func PathEscape(s string) string { func PathEscape(s string) string {

View File

@@ -13,8 +13,6 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/Nightapes/go-semantic-release/pkg/config"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/Nightapes/go-semantic-release/internal/releaser/util" "github.com/Nightapes/go-semantic-release/internal/releaser/util"
@@ -50,80 +48,6 @@ func TestGetAccessToken(t *testing.T) {
} }
} }
type testDoubleFiles struct {
testFiles []config.Asset
valid bool
}
var files = []testDoubleFiles{
testDoubleFiles{
testFiles: []config.Asset{
config.Asset{
Name: "file0",
Compress: true,
},
config.Asset{
Name: "file1",
Compress: true,
},
},
valid: true,
},
testDoubleFiles{
testFiles: []config.Asset{
config.Asset{
Name: "",
Compress: true,
},
config.Asset{
Name: "",
Compress: false,
},
},
valid: false,
},
}
func TestPrepareAssets(t *testing.T) {
for _, testObject := range files {
workDir, _ := os.Getwd()
filesToDelete := []string{}
for _, testFile := range testObject.testFiles {
if testFile.Name != "" {
filesToDelete = append(filesToDelete, testFile.Name)
file, err := os.Create(testFile.Name)
if err != nil {
fmt.Print(err.Error())
}
defer file.Close()
if testFile.Compress {
filesToDelete = append(filesToDelete, testFile.Name+".zip")
}
}
}
preparedFiles, err := util.PrepareAssets(workDir, testObject.testFiles)
if err == nil {
assert.Equal(t, 2, len(preparedFiles))
}
assert.Equal(t, testObject.valid, err == nil)
for _, file := range filesToDelete {
if err := os.Remove(file); err != nil {
fmt.Println(err.Error())
}
}
}
}
func TestShouldRetry(t *testing.T) { func TestShouldRetry(t *testing.T) {
assert.True(t, util.ShouldRetry(&http.Response{StatusCode: 429})) assert.True(t, util.ShouldRetry(&http.Response{StatusCode: 429}))
assert.False(t, util.ShouldRetry(&http.Response{StatusCode: 200})) assert.False(t, util.ShouldRetry(&http.Response{StatusCode: 200}))

View File

@@ -3,6 +3,7 @@ package config
import ( import (
"io/ioutil" "io/ioutil"
"os"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
@@ -11,7 +12,7 @@ import (
// ChangelogConfig struct // ChangelogConfig struct
type ChangelogConfig struct { type ChangelogConfig struct {
PrintAll bool `yaml:"printAll,omitempty"` PrintAll bool `yaml:"printAll,omitempty"`
Template string `yaml:"template,omitempty"` TemplateTitle string `yaml:"title,omitempty"`
TemplatePath string `yaml:"templatePath,omitempty"` TemplatePath string `yaml:"templatePath,omitempty"`
Docker ChangelogDocker `yaml:"docker,omitempty"` Docker ChangelogDocker `yaml:"docker,omitempty"`
NPM ChangelogNPM `yaml:"npm,omitempty"` NPM ChangelogNPM `yaml:"npm,omitempty"`
@@ -31,7 +32,9 @@ type ChangelogNPM struct {
//Asset type struct //Asset type struct
type Asset struct { type Asset struct {
Name string `yaml:"name"` Path string `yaml:"path"`
Rename string `yaml:"rename,omitempty"`
Name string `yaml:"name,omitempty"` // Deprecated
Compress bool `yaml:"compress"` Compress bool `yaml:"compress"`
} }
@@ -50,6 +53,25 @@ type GitLabProvider struct {
AccessToken string AccessToken string
} }
// GitProvider struct
type GitProvider struct {
Email string `yaml:"email"`
Username string `yaml:"user"`
Auth string `yaml:"auth"`
SSH bool `yaml:"ssh"`
}
// Hooks struct
type Hooks struct {
PreRelease []string `yaml:"preRelease"`
PostRelease []string `yaml:"postRelease"`
}
// Checksum struct
type Checksum struct {
Algorithm string `yaml:"algorithm"`
}
// ReleaseConfig struct // ReleaseConfig struct
type ReleaseConfig struct { type ReleaseConfig struct {
CommitFormat string `yaml:"commitFormat"` CommitFormat string `yaml:"commitFormat"`
@@ -58,7 +80,10 @@ type ReleaseConfig struct {
Release string `yaml:"release,omitempty"` Release string `yaml:"release,omitempty"`
GitHubProvider GitHubProvider `yaml:"github,omitempty"` GitHubProvider GitHubProvider `yaml:"github,omitempty"`
GitLabProvider GitLabProvider `yaml:"gitlab,omitempty"` GitLabProvider GitLabProvider `yaml:"gitlab,omitempty"`
GitProvider GitProvider `yaml:"git,omitempty"`
Assets []Asset `yaml:"assets"` Assets []Asset `yaml:"assets"`
Checksum Checksum `yaml:"checksum,omitempty"`
Hooks Hooks `yaml:"hooks"`
ReleaseTitle string `yaml:"title"` ReleaseTitle string `yaml:"title"`
IsPreRelease bool IsPreRelease bool
} }
@@ -71,13 +96,31 @@ func Read(configPath string) (*ReleaseConfig, error) {
return &ReleaseConfig{}, err return &ReleaseConfig{}, err
} }
var releaseConfig ReleaseConfig log.Tracef("Found config %s", string(content))
err = yaml.Unmarshal(content, &releaseConfig) releaseConfig := &ReleaseConfig{}
err = yaml.Unmarshal(content, releaseConfig)
if err != nil { if err != nil {
return &ReleaseConfig{}, err return &ReleaseConfig{}, err
} }
log.Tracef("Found config %+v", releaseConfig) org := *releaseConfig
return &releaseConfig, nil releaseConfig.Hooks = Hooks{}
configWithoutHooks, err := yaml.Marshal(releaseConfig)
if err != nil {
return &ReleaseConfig{}, err
}
configWithoutHooks = []byte(os.ExpandEnv(string(configWithoutHooks)))
releaseConfigWithExpanedEnvs := &ReleaseConfig{}
err = yaml.Unmarshal(configWithoutHooks, releaseConfigWithExpanedEnvs)
if err != nil {
return &ReleaseConfig{}, err
}
releaseConfigWithExpanedEnvs.Hooks = org.Hooks
log.Tracef("Found config %+v", releaseConfigWithExpanedEnvs)
return releaseConfigWithExpanedEnvs, nil
} }

View File

@@ -41,6 +41,9 @@ func TestWriteAndReadCache(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
os.Setenv("TEST_CONFIG", "value")
defer os.Unsetenv("TEST_CONFIG")
completePath := path.Join(path.Dir(dir), ".release.yml") completePath := path.Join(path.Dir(dir), ".release.yml")
content := []byte(` content := []byte(`
commitFormat: angular commitFormat: angular
@@ -53,9 +56,12 @@ branch:
add_git_releases: alpha add_git_releases: alpha
changelog: changelog:
printAll: false printAll: false
template: '' template: ""
templatePath: '' templatePath: '${TEST_CONFIG}'
release: 'github' release: 'github'
hooks:
preRelease:
- "Test hook ${RELEASE_VERSION}"
assets: assets:
- name: ./build/go-semantic-release - name: ./build/go-semantic-release
compress: false compress: false
@@ -75,14 +81,19 @@ github:
Branch: map[string]string{"add_git_releases": "alpha", "alpha": "alpha", "beta": "beta", "master": "release", "rc": "rc"}, Branch: map[string]string{"add_git_releases": "alpha", "alpha": "alpha", "beta": "beta", "master": "release", "rc": "rc"},
Changelog: config.ChangelogConfig{ Changelog: config.ChangelogConfig{
PrintAll: false, PrintAll: false,
Template: "", TemplateTitle: "",
TemplatePath: ""}, TemplatePath: "value"},
Release: "github", Release: "github",
GitHubProvider: config.GitHubProvider{ GitHubProvider: config.GitHubProvider{
Repo: "go-semantic-release", Repo: "go-semantic-release",
User: "nightapes", User: "nightapes",
CustomURL: "", CustomURL: "",
AccessToken: ""}, AccessToken: ""},
Hooks: config.Hooks{
PreRelease: []string{
"Test hook ${RELEASE_VERSION}",
},
},
Assets: []config.Asset{ Assets: []config.Asset{
config.Asset{ config.Asset{
Name: "./build/go-semantic-release", Name: "./build/go-semantic-release",
@@ -92,20 +103,3 @@ github:
}, result) }, result)
} }
// func TestWriteNotFound(t *testing.T) {
// err := cache.Write("notfound/dir", shared.ReleaseVersion{
// Last: shared.ReleaseVersionEntry{
// Commit: "12345",
// Version: createVersion("1.0.0"),
// },
// Next: shared.ReleaseVersionEntry{
// Commit: "12346",
// Version: createVersion("1.1.0"),
// },
// Branch: "master",
// })
// assert.Errorf(t, err, "Write non exsiting file")
// }

View File

@@ -5,17 +5,19 @@ import (
"time" "time"
"github.com/Masterminds/semver" "github.com/Masterminds/semver"
log "github.com/sirupsen/logrus"
"github.com/Nightapes/go-semantic-release/internal/analyzer" "github.com/Nightapes/go-semantic-release/internal/analyzer"
"github.com/Nightapes/go-semantic-release/internal/assets"
"github.com/Nightapes/go-semantic-release/internal/cache" "github.com/Nightapes/go-semantic-release/internal/cache"
"github.com/Nightapes/go-semantic-release/internal/calculator" "github.com/Nightapes/go-semantic-release/internal/calculator"
"github.com/Nightapes/go-semantic-release/internal/changelog" "github.com/Nightapes/go-semantic-release/internal/changelog"
"github.com/Nightapes/go-semantic-release/internal/ci" "github.com/Nightapes/go-semantic-release/internal/ci"
"github.com/Nightapes/go-semantic-release/internal/gitutil" "github.com/Nightapes/go-semantic-release/internal/gitutil"
"github.com/Nightapes/go-semantic-release/internal/hooks"
"github.com/Nightapes/go-semantic-release/internal/releaser" "github.com/Nightapes/go-semantic-release/internal/releaser"
"github.com/Nightapes/go-semantic-release/internal/releaser/util"
"github.com/Nightapes/go-semantic-release/internal/shared" "github.com/Nightapes/go-semantic-release/internal/shared"
"github.com/Nightapes/go-semantic-release/pkg/config" "github.com/Nightapes/go-semantic-release/pkg/config"
log "github.com/sirupsen/logrus"
) )
// SemanticRelease struct // SemanticRelease struct
@@ -25,11 +27,13 @@ type SemanticRelease struct {
analyzer *analyzer.Analyzer analyzer *analyzer.Analyzer
calculator *calculator.Calculator calculator *calculator.Calculator
releaser releaser.Releaser releaser releaser.Releaser
assets *assets.Set
repository string repository string
checkConfig bool
} }
// New SemanticRelease struct // New SemanticRelease struct
func New(c *config.ReleaseConfig, repository string) (*SemanticRelease, error) { func New(c *config.ReleaseConfig, repository string, checkConfig bool) (*SemanticRelease, error) {
util, err := gitutil.New(repository) util, err := gitutil.New(repository)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -40,7 +44,13 @@ func New(c *config.ReleaseConfig, repository string) (*SemanticRelease, error) {
return nil, err return nil, err
} }
releaser, err := releaser.New(c).GetReleaser() if !checkConfig {
log.Infof("Ignore config checks!. No guarantee to run without issues")
}
assets := assets.New(repository, c.Checksum.Algorithm)
releaser, err := releaser.New(c, util).GetReleaser(checkConfig)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -51,13 +61,15 @@ func New(c *config.ReleaseConfig, repository string) (*SemanticRelease, error) {
releaser: releaser, releaser: releaser,
analyzer: analyzer, analyzer: analyzer,
repository: repository, repository: repository,
assets: assets,
checkConfig: checkConfig,
calculator: calculator.New(), calculator: calculator.New(),
}, nil }, nil
} }
//GetCIProvider result with ci config //GetCIProvider result with ci config
func (s *SemanticRelease) GetCIProvider() (*ci.ProviderConfig, error) { func (s *SemanticRelease) GetCIProvider() (*ci.ProviderConfig, error) {
return ci.GetCIProvider(s.gitutil, ci.ReadAllEnvs()) return ci.GetCIProvider(s.gitutil, s.checkConfig, ci.ReadAllEnvs())
} }
// GetNextVersion from .version or calculate new from commits // GetNextVersion from .version or calculate new from commits
@@ -183,7 +195,7 @@ func (s *SemanticRelease) WriteChangeLog(changelogContent, file string) error {
return ioutil.WriteFile(file, []byte(changelogContent), 0644) return ioutil.WriteFile(file, []byte(changelogContent), 0644)
} }
// Release pusblish release to provider // Release publish release to provider
func (s *SemanticRelease) Release(provider *ci.ProviderConfig, force bool) error { func (s *SemanticRelease) Release(provider *ci.ProviderConfig, force bool) error {
if provider.IsPR { if provider.IsPR {
@@ -196,6 +208,10 @@ func (s *SemanticRelease) Release(provider *ci.ProviderConfig, force bool) error
return nil return nil
} }
if err := s.assets.Add(s.config.Assets...); err != nil {
return err
}
releaseVersion, err := s.GetNextVersion(provider, force) releaseVersion, err := s.GetNextVersion(provider, force)
if err != nil { if err != nil {
log.Debugf("Could not get next version") log.Debugf("Could not get next version")
@@ -207,27 +223,38 @@ func (s *SemanticRelease) Release(provider *ci.ProviderConfig, force bool) error
return nil return nil
} }
generatedChanglog, err := s.GetChangelog(releaseVersion) generatedChangelog, err := s.GetChangelog(releaseVersion)
if err != nil { if err != nil {
log.Debugf("Could not get changelog") log.Debugf("Could not get changelog")
return err return err
} }
releaser, err := releaser.New(s.config).GetReleaser() hook := hooks.New(s.config, releaseVersion)
if err != nil { if err := hook.PreRelease(); err != nil {
log.Debugf("Error during pre release hook")
return err return err
} }
err = releaser.ValidateConfig() if s.config.Checksum.Algorithm != "" {
if err != nil { if err := s.assets.GenerateChecksum(); err != nil {
return err
}
}
for _, asset := range s.assets.All() {
if asset.IsCompressed() {
if _, err := asset.ZipFile(); err != nil {
return err
}
}
}
if err = s.releaser.CreateRelease(releaseVersion, generatedChangelog, s.assets); err != nil {
return err return err
} }
if err = releaser.CreateRelease(releaseVersion, generatedChanglog); err != nil { if err := hook.PostRelease(); err != nil {
return err log.Debugf("Error during post release hook")
}
if err = releaser.UploadAssets(s.repository, s.config.Assets); err != nil {
return err return err
} }
@@ -236,12 +263,21 @@ func (s *SemanticRelease) Release(provider *ci.ProviderConfig, force bool) error
// ZipFiles zip files configured in release config // ZipFiles zip files configured in release config
func (s *SemanticRelease) ZipFiles() error { func (s *SemanticRelease) ZipFiles() error {
for _, file := range s.config.Assets { assets := assets.New(s.repository, "")
if file.Compress {
if _, err := util.PrepareAssets(s.repository, s.config.Assets); err != nil { if err := assets.Add(s.config.Assets...); err != nil {
return err return err
} }
if err := assets.GenerateChecksum(); err != nil {
return err
} }
for _, asset := range assets.All() {
path, err := asset.GetPath()
if err != nil {
return err
}
log.Infof("File %s under %s is zipped %t", asset.GetName(), path, asset.IsCompressed())
} }
return nil return nil
} }