-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit generally improves CICD in regards to automated tagging. Instead of manually adding and pushing a tag to trigger a release, it's controlled through the `mockery-tools.env` config. Furthermore, doc updates no longer require tags to update the docs page. It too will key off of the `VERSION` parameter to determine the correct version to push.
- Loading branch information
1 parent
a27cb03
commit 63a14b5
Showing
12 changed files
with
713 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
name: documentation | ||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
branches: [ master ] | ||
permissions: | ||
contents: write | ||
jobs: | ||
|
@@ -27,6 +26,6 @@ jobs: | |
git config --global user.email [email protected] | ||
git fetch origin gh-pages --depth=1 | ||
- name: Deploy docs | ||
run: "mike deploy --push --update-aliases $(echo ${{ github.ref_name }} | cut -d'.' -f1-2 ) latest" | ||
run: "mike deploy --push --update-aliases $(grep VERSION mockery-tools.env | cut -d'=' -f 2 | cut -d'.' -f1-2) latest" | ||
env: | ||
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Create new Git tag | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
permissions: | ||
contents: write | ||
jobs: | ||
tag: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tag_result: ${{ steps.tag.outputs.tag_result }} | ||
steps: | ||
- run: sudo apt update && sudo apt install -y git && git --version | ||
- uses: actions/checkout@v2 | ||
with: | ||
# We need entire history of tags | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: ./tools/go.mod | ||
check-latest: true | ||
cache-dependency-path: "**/*.sum" | ||
|
||
- name: Download Go dependencies | ||
run: cd tools/ && go run github.com/go-task/task/v3/cmd/task install-deps && echo "~/go/bin" >> $GITHUB_PATH | ||
|
||
- name: Run tagging commands | ||
id: tag | ||
run: | | ||
set +e | ||
task -x tag | ||
tag_result="$?" | ||
echo "tag_result=$tag_result" >> $GITHUB_OUTPUT | ||
# The range between 8 and 63 inclusive is reserved for custom | ||
# error codes that contain specific meaning. | ||
if [ $tag_result -lt 8 -o $tag_result -gt 63 ]; then | ||
exit $tag_result | ||
fi | ||
exit 0 | ||
- name: Push tags | ||
run: task tag.push | ||
if: steps.tag.outputs.tag_result == 0 | ||
|
||
release: | ||
needs: tag | ||
if: needs.tag.outputs.tag_result == 0 | ||
runs-on: ubuntu-latest | ||
env: | ||
DOCKER_CLI_EXPERIMENTAL: "enabled" | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: GoReleaser | ||
uses: goreleaser/[email protected] | ||
with: | ||
args: release --rm-dist | ||
version: "<2" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} | ||
HOMEBREW_TAP_TOKEN: ${{ secrets.GORELEASER_HOMEBREW_TAP_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VERSION=v2.49.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/go-errors/errors" | ||
"github.com/rs/zerolog" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var logger zerolog.Logger | ||
|
||
type timestampHook struct{} | ||
|
||
func (t timestampHook) Run(e *zerolog.Event, level zerolog.Level, message string) { | ||
e.Timestamp() | ||
} | ||
|
||
func maybeExit(err error) { | ||
printStack(err) | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func newViper() *viper.Viper { | ||
v := viper.New() | ||
v.SetConfigType("env") | ||
v.SetConfigName("mockery-tools") | ||
v.AddConfigPath(".") | ||
v.AddConfigPath("../") | ||
v.SetEnvPrefix("MOCKERYTOOLS") | ||
maybeExit(v.ReadInConfig()) | ||
return v | ||
} | ||
|
||
func NewRootCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "mockery_tools [command]", | ||
} | ||
|
||
logger = zerolog.New(zerolog.ConsoleWriter{ | ||
Out: os.Stdout, | ||
}).Hook(timestampHook{}) | ||
|
||
subCommands := []func(v *viper.Viper) (*cobra.Command, error){ | ||
NewTagCmd, | ||
} | ||
for _, CommandFunc := range subCommands { | ||
subCmd, err := CommandFunc(newViper()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
cmd.AddCommand(subCmd) | ||
} | ||
return cmd | ||
} | ||
|
||
func printStack(err error) { | ||
if err == nil { | ||
return | ||
} | ||
newErr, ok := err.(*errors.Error) | ||
if ok { | ||
fmt.Printf("%v\n", newErr.ErrorStack()) | ||
} else { | ||
fmt.Printf("%v\n", err) | ||
} | ||
} |
Oops, something went wrong.