diff --git a/.commitlintrc.json b/.commitlintrc.json new file mode 100644 index 0000000..afd3f66 --- /dev/null +++ b/.commitlintrc.json @@ -0,0 +1,45 @@ +{ + "rules": { + "type-enum": [ + 2, + "always", + [ + "chore", + "ci", + "feat", + "fix", + "patch", + "style" + ] + ], + "subject-empty": [ + 2, + "never" + ], + "type-case": [ + 2, + "always", + "lower-case" + ], + "subject-case": [ + 0 + ], + "type-empty": [ + 2, + "never" + ], + "scope-case": [ + 2, + "always", + "lower-case" + ], + "scope-enum": [ + 0 + ], + "header-max-length": [ + 2, + "always", + 100 + ] + } +} \ No newline at end of file diff --git a/.github/configs/renovate/autoMerge.json5 b/.github/configs/renovate/autoMerge.json5 deleted file mode 100644 index 58363dd..0000000 --- a/.github/configs/renovate/autoMerge.json5 +++ /dev/null @@ -1,50 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "packageRules": [ - { - "description": [ - "Auto-merge go updates for minor and patch" - ], - "matchDatasources": [ - "gomod" - ], - "automerge": true, - "automergeType": "pr", - "matchUpdateTypes": [ - "minor", - "patch" - ] - }, - { - "description": [ - "Auto-merge container updates for minor and patch" - ], - "matchDatasources": [ - "docker" - ], - "automerge": true, - "automergeType": "pr", - "matchUpdateTypes": [ - "minor", - "patch" - ] - }, - { - "description": [ - "Auto-merge GitHub Actions for minor and patch" - ], - "matchManagers": [ - "github-actions" - ], - "matchDatasources": [ - "github-tags" - ], - "automerge": true, - "automergeType": "pr", - "matchUpdateTypes": [ - "minor", - "patch" - ] - } - ] -} \ No newline at end of file diff --git a/.github/configs/renovate/labels.json5 b/.github/configs/renovate/labels.json5 deleted file mode 100644 index bc60574..0000000 --- a/.github/configs/renovate/labels.json5 +++ /dev/null @@ -1,53 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "packageRules": [ - { - "matchUpdateTypes": [ - "major" - ], - "labels": [ - "type/major" - ] - }, - { - "matchUpdateTypes": [ - "minor" - ], - "labels": [ - "type/minor" - ] - }, - { - "matchUpdateTypes": [ - "patch" - ], - "labels": [ - "type/patch" - ] - }, - { - "matchDatasources": [ - "docker" - ], - "addLabels": [ - "renovate/container" - ] - }, - { - "matchDatasources": [ - "gomod" - ], - "addLabels": [ - "renovate/go" - ] - }, - { - "matchManagers": [ - "github-actions" - ], - "addLabels": [ - "renovate/github-action" - ] - } - ] -} \ No newline at end of file diff --git a/.github/configs/renovate/semanticCommits.json5 b/.github/configs/renovate/semanticCommits.json5 deleted file mode 100644 index a4c04c1..0000000 --- a/.github/configs/renovate/semanticCommits.json5 +++ /dev/null @@ -1,85 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "packageRules": [ - // ============================================================================================ - // Docker - // ============================================================================================ - { - "matchDatasources": [ - "docker" - ], - "matchUpdateTypes": [ - "major" - ], - "commitMessagePrefix": "deps(container)!: ", - "commitMessageTopic": "{{depName}}", - "commitMessageExtra": " ( {{currentVersion}} → {{newVersion}} )" - }, - { - "matchDatasources": [ - "docker" - ], - "matchUpdateTypes": [ - "minor", - "patch" - ], - "semanticCommitType": "deps", - "semanticCommitScope": "container", - "commitMessageTopic": "{{depName}}", - "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" - }, - // ============================================================================================ - // Golang - // ============================================================================================ - { - "matchDatasources": [ - "gomod" - ], - "matchUpdateTypes": [ - "major" - ], - "commitMessagePrefix": "deps(go)!: ", - "commitMessageTopic": "{{depName}}", - "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" - }, - { - "matchDatasources": [ - "gomod" - ], - "matchUpdateTypes": [ - "minor", - "patch" - ], - "commitMessagePrefix": "deps(go): ", - "commitMessageTopic": "{{depName}}", - "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" - }, - // ============================================================================================ - // GitHub Actions - // ============================================================================================ - { - "matchManagers": [ - "github-actions" - ], - "matchUpdateTypes": [ - "major" - ], - "commitMessagePrefix": "deps(github-actions)!: ", - "commitMessageTopic": "{{depName}}", - "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" - }, - { - "matchManagers": [ - "github-actions" - ], - "matchUpdateTypes": [ - "minor", - "patch" - ], - "semanticCommitType": "deps", - "semanticCommitScope": "github-actions", - "commitMessageTopic": "{{depName}}", - "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" - } - ] -} \ No newline at end of file diff --git a/.github/configs/labeler.yaml b/.github/labeler.yaml similarity index 100% rename from .github/configs/labeler.yaml rename to .github/labeler.yaml diff --git a/.github/configs/labels.yaml b/.github/labels.yaml similarity index 100% rename from .github/configs/labels.yaml rename to .github/labels.yaml diff --git a/.github/renovate.json5 b/.github/renovate.json5 deleted file mode 100644 index b9006b3..0000000 --- a/.github/renovate.json5 +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "dependencyDashboardTitle": "Renovate Dashboard 🤖", - "extends": [ - ":dependencyDashboard", - ":timezone(Europe/Bucharest)", - "config:best-practices", - "docker:enableMajor", - ":disableRateLimiting", - ":semanticCommits", - "github>mirceanton/kube-switcher//.github/configs/renovate/autoMerge.json5", - "github>mirceanton/kube-switcher//.github/configs/renovate/semanticCommits.json5", - "github>mirceanton/kube-switcher//.github/configs/renovate/labels.json5" - ] -} \ No newline at end of file diff --git a/.github/workflows/devcontainer-build.yaml b/.github/workflows/devcontainer-build.yaml index 691d6ae..135278d 100644 --- a/.github/workflows/devcontainer-build.yaml +++ b/.github/workflows/devcontainer-build.yaml @@ -12,10 +12,10 @@ on: jobs: release: - uses: mirceanton/reusable-workflows/.github/workflows/docker-release.yaml@17d8ef4df857d93b905170956fbbcd56b296e8bb + uses: mirceanton/reusable-workflows/.github/workflows/reusable-docker-build-push.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 secrets: inherit with: - image: "ghcr.io/${{ github.repository }}-devcontainer" + image: "ghcr.io/mirceanton/kube-switcher-devcontainer" platforms: linux/amd64 tags: test context: ./.devcontainer diff --git a/.github/workflows/git-release.yaml b/.github/workflows/git-release.yaml deleted file mode 100644 index a1eb860..0000000 --- a/.github/workflows/git-release.yaml +++ /dev/null @@ -1,35 +0,0 @@ ---- -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: Git Release - -on: - workflow_dispatch: - inputs: - dry-run: - description: "Dry Run" - required: false - default: false - type: boolean - - pull_request: - paths: - - ".github/workflows/git-release.yaml" - - "cmd/**" - - "go.mod" - - "go.sum" - - "main.go" - - push: - branches: ["main"] - paths: - - "cmd/**" - - "go.mod" - - "go.sum" - - "main.go" - -jobs: - release: - uses: mirceanton/reusable-workflows/.github/workflows/git-release-semver.yaml@17d8ef4df857d93b905170956fbbcd56b296e8bb - secrets: inherit - with: - dry-run: ${{ inputs.dry-run || github.event_name == 'pull_request' }} diff --git a/.github/workflows/go-lint.yaml b/.github/workflows/go-lint.yaml deleted file mode 100644 index 218e957..0000000 --- a/.github/workflows/go-lint.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: Go Lint - -on: - workflow_dispatch: {} - - pull_request: - paths: - - ".github/workflows/go-lint.yaml" - - ".golangci.yaml" - - "go.mod" - - "go.sum" - - "cmd/**" - -jobs: - golangci-lint: - uses: mirceanton/reusable-workflows/.github/workflows/go-lint.yaml@17d8ef4df857d93b905170956fbbcd56b296e8bb - secrets: inherit - with: - go-version: "1.22.5" - golangci-version: "v1.60.3" diff --git a/.github/workflows/go-release.yaml b/.github/workflows/go-release.yaml deleted file mode 100644 index 787280f..0000000 --- a/.github/workflows/go-release.yaml +++ /dev/null @@ -1,32 +0,0 @@ ---- -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: Go Release - -on: - workflow_dispatch: - inputs: - dry-run: - description: "Dry Run" - default: false - required: false - type: boolean - - push: - tags: ["*"] - - pull_request: - paths: - - ".github/workflows/go-release.yaml" - - ".goreleaser.yaml" - - "go.mod" - - "go.sum" - - "cmd/**" - -jobs: - goreleaser: - uses: mirceanton/reusable-workflows/.github/workflows/go-release.yaml@17d8ef4df857d93b905170956fbbcd56b296e8bb - secrets: inherit - with: - go-version: "1.22.5" - goreleaser-version: "v2.2.0" - dry-run: ${{ inputs.dry-run || github.event_name == 'pull_request' }} diff --git a/.github/workflows/label-sync.yaml b/.github/workflows/label-sync.yaml new file mode 100644 index 0000000..9385d2b --- /dev/null +++ b/.github/workflows/label-sync.yaml @@ -0,0 +1,38 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Label Sync + +on: + # Manual Trigger + workflow_dispatch: + inputs: + dry-run: + description: Dry Run + default: true + required: false + type: boolean + + # Dry Run on any PR that changes the labels config or the workflow + pull_request: + paths: + - .github/workflows/label-sync.yaml + - .github/labels.yaml + + # "Wet" Run on any push to the main branch that changes the labels config or the workflow + push: + branches: ["main", "master"] + paths: + - .github/workflows/label-sync.yaml + - .github/labels.yaml + + # "Wet" Run daily hourly + schedule: + - cron: "0 * * * *" + +jobs: + label-sync: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-label-sync.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 + secrets: inherit + with: + dry-run: ${{ inputs.dry-run || github.event_name == 'pull_request' }} + config-file: .github/labels.yaml diff --git a/.github/workflows/labeler.yaml b/.github/workflows/labeler.yaml new file mode 100644 index 0000000..9fddf93 --- /dev/null +++ b/.github/workflows/labeler.yaml @@ -0,0 +1,13 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Labeler + +on: + pull_request_target: {} + +jobs: + pr-labeler: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-labeler.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 + secrets: inherit + with: + config-file: .github/labeler.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..c0e8d1d --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,37 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Lint + +on: + # Manual Trigger + workflow_dispatch: {} + + # Run on any PR + pull_request: {} + +jobs: + golangci-lint: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-go-lint.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 + secrets: inherit + + yamllint: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-yamllint.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 + secrets: inherit + with: + yamllint-args: "--config-file=.yamllint.yaml" + + actionlint: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-actionlint.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 + secrets: inherit + + shellcheck: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-shellcheck.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 + secrets: inherit + + markdownlint: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-markdownlint.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 + secrets: inherit + + commitlint: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-commitlint.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 + secrets: inherit diff --git a/.github/workflows/meta-label-sync.yaml b/.github/workflows/meta-label-sync.yaml deleted file mode 100644 index 2db931a..0000000 --- a/.github/workflows/meta-label-sync.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: Meta - Label Sync - -on: - workflow_dispatch: - inputs: - dry-run: - description: "Dry Run" - default: true - required: false - type: boolean - - pull_request: - paths: - - ".github/configs/labels.yaml" - - ".github/workflows/meta-label-sync.yaml" - - push: - branches: ["main"] - paths: - - ".github/configs/labels.yaml" - - ".github/workflows/meta-label-sync.yaml" - - schedule: - - cron: "0 0 * * *" # Every day at midnight - -jobs: - label-sync: - uses: mirceanton/reusable-workflows/.github/workflows/meta-label-sync.yaml@17d8ef4df857d93b905170956fbbcd56b296e8bb - secrets: inherit - with: - dry-run: ${{ inputs.dry-run || github.event_name == 'pull_request' }} - config-file: ".github/configs/labels.yaml" diff --git a/.github/workflows/meta-labeler.yaml b/.github/workflows/meta-labeler.yaml deleted file mode 100644 index 0957c74..0000000 --- a/.github/workflows/meta-labeler.yaml +++ /dev/null @@ -1,13 +0,0 @@ ---- -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: Meta - Labeler - -on: - pull_request_target: {} - -jobs: - pr-labeler: - uses: mirceanton/reusable-workflows/.github/workflows/meta-labeler.yaml@17d8ef4df857d93b905170956fbbcd56b296e8bb - secrets: inherit - with: - config-file: ".github/configs/labeler.yaml" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..15cb278 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,43 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Release + +on: + # Manual Trigger + workflow_dispatch: + inputs: + dry-run: + description: Dry Run + required: false + default: false + type: boolean + + # Dry Run on any PR that changes this pipeline or that should ultimately trigger a release when merged + pull_request: + paths: + - ".github/workflows/release.yaml" + - "go.mod" + - "go.sum" + - "**/**.go" + + # "Wet" Run on any push to the main branch that modified a go-related file + push: + branches: ["main", "master"] + paths: + - "go.mod" + - "go.sum" + - "**/**.go" + +jobs: + git: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-release-semver.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 + secrets: inherit + with: + dry-run: ${{ inputs.dry-run || github.event_name == 'pull_request' }} + + goreleaser: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-go-release.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 + needs: [git] + secrets: inherit + with: + dry-run: ${{ inputs.dry-run || github.event_name == 'pull_request' }} diff --git a/.github/workflows/renovate.yaml b/.github/workflows/renovate.yaml index 9990d4c..0a14bcc 100644 --- a/.github/workflows/renovate.yaml +++ b/.github/workflows/renovate.yaml @@ -3,23 +3,29 @@ name: Renovate on: + # Manual Trigger workflow_dispatch: inputs: dry-run: description: Dry Run - default: "false" + default: false required: false + type: boolean log-level: description: Log Level default: debug required: false + type: string + + # Dry Run on any PR that changes the renovate config or the renovate workflow pull_request: paths: - - ".github/workflows/renovate.yaml" - - ".github/configs/renovate/*.json5" - - "renovate.json5" + - .github/workflows/renovate.yaml + - renovate.json5 + + # "Wet" Run hourly schedule: - - cron: "0 * * * *" # hourly + - cron: "0 * * * *" concurrency: group: ${{ github.workflow }}-${{ github.event.number || github.ref }} @@ -27,8 +33,9 @@ concurrency: jobs: renovate: - uses: mirceanton/reusable-workflows/.github/workflows/renovate.yaml@17d8ef4df857d93b905170956fbbcd56b296e8bb + uses: mirceanton/reusable-workflows/.github/workflows/reusable-renovate.yaml@df1ea2563affc3e30cc8a5e4b4f75a495e5e89a3 # v3.4.4 secrets: inherit with: dry-run: "${{ inputs.dry-run == true || github.event_name == 'pull_request' }}" log-level: "${{ inputs.log-level || 'debug' }}" + config-file: "renovate.json5" diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..05df305 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,5 @@ +--- +default: true +MD013: false # Ignore long lines +MD033: false # Ignore inline HTML +MD041: false # Ignore images without alt tags diff --git a/.releaserc.yaml b/.releaserc.yaml index 6f522a2..68f320b 100644 --- a/.releaserc.yaml +++ b/.releaserc.yaml @@ -8,3 +8,34 @@ plugins: - "@semantic-release/commit-analyzer" - "@semantic-release/release-notes-generator" - "@semantic-release/github" + +preset: "angular" + +releaseRules: + - type: "feat" + release: "minor" + - type: "feat" + breaking: true + release: "major" + - type: "fix" + release: "patch" + - type: "fix" + breaking: true + release: "major" + - type: "patch" + release: "patch" + - type: "patch" + breaking: true + release: "major" + - type: "chore" + release: false + - type: "ci" + release: false + - type: "style" + release: false + +parserOpts: + noteKeywords: + - "BREAKING" + - "BREAKING CHANGE" + - "BREAKING CHANGES" diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..9ad7120 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,24 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/yamllint.json +extends: default + +rules: + comments: + min-spaces-from-content: 1 + + line-length: + max: 150 + + braces: + level: warning + max-spaces-inside: 1 + + brackets: + level: warning + max-spaces-inside: 1 + + # Ignore truthy for github workflows due to dummy trigger on the + # 'on:' clause + truthy: + ignore: + - .github/workflows diff --git a/renovate.json5 b/renovate.json5 new file mode 100644 index 0000000..09a36a7 --- /dev/null +++ b/renovate.json5 @@ -0,0 +1,13 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "dependencyDashboardTitle": "Renovate Dashboard 🤖", + "extends": [ + ":dependencyDashboard", + "config:best-practices", + ":disableRateLimiting", + ":semanticCommits", + "github>mirceanton/renovate-config//labels/all.json5", + "github>mirceanton/renovate-config//semantic-commits/all.json5", + "github>mirceanton/renovate-config//custom-managers/regex-yaml.json5", + ] +} \ No newline at end of file