diff --git a/.chglog/config.yml b/.chglog/config.yml index d5cb624..57aadc3 100755 --- a/.chglog/config.yml +++ b/.chglog/config.yml @@ -1,3 +1,7 @@ +# Copyright © 2023 KubeCub open source community. All rights reserved. +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + style: github template: CHANGELOG.tpl.md info: diff --git a/.github/sync_labeler.yml b/.github/sync_labeler.yml index 93da08e..3e0d4c2 100644 --- a/.github/sync_labeler.yml +++ b/.github/sync_labeler.yml @@ -1,3 +1,7 @@ +# Copyright © 2023 KubeCub open source community. All rights reserved. +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + - color: f9d0c4 default: false description: ¯\\\_(ツ)_/¯ diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml new file mode 100644 index 0000000..9b2ba64 --- /dev/null +++ b/.github/workflows/create-release-branch.yml @@ -0,0 +1,45 @@ +# Copyright © 2023 KubeCub open source community. All rights reserved. +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +name: Create Release Branch + +on: + push: + tags: + - 'v*' # 监听以 'v' 开头的 tag + +jobs: + create_release_branch: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Create release branch + run: | + # 获取当前推送的 tag + TAG_NAME=$(echo "${GITHUB_REF}" | sed -e 's,.*/\(.*\),\1,') + + # 检查 tag 格式是否符合预期 + if [[ "${TAG_NAME}" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + MAJOR_VERSION=${BASH_REMATCH[1]} + MINOR_VERSION=${BASH_REMATCH[2]} + PATCH_VERSION=${BASH_REMATCH[3]} + + # 检查是否满足创建分支的条件 + if [[ ${PATCH_VERSION} -eq 0 && ! ${TAG_NAME} =~ [A-Za-z-] ]]; then + RELEASE_BRANCH_NAME="release-v${MAJOR_VERSION}.0" + + # 创建分支 + git branch "${RELEASE_BRANCH_NAME}" "${TAG_NAME}" + git push origin "${RELEASE_BRANCH_NAME}" + + echo "Created release branch: ${RELEASE_BRANCH_NAME}" + else + echo "Tag format is invalid or does not meet the conditions. Release branch not created." + fi + else + echo "Tag format is invalid. Release branch not created." + fi diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 8f5c40c..c3bf7ac 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -1,3 +1,7 @@ +# Copyright © 2023 KubeCub open source community. All rights reserved. +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + name: Daily Build and Push on: diff --git a/.github/workflows/depsreview.yaml b/.github/workflows/depsreview.yaml index bb9f369..bdbbdc5 100644 --- a/.github/workflows/depsreview.yaml +++ b/.github/workflows/depsreview.yaml @@ -1,3 +1,7 @@ +# Copyright © 2023 KubeCub open source community. All rights reserved. +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + name: dependency-review on: [pull_request] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 669e626..cac6c74 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,19 +1,27 @@ +# Copyright © 2023 KubeCub open source community. All rights reserved. +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + name: github labels syncer release on: push: - # run only against tags + branches: + - 'main' tags: - - '*' + - 'v*' permissions: contents: write packages: write issues: write + id-token: write jobs: goreleaser: runs-on: ubuntu-latest + env: + DOCKER_CLI_EXPERIMENTAL: "enabled" steps: - uses: actions/checkout@v3 with: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 093a358..4c2d65b 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,17 +1,31 @@ -# This is an example .goreleaser.yml file with some sensible defaults. -# Make sure to check the documentation at https://goreleaser.com +# Copyright © 2023 KubeCub open source community. All rights reserved. +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + before: hooks: # You may remove this if you don't use go modules. - - go mod tidy + - make tidy + - make copyright-add # you may remove this if you don't need go generate - - go generate ./... + - make generate # The lines beneath this are called `modelines`. See `:help modeline` # Feel free to remove those if you don't want/use them. # yaml-language-server: $schema=https://goreleaser.com/static/schema.json # vim: set ts=2 sw=2 tw=0 fo=cnqoj +snapshot: + name_template: "{{ incpatch .Version }}-next" + +gomod: + proxy: true + +report_sizes: true + +metadata: + mod_timestamp: "{{ .CommitTimestamp }}" + # Default: './dist' dist: _output/dist diff --git a/cmd/exporter/main.go b/cmd/exporter/main.go index 89c2e33..7c801af 100644 --- a/cmd/exporter/main.go +++ b/cmd/exporter/main.go @@ -48,7 +48,6 @@ var ( ) func main() { - exporters := exporter.Labels{} // var exporters exporter.LabelsToObject if buildInfo, available := debug.ReadBuildInfo(); available { @@ -77,7 +76,7 @@ func main() { log.Fatal(err) } if *file != "" { - err = os.WriteFile(*file, b, 0644) + err = os.WriteFile(*file, b, 0o644) if err != nil { log.Fatal(err) } @@ -94,7 +93,7 @@ func main() { log.Fatal(err) } if *file != "" { - err = os.WriteFile(*file, b, 0644) + err = os.WriteFile(*file, b, 0o644) if err != nil { log.Fatal(err) } @@ -111,7 +110,7 @@ func main() { log.Fatal(err) } if *file != "" { - err = os.WriteFile(*file, b, 0644) + err = os.WriteFile(*file, b, 0o644) if err != nil { log.Fatal(err) } @@ -128,7 +127,7 @@ func main() { log.Fatal(err) } if *file != "" { - err = os.WriteFile(*file, b, 0644) + err = os.WriteFile(*file, b, 0o644) if err != nil { log.Fatal(err) } @@ -165,5 +164,4 @@ func main() { fmt.Println(string(b)) return } - } diff --git a/cmd/syncer/.goreleaser.yaml b/cmd/syncer/.goreleaser.yaml index a65edfe..ea5dcca 100644 --- a/cmd/syncer/.goreleaser.yaml +++ b/cmd/syncer/.goreleaser.yaml @@ -1,3 +1,7 @@ +# Copyright © 2023 KubeCub open source community. All rights reserved. +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + # This is an example .goreleaser.yml file with some sensible defaults. # Make sure to check the documentation at https://goreleaser.com before: diff --git a/internal/utils/term/term_writer.go b/internal/utils/term/term_writer.go index dcc9d36..c5d6a3c 100644 --- a/internal/utils/term/term_writer.go +++ b/internal/utils/term/term_writer.go @@ -20,9 +20,11 @@ type wordWrapWriter struct { // NewResponsiveWriter creates a Writer that detects the column width of the // terminal we are in, and adjusts every line width to fit and use recommended // terminal sizes for better readability. Does proper word wrapping automatically. -// if terminal width >= 120 columns use 120 columns -// if terminal width >= 100 columns use 100 columns -// if terminal width >= 80 columns use 80 columns +// +// if terminal width >= 120 columns use 120 columns +// if terminal width >= 100 columns use 100 columns +// if terminal width >= 80 columns use 80 columns +// // In case we're not in a terminal or if it's smaller than 80 columns width, // doesn't do any wrapping. func NewResponsiveWriter(w io.Writer) io.Writer { diff --git a/labels-templates/go-project-layout-xml.xml b/labels-templates/go-project-layout-xml.xml index 918219d..75e1cb7 100644 --- a/labels-templates/go-project-layout-xml.xml +++ b/labels-templates/go-project-layout-xml.xml @@ -1,3 +1,9 @@ + +