Skip to content

Commit

Permalink
added goreleaser to manage releases
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin committed Dec 27, 2020
1 parent 9665ef8 commit 6c9e750
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release Go project

on:
push:
tags:
- "*" # triggers only if push new tag version, like `0.8.4` or else

jobs:
build:
name: GoReleaser build
runs-on: ubuntu-latest

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0 # See: https://goreleaser.com/ci/actions/

- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
id: go

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@master
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }}
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ func replaceTextBetweenMarkers(sourceText string, config Config) string {
paddedReplaceText := fmt.Sprintf("%s%s", strings.Repeat(" ", config.Indent),
reAddSpaces.ReplaceAllString(config.Block, "\n"+strings.Repeat(" ", config.Indent)))

if !config.State {
// Remove the block
switch {
case !config.State:
return removeExistingBlock(sourceText, config.BeginMarker, config.EndMarker)
} else if config.InsertBefore != "" {
case config.InsertBefore != "":
sourceText = removeExistingBlock(sourceText, config.BeginMarker, config.EndMarker)

var index = strings.LastIndex(sourceText, config.InsertBefore)
Expand All @@ -233,7 +233,7 @@ func replaceTextBetweenMarkers(sourceText string, config Config) string {
paddedReplaceText,
paddedEndMarker,
sourceText[index:])
} else if config.InsertAfter != "" {
case config.InsertAfter != "":
sourceText = removeExistingBlock(sourceText, config.BeginMarker, config.EndMarker)

var index = strings.LastIndex(sourceText, config.InsertAfter)
Expand All @@ -253,7 +253,7 @@ func replaceTextBetweenMarkers(sourceText string, config Config) string {
paddedReplaceText,
paddedEndMarker,
sourceText[index:])
} else if strings.Contains(sourceText, config.BeginMarker) {
case strings.Contains(sourceText, config.BeginMarker):
// Remove any leading spaces before replacing the block in case indentation changed
beginIndex := strings.LastIndex(sourceText, config.BeginMarker)
sourceText = removeLeadingSpacesOfBlock(sourceText, beginIndex)
Expand All @@ -266,7 +266,7 @@ func replaceTextBetweenMarkers(sourceText string, config Config) string {
paddedReplaceText,
paddedEndMarker),
)
} else {
default:
// Not found, add to EOF
return fmt.Sprintf("%s%s\n%s\n%s\n",
sourceText,
Expand Down

0 comments on commit 6c9e750

Please sign in to comment.