diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f026f0..ae749a8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: release on: push: - tags: v[0-9]+.[0-9]+.[0-9]+ + branches: [ master, test ] workflow_dispatch: defaults: @@ -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 @@ -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 diff --git a/cmd/compiledb/main.go b/cmd/compiledb/main.go index 2e3867b..054b081 100644 --- a/cmd/compiledb/main.go +++ b/cmd/compiledb/main.go @@ -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) @@ -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]... diff --git a/internal/init.go b/internal/init.go index 8279ca3..73b3dec 100644 --- a/internal/init.go +++ b/internal/init.go @@ -25,10 +25,8 @@ type Config struct { } var ( - CommandCnt = 0 - ParseConfig Config = Config{ - OutputFile: "compile_commands.json", - } + CommandCnt = 0 + ParseConfig Config ParseResult []interface{} ) @@ -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...) @@ -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() }()