Skip to content

Commit

Permalink
Merge pull request #44 from Nightapes/fix/hooks
Browse files Browse the repository at this point in the history
feat(hooks): pass environment variables to hooks
  • Loading branch information
Nightapes authored Aug 18, 2020
2 parents 1bc0185 + 348ea66 commit 8ffc080
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 35 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: Go
on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
jobs:
build:
strategy:
matrix:
go: ["1.13", "1.14"]
go: ["1.13", "1.14", "1.15"]
name: Build with go version ${{ matrix.go }}
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
- name: Set up GoLang ${{ matrix.go }}
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go }}
Expand All @@ -20,7 +24,7 @@ jobs:
- name: Lint
run: |
export PATH=$PATH:$(go env GOPATH)/bin
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.18.0
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.30.0
golangci-lint run ./...
- name: Run tests
Expand All @@ -37,7 +41,7 @@ jobs:
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'
if: matrix.go == '1.15'
run: |
docker login -u nightapes -p ${{ secrets.DOCKER_PASSWORD }}
docker login -u nightapes -p ${{ secrets.GITHUB_TOKEN }} docker.pkg.github.com
Expand All @@ -46,7 +50,7 @@ jobs:
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'
if: matrix.go == '1.15'
with:
name: build
path: build
Expand Down
5 changes: 3 additions & 2 deletions cmd/go-semantic-release/commands/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

func init() {
changelogCmd.Flags().Bool("checks", false, "Check for missing values and envs")
changelogCmd.Flags().StringP("out", "o", "CHANGELOG.md", "Name of the file")
rootCmd.AddCommand(changelogCmd)
}
Expand Down Expand Up @@ -35,12 +36,12 @@ var changelogCmd = &cobra.Command{
return err
}

ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
configChecks, err := cmd.Flags().GetBool("checks")
if err != nil {
return err
}

s, err := semanticrelease.New(readConfig(config), repository, !ignoreConfigChecks)
s, err := semanticrelease.New(readConfig(config), repository, configChecks)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/go-semantic-release/commands/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

func init() {
hooksCmd.Flags().Bool("checks", false, "Check for missing values and envs")
rootCmd.AddCommand(hooksCmd)
}

Expand All @@ -29,14 +30,14 @@ var hooksCmd = &cobra.Command{
return err
}

ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
configChecks, err := cmd.Flags().GetBool("checks")
if err != nil {
return err
}

releaseConfig := readConfig(config)

s, err := semanticrelease.New(releaseConfig, repository, !ignoreConfigChecks)
s, err := semanticrelease.New(releaseConfig, repository, configChecks)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/go-semantic-release/commands/last.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func init() {
lastCmd.Flags().Bool("checks", false, "Check for missing values and envs")
rootCmd.AddCommand(lastCmd)
}

Expand All @@ -30,12 +31,12 @@ var lastCmd = &cobra.Command{
return err
}

ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
configChecks, err := cmd.Flags().GetBool("checks")
if err != nil {
return err
}

s, err := semanticrelease.New(readConfig(config), repository, !ignoreConfigChecks)
s, err := semanticrelease.New(readConfig(config), repository, configChecks)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/go-semantic-release/commands/next.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func init() {
nextCmd.Flags().Bool("checks", false, "Check for missing values and envs")
rootCmd.AddCommand(nextCmd)
}

Expand All @@ -30,12 +31,12 @@ var nextCmd = &cobra.Command{
return err
}

ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
configChecks, err := cmd.Flags().GetBool("checks")
if err != nil {
return err
}

s, err := semanticrelease.New(readConfig(config), repository, !ignoreConfigChecks)
s, err := semanticrelease.New(readConfig(config), repository, configChecks)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions cmd/go-semantic-release/commands/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
)

func init() {
releaseCmd.Flags().Bool("no-checks", false, "Ignore missing values and envs")
rootCmd.AddCommand(releaseCmd)
}

Expand Down
1 change: 0 additions & 1 deletion cmd/go-semantic-release/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func init() {
rootCmd.PersistentFlags().StringP("loglevel", "l", "error", "Set loglevel")
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-checks", false, "Ignore missing values and envs")
}

func readConfig(file string) *config.ReleaseConfig {
Expand Down
5 changes: 3 additions & 2 deletions cmd/go-semantic-release/commands/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

func init() {
setCmd.Flags().Bool("checks", false, "Check for missing values and envs")
rootCmd.AddCommand(setCmd)
}

Expand All @@ -26,12 +27,12 @@ var setCmd = &cobra.Command{
return err
}

ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
configChecks, err := cmd.Flags().GetBool("checks")
if err != nil {
return err
}

s, err := semanticrelease.New(readConfig(config), repository, !ignoreConfigChecks)
s, err := semanticrelease.New(readConfig(config), repository, configChecks)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/go-semantic-release/commands/zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
)

func init() {
zipCmd.Flags().Bool("checks", false, "Check for missing values and envs")
zipCmd.Flags().StringP("algorithm", "a", "sha256", "Algorithm for checksum (crc32,md5,sha1,sha224,sha384,sha256,sha512)")
rootCmd.AddCommand(zipCmd)
}
Expand All @@ -24,12 +25,12 @@ var zipCmd = &cobra.Command{
return err
}

ignoreConfigChecks, err := cmd.Flags().GetBool("no-checks")
configChecks, err := cmd.Flags().GetBool("checks")
if err != nil {
return err
}

s, err := semanticrelease.New(readConfig(config), repository, !ignoreConfigChecks)
s, err := semanticrelease.New(readConfig(config), repository, configChecks)
if err != nil {
return err
}
Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ go 1.13

require (
github.com/Masterminds/semver v1.5.0
github.com/golang/protobuf v1.3.4 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/go-github/v25 v25.1.3
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/spf13/cobra v0.0.6
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.4.0
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d // indirect
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b // indirect
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de // indirect
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae // indirect
google.golang.org/appengine v1.6.5 // indirect
golang.org/x/sys v0.0.0-20200817155316-9781c653f443 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/src-d/go-billy.v4 v4.3.2
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v2 v2.2.8
gopkg.in/yaml.v2 v2.3.0
)
Loading

0 comments on commit 8ffc080

Please sign in to comment.