Skip to content

Commit bc0031c

Browse files
committed
Add release workflow
1 parent 42abaea commit bc0031c

File tree

3 files changed

+78
-8
lines changed

3 files changed

+78
-8
lines changed

.github/workflows/release.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
1-
name: release
1+
name: Release
2+
23
on:
34
push:
45
tags:
5-
- "v*"
6-
permissions:
7-
contents: write
6+
- '*'
87

98
jobs:
10-
release:
9+
goreleaser:
10+
name: Run GoReleaser
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
1214
steps:
13-
- uses: actions/checkout@v3
14-
- uses: cli/gh-extension-precompile@v1
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Set up Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version-file: "go.mod"
23+
cache: true
24+
- name: Run GoReleaser
25+
uses: goreleaser/goreleaser-action@v6
26+
with:
27+
distribution: goreleaser
28+
version: latest
29+
args: release --clean
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 2
2+
3+
builds:
4+
- main: cmd/gh-codeowners/main.go
5+
env:
6+
- CGO_ENABLED=0
7+
goos:
8+
- linux
9+
- windows
10+
- darwin
11+
goarch:
12+
- "386"
13+
- amd64
14+
- arm64
15+
ldflags:
16+
- -s -w
17+
- -X go.szostok.io/version.version={{.Version}}
18+
- -X go.szostok.io/version.buildDate={{.Date}}
19+
20+
archives:
21+
- name_template: "gh-codeowners-{{ .Os }}-{{ .Arch }}"
22+
format: binary
23+
24+
checksum:
25+
name_template: 'checksums.txt'
26+
27+
snapshot:
28+
name_template: "{{ .Tag }}-next"
29+
30+
changelog:
31+
use: github
32+
filters:
33+
exclude:
34+
- '^docs:'
35+
- '^test:'

internal/issues/printer.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package issues
33
import (
44
"bytes"
55
"fmt"
6+
"os"
67
"regexp"
78
"strings"
89

@@ -24,8 +25,16 @@ type Printer struct {
2425
func NewPrinter() (*Printer, error) {
2526
terminal := term.FromEnv()
2627
termWidth, _, _ := terminal.Size()
28+
opts := []glamour.TermRendererOption{
29+
glamour.WithWordWrap(termWidth),
30+
}
31+
if !terminal.IsColorEnabled() {
32+
opts = append(opts, glamour.WithStyles(glamour.NoTTYStyleConfig))
33+
} else {
34+
opts = append(opts, glamour.WithStylePath(getEnvironmentStyle()))
35+
}
2736

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

99108
return nil
100109
}
110+
111+
func getEnvironmentStyle() string {
112+
glamourStyle := os.Getenv("GLAMOUR_STYLE")
113+
if glamourStyle == "" {
114+
glamourStyle = glamour.AutoStyle
115+
}
116+
117+
return glamourStyle
118+
}

0 commit comments

Comments
 (0)