Skip to content

Commit

Permalink
feat: only print make log if not use -n, add auto release
Browse files Browse the repository at this point in the history
  • Loading branch information
fcying committed Aug 2, 2024
1 parent d1e66a1 commit bb3f1e1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: release

on:
push:
tags: v[0-9]+.[0-9]+.[0-9]+
branches: [ master, test ]
workflow_dispatch:

defaults:
Expand All @@ -14,13 +14,28 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
env:
VERSION: ""
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: 'stable'
- run: go version

- name: Check need release
id: check_release
run: |
version=""
new_ver=$(grep -Po "v\d+\.\d+\.\d+" cmd/compiledb/main.go)
cur_ver=$(git describe --abbrev=0 --tags)
if [ "$new_ver" != "$cur_ver" ]; then
version=$new_ver
fi
echo "VERSION=$version" >> $GITHUB_ENV
- name: Install dependencies
run: go mod tidy

Expand Down Expand Up @@ -53,8 +68,10 @@ jobs:
ls -la $out
- name: Release
if: ${{ env.VERSION != '' }}
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
allowUpdates: true
artifactErrorsFailBuild: true
generateReleaseNotes: true
Expand Down
3 changes: 1 addition & 2 deletions cmd/compiledb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/urfave/cli/v2"
)

var Version string = "v1.1.0"
var Version string = "v1.2.0"

func init() {
log.SetOutput(os.Stdout)
Expand All @@ -32,7 +32,6 @@ func updateConfig(ctx *cli.Context) {
}

func main() {

cli.AppHelpTemplate = `{{.HelpName}} {{.Version}}
USAGE: {{.Name}} {{if .VisibleFlags}}[options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[args]...
Expand Down
21 changes: 15 additions & 6 deletions internal/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ type Config struct {
}

var (
CommandCnt = 0
ParseConfig Config = Config{
OutputFile: "compile_commands.json",
}
CommandCnt = 0
ParseConfig Config
ParseResult []interface{}
)

Expand Down Expand Up @@ -63,8 +61,8 @@ func WriteJSON(filename string) {

func MakeWrap(args []string) {
var wg sync.WaitGroup
wg.Add(1)

wg.Add(1)
go func() {
// append log
args = append([]string{"-Bnkw"}, args...)
Expand All @@ -73,12 +71,23 @@ func MakeWrap(args []string) {
var stdoutBuf bytes.Buffer
cmd.Stdout = &stdoutBuf
cmd.Stderr = &stdoutBuf

cmd.Run()

level := log.GetLevel()

// only print make log
if ParseConfig.NoBuild == false {
log.SetLevel(log.PanicLevel)
}

buildLog := strings.Split(stdoutBuf.String(), "\n")
Parse(buildLog)

// restore log level
if ParseConfig.NoBuild == false {
log.SetLevel(level)
}

wg.Done()
}()

Expand Down

0 comments on commit bb3f1e1

Please sign in to comment.