Skip to content

Commit

Permalink
Add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok committed Jul 23, 2024
1 parent 42abaea commit bc0031c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 8 deletions.
31 changes: 24 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
name: release
name: Release

on:
push:
tags:
- "v*"
permissions:
contents: write
- '*'

jobs:
release:
goreleaser:
name: Run GoReleaser
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: cli/gh-extension-precompile@v1
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: 2

builds:
- main: cmd/gh-codeowners/main.go
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- "386"
- amd64
- arm64
ldflags:
- -s -w
- -X go.szostok.io/version.version={{.Version}}
- -X go.szostok.io/version.buildDate={{.Date}}

archives:
- name_template: "gh-codeowners-{{ .Os }}-{{ .Arch }}"
format: binary

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Tag }}-next"

changelog:
use: github
filters:
exclude:
- '^docs:'
- '^test:'
20 changes: 19 additions & 1 deletion internal/issues/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package issues
import (
"bytes"
"fmt"
"os"
"regexp"
"strings"

Expand All @@ -24,8 +25,16 @@ type Printer struct {
func NewPrinter() (*Printer, error) {
terminal := term.FromEnv()
termWidth, _, _ := terminal.Size()
opts := []glamour.TermRendererOption{
glamour.WithWordWrap(termWidth),
}
if !terminal.IsColorEnabled() {
opts = append(opts, glamour.WithStyles(glamour.NoTTYStyleConfig))
} else {
opts = append(opts, glamour.WithStylePath(getEnvironmentStyle()))
}

renderer, err := glamour.NewTermRenderer(glamour.WithWordWrap(termWidth), glamour.WithEnvironmentConfig())
renderer, err := glamour.NewTermRenderer(opts...)
if err != nil {
return nil, fmt.Errorf("while creating glamour renderer: %w", err)
}
Expand Down Expand Up @@ -98,3 +107,12 @@ func (p *Printer) PrintMissingOwnersFile(missingFiles []string, org string) erro

return nil
}

func getEnvironmentStyle() string {
glamourStyle := os.Getenv("GLAMOUR_STYLE")
if glamourStyle == "" {
glamourStyle = glamour.AutoStyle
}

return glamourStyle
}

0 comments on commit bc0031c

Please sign in to comment.