diff --git a/.commitlintrc.json b/.commitlintrc.json new file mode 100644 index 0000000..64af300 --- /dev/null +++ b/.commitlintrc.json @@ -0,0 +1,46 @@ +{ + "rules": { + "type-enum": [ + 2, + "always", + [ + "chore", + "ci", + "deps", + "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", + 120 + ] + } +} \ No newline at end of file diff --git a/.cruft.json b/.cruft.json new file mode 100644 index 0000000..77caae5 --- /dev/null +++ b/.cruft.json @@ -0,0 +1,19 @@ +{ + "template": "https://github.com/mirceanton/repository-templates", + "commit": "3d3e42bb4fbe8a10583e3ba1f4d2bf8d33689d36", + "checkout": null, + "context": { + "cookiecutter": { + "project_name": "talswitcher", + "repo_name": "talswitcher", + "project_description": "A simple tool to help manage multiple talosconfig files.", + "author": "Mircea-Pavel Anton", + "go_version": "1.23.0", + "_copy_without_render": [ + ".github/*" + ], + "_template": "https://github.com/mirceanton/repository-templates" + } + }, + "directory": "golang" +} diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..e8fd1d2 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,32 @@ +## ================================================================================================ +# Utility versions +## ================================================================================================ +ARG TASKFILE_VERSION=v3.38.0@sha256:308c4f5be86bffae3f956cbd7225c4fec69b0e7a89012120b818a10df45d7c59 +ARG GOLINT_VERSION=v1.61.0-alpine@sha256:61e2d68adc792393fcb600340fe5c28059638d813869d5b4c9502392a2fb4c96 +ARG GORELEASER_VERSION=v2.3.2@sha256:d62b4a18dfe3af7bd4da9e5954b496548ef04e73ae8f98cd75ba63a9ed4d73e5 + + +## ================================================================================================ +# "Build" stage for utilities with docker images already present +## ================================================================================================ +FROM ghcr.io/mirceanton/taskfile:${TASKFILE_VERSION} AS taskfile +FROM golangci/golangci-lint:${GOLINT_VERSION} AS golangci-lint +FROM goreleaser/goreleaser:${GORELEASER_VERSION} AS goreleaser + + +## ================================================================================================ +## Main image +## ================================================================================================ +FROM mcr.microsoft.com/devcontainers/go:1.23-bookworm@sha256:089dc0f3ae6e3a07b0896c28c0bde042fbb1e31fe87908ca55f32e37f56ff0c6 AS workspace + +# Install additional tools +COPY --from=taskfile /task /usr/local/bin/task +COPY --from=golangci-lint /usr/bin/golangci-lint /usr/local/bin/golangci-lint +COPY --from=goreleaser /usr/bin/goreleaser /usr/local/bin/goreleaser + +# Generate bash completions +RUN golangci-lint completion bash | sudo tee /etc/bash_completion.d/golangci-lint.bash > /dev/null +RUN goreleaser completion bash | sudo tee /etc/bash_completion.d/goreleaser.bash > /dev/null + +USER vscode +ENTRYPOINT [ "/bin/bash", "-l", "-c" ] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..75b24e0 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,13 @@ +{ + "name": "talswitcher", + "build": { + "dockerfile": "Dockerfile" + }, + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + "remoteUser": "vscode", + "containerUser": "vscode", + "updateRemoteUserUID": true +} \ No newline at end of file diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..0d92fe0 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @mircea-pavel-anton \ No newline at end of file diff --git a/.github/labeler.yaml b/.github/labeler.yaml new file mode 100644 index 0000000..b0c5ced --- /dev/null +++ b/.github/labeler.yaml @@ -0,0 +1,18 @@ +--- +area/docker: + - changed-files: + - any-glob-to-any-file: ".dockerignore" + - any-glob-to-any-file: "Dockerfile" + - any-glob-to-any-file: ".devcontainer/devcontainer.json" + +area/github: + - changed-files: + - any-glob-to-any-file: ".github/**/*" + +area/go: + - changed-files: + - any-glob-to-any-file: "cmd/**/*" + - any-glob-to-any-file: "internal/**/*" + - any-glob-to-any-file: "pkg/**/*" + - any-glob-to-any-file: "go.mod" + - any-glob-to-any-file: "go.sum" diff --git a/.github/labels.yaml b/.github/labels.yaml new file mode 100644 index 0000000..b3460f3 --- /dev/null +++ b/.github/labels.yaml @@ -0,0 +1,58 @@ +--- +# ================================================================================================= +# Areas +# ================================================================================================= +- name: area/docker + color: "3970E4" +- name: area/github + color: "000000" +- name: area/go + color: "844FBA" + +# ================================================================================================= +# Renovate Types +# ================================================================================================= +- name: renovate/go + color: "844FBA" +- name: renovate/container + color: "3970E4" +- name: renovate/github-action + color: "000000" + +# ================================================================================================= +# Semantic Types +# ================================================================================================= +- name: type/digest + color: "ffeC19" +- name: type/patch + color: "ffeC19" +- name: type/minor + color: "ff9800" +- name: type/major + color: "f6412d" + +# ================================================================================================= +# Size Types +# ================================================================================================= +- name: size/XS + color: "0000ff" +- name: size/S + color: "000ff0" +- name: size/M + color: "00ff00" +- name: size/L + color: "0ff000" +- name: size/XL + color: "ff0000" +- name: size/XXL + color: "ff00ff" + +# ================================================================================================= +# Issue Types +# ================================================================================================= +- name: issue/bug + color: "ff0000" +- name: issue/feature + color: "00ff00" +- name: issue/chore + color: "0000ff" diff --git a/.github/workflows/cruft-sync.yaml b/.github/workflows/cruft-sync.yaml new file mode 100644 index 0000000..9fece92 --- /dev/null +++ b/.github/workflows/cruft-sync.yaml @@ -0,0 +1,106 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Cruft Sync + +on: + # Manual Trigger + workflow_dispatch: {} + + # "Wet" Run hourly + schedule: + - cron: "0 * * * *" + +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Setup Python + uses: actions/setup-python@v5.2.0 + with: + python-version: "3.12" + + - name: Install Cruft + run: pip3 install cruft + + - name: Generate Token + uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0 + id: app-token + with: + app-id: "${{ secrets.BOT_APP_ID }}" + private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" + + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + fetch-depth: 0 + token: "${{ steps.app-token.outputs.token }}" + + - name: Check if the `cruft_update` branch already exists + id: check-branch + run: | + if git ls-remote --exit-code --heads origin cruft_update; then + echo "branch_exists=true" | tee "$GITHUB_OUTPUT" + else + echo "branch_exists=false" | tee "$GITHUB_OUTPUT" + fi + + - name: Create the `cruft_update` branch + if: steps.check-branch.outputs.branch_exists == 'false' + run: git branch cruft_update + + - name: Switch to the `cruft_update` branch + run: git switch cruft_update + + - name: Check if a cruft update is available + id: check-cruft + run: | + if ! cruft check; then + echo "has_changes=true" | tee "$GITHUB_OUTPUT" + else + echo "has_changes=false" | tee "$GITHUB_OUTPUT" + fi + + - name: Apply cruft update + if: steps.check-cruft.outputs.has_changes == 'true' + run: | + cruft update --skip-apply-ask --refresh-private-variables + git restore --staged . + + - name: Configure Git User + if: steps.check-cruft.outputs.has_changes == 'true' + run: | + git config --global user.email "mr.borboto@noreply.mirceanton.com" + git config --global user.name "Mr. Borboto" + + - name: Commit and push changes + if: steps.check-cruft.outputs.has_changes == 'true' + run: | + git add -A + git commit -m "chore(cruft): apply template updates" + git push --set-upstream origin cruft_update + + - name: Check if a pull request already exists + id: check-pr + env: + GH_TOKEN: "${{ steps.app-token.outputs.token }}" + run: | + PR_EXISTS=$(gh pr list --head cruft_update --json number | jq '. | length > 0') + echo "pr_exists=$PR_EXISTS" | tee "$GITHUB_OUTPUT" + + - name: Compare the current branch with the main branch + id: check-changes + run: | + if git diff --quiet origin/main; then + echo "has_changes=false" | tee "$GITHUB_OUTPUT" + else + echo "has_changes=true" | tee "$GITHUB_OUTPUT" + fi + + - name: Create pull request + if: steps.check-pr.outputs.pr_exists == 'false' && steps.check-changes.outputs.has_changes == 'true' + env: + GH_TOKEN: "${{ steps.app-token.outputs.token }}" + run: | + gh pr create \ + --title "chore(cruft): Apply updates from template" \ + --body "This PR adds the changes from the upstream template." diff --git a/.github/workflows/devcontainer-build.yaml b/.github/workflows/devcontainer-build.yaml new file mode 100644 index 0000000..01b819b --- /dev/null +++ b/.github/workflows/devcontainer-build.yaml @@ -0,0 +1,23 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: DevContainer Docker Build + +on: + workflow_dispatch: {} + + pull_request: + paths: + - ".github/workflows/devcontainer-build.yaml" + - ".devcontainer/Dockerfile" + +jobs: + release: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-docker-build-push.yaml@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + secrets: inherit + with: + image: "ghcr.io/${{ github.repository }}-devcontainer" + platforms: linux/amd64 + tags: test + context: ./.devcontainer + dockerfile: ./.devcontainer/Dockerfile + dry-run: true diff --git a/.github/workflows/git-release.yaml b/.github/workflows/git-release.yaml new file mode 100644 index 0000000..dc77c60 --- /dev/null +++ b/.github/workflows/git-release.yaml @@ -0,0 +1,36 @@ +--- +# 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/git-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@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + secrets: inherit + with: + dry-run: ${{ inputs.dry-run || github.event_name == 'pull_request' }} diff --git a/.github/workflows/goreleaser.yaml b/.github/workflows/goreleaser.yaml new file mode 100644 index 0000000..4cdc39e --- /dev/null +++ b/.github/workflows/goreleaser.yaml @@ -0,0 +1,32 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Goreleaser + +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/goreleaser.yaml" + - "go.mod" + - "go.sum" + - "**/**.go" + + # "Wet" Run on any tag push + push: + tags: ["*"] + +jobs: + goreleaser: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-go-release.yaml@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + secrets: inherit + with: + 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..9b09037 --- /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 hourly + schedule: + - cron: "0 * * * *" + +jobs: + label-sync: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-label-sync.yaml@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + 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..eb47004 --- /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@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + 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..6e567d9 --- /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@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + secrets: inherit + + yamllint: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-yamllint.yaml@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + secrets: inherit + with: + yamllint-args: "--config-file=.yamllint.yaml" + + actionlint: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-actionlint.yaml@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + secrets: inherit + + shellcheck: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-shellcheck.yaml@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + secrets: inherit + + markdownlint: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-markdownlint.yaml@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + secrets: inherit + + commitlint: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-commitlint.yaml@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + secrets: inherit diff --git a/.github/workflows/renovate.yaml b/.github/workflows/renovate.yaml new file mode 100644 index 0000000..b8d83e2 --- /dev/null +++ b/.github/workflows/renovate.yaml @@ -0,0 +1,41 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Renovate + +on: + # Manual Trigger + workflow_dispatch: + inputs: + dry-run: + description: Dry Run + 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 + - renovate.json5 + + # "Wet" Run hourly + schedule: + - cron: "0 * * * *" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} + cancel-in-progress: true + +jobs: + renovate: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-renovate.yaml@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + 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/.github/workflows/test-go.yaml b/.github/workflows/test-go.yaml new file mode 100644 index 0000000..e413ee4 --- /dev/null +++ b/.github/workflows/test-go.yaml @@ -0,0 +1,17 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Test Go + +on: + # Manual Trigger + workflow_dispatch: {} + + # Run on any PR + pull_request: {} + +jobs: + test: + uses: mirceanton/reusable-workflows/.github/workflows/reusable-go-test.yaml@b15f79125a97349d2f1043d1556d6e3cebae2227 # v3.4.5 + secrets: inherit + with: + go-version: stable diff --git a/.gitignore b/.gitignore index 3b032a8..f62a5c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ talswitcher -.task/ -dist/ +dist/ \ No newline at end of file diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..f117a47 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json +linters: + enable: + - goimports + - gofmt + - gofumpt diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..94508cd --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,95 @@ +--- +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +version: 2 +project_name: talswitcher + +before: + hooks: + - go mod tidy + - go mod download +builds: + - env: + - CGO_ENABLED=0 + binary: "{{.ProjectName}}" + goos: + - linux + - darwin + ldflags: + - -s -w -X github.com/mirceanton/{{.ProjectName}}/cmd.version={{.Version}} + +archives: + - format: tar.gz + name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}" + +checksum: + disable: false + name_template: "checksums.txt" + +changelog: + disable: false + use: github + sort: asc + groups: + - title: Features + regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' + order: 0 + - title: "Patches" + regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$' + order: 1 + - title: "CI" + regexp: ".*ci.*" + order: 998 + - title: Others + order: 999 + +nfpms: + - homepage: https://github.com/mirceanton/{{.ProjectName}} + maintainer: Mircea-Pavel Anton + description: A simple tool to help manage multiple talosconfig files. + file_name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}" + license: MIT + formats: [deb, apk, rpm] + +dockers: + - image_templates: + - "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-amd64" + use: buildx + dockerfile: Dockerfile + build_flag_templates: + - "--platform=linux/amd64" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.url=https://github.com/mirceanton/{{.ProjectName}}" + - "--label=org.opencontainers.image.source=https://github.com/mirceanton/{{.ProjectName}}" + - "--label=org.opencontainers.image.licenses=MIT" + - "--label=org.opencontainers.image.authors=Mircea-Pavel Anton " + - "--label=org.opencontainers.image.description=A simple tool to help manage multiple talosconfig files." + - image_templates: + - "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-arm64v8" + use: buildx + goarch: arm64 + dockerfile: Dockerfile + build_flag_templates: + - "--platform=linux/arm64/v8" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.url=https://github.com/mirceanton/{{.ProjectName}}" + - "--label=org.opencontainers.image.source=https://github.com/mirceanton/{{.ProjectName}}" + - "--label=org.opencontainers.image.licenses=MIT" + - "--label=org.opencontainers.image.authors=Mircea-Pavel Anton " + - "--label=org.opencontainers.image.description=A simple tool to help manage multiple talosconfig files." + +docker_manifests: + - name_template: "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}" + image_templates: + - "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-amd64" + - "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-arm64v8" + + - name_template: "ghcr.io/mirceanton/{{.ProjectName}}:latest" + image_templates: + - "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-amd64" + - "ghcr.io/mirceanton/{{.ProjectName}}:v{{.Version}}-arm64v8" 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 new file mode 100644 index 0000000..68f320b --- /dev/null +++ b/.releaserc.yaml @@ -0,0 +1,41 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/semantic-release.json +branches: + - master + - main + +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/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..773c6b8 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,17 @@ +{ + "recommendations": [ + "golang.go", + "aaron-bond.better-comments", + "ms-azuretools.vscode-docker", + "davidanson.vscode-markdownlint", + "albert.TabOut", + "mhutchie.git-graph", + "bierner.emojisense", + "redhat.vscode-yaml", + "pkief.material-icon-theme", + "task.vscode-task", + "GitHub.copilot", + "foxundermoon.shell-format", + "DavidAnson.vscode-markdownlint" + ], +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d4b9525 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,69 @@ +{ + "editor.fontFamily": "Cascadia Code", + "editor.fontSize": 14, + "editor.fontLigatures": true, + "editor.cursorBlinking": "phase", + "editor.bracketPairColorization.enabled": true, + "editor.bracketPairColorization.independentColorPoolPerBracketType": true, + "editor.guides.bracketPairs": true, + "editor.guides.bracketPairsHorizontal": true, + "editor.guides.highlightActiveBracketPair": true, + "editor.hover.delay": 500, + "editor.renderWhitespace": "boundary", + "editor.rulers": [ + 150, + 200 + ], + "editor.stickyScroll.enabled": false, + "explorer.autoReveal": false, + "files.associations": { + "**/*.json5": "jsonc" + }, + "files.trimTrailingWhitespace": true, + "editor.formatOnSave": true, + "files.autoSave": "afterDelay", + "files.autoSaveDelay": 1000, + "workbench.iconTheme": "material-icon-theme", + "[json]": { + "editor.defaultFormatter": "vscode.json-language-features", + "editor.insertSpaces": true, + "editor.tabSize": 2, + "editor.quickSuggestions": { + "strings": true + }, + "editor.suggest.insertMode": "replace" + }, + "[yaml]": { + "editor.defaultFormatter": "redhat.vscode-yaml", + "editor.insertSpaces": true, + "editor.tabSize": 2, + "editor.autoIndent": "keep", + "editor.quickSuggestions": { + "other": true, + "comments": false, + "strings": true + } + }, + "[go]": { + "editor.defaultFormatter": "golang.go", + "editor.insertSpaces": false, + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": "always" + } + }, + "[shellscript]": { + "editor.defaultFormatter": "foxundermoon.shell-format", + "files.eol": "\n" + }, + "[markdown]": { + "editor.defaultFormatter": "DavidAnson.vscode-markdownlint", + "editor.wordWrap": "on" + }, + "[dockerfile]": { + "editor.defaultFormatter": "ms-azuretools.vscode-docker", + "editor.quickSuggestions": { + "strings": true + } + } +} \ No newline at end of file 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/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9100bf9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM alpine:3.20.3 +USER 8675:8675 +COPY talswitcher / +ENTRYPOINT ["/talswitcher"] \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..963d782 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Mircea-Pavel Anton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/Taskfile.yaml b/Taskfile.yaml new file mode 100644 index 0000000..dac4b52 --- /dev/null +++ b/Taskfile.yaml @@ -0,0 +1,16 @@ +--- +# yaml-language-server: $schema=https://taskfile.dev/schema.json +version: "3" + +tasks: + build: + desc: Run goreleaser in snapshot mode. + cmd: goreleaser release --snapshot --clean + + test: + desc: Run tests. + cmd: go test -v ./... -race -covermode=atomic + + lint: + desc: Run linter. + cmd: golangci-lint run --fix diff --git a/go.mod b/go.mod index 9c4e04f..6980209 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mirceanton/talswitcher -go 1.22.7 +go 1.23.0 toolchain go1.23.2 diff --git a/renovate.json5 b/renovate.json5 new file mode 100644 index 0000000..7b97669 --- /dev/null +++ b/renovate.json5 @@ -0,0 +1,25 @@ +{ + "$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" + ], + "ignorePaths": [ + // Ignore files managed by cruft. Renovate will update them upstream and cruft will sync them here. + ".github/workflows/cruft-sync.yaml", + ".github/workflows/devcontainer-build.yaml", + ".github/workflows/git-release.yaml", + ".github/workflows/goreleaser.yaml", + ".github/workflows/label-sync.yaml", + ".github/workflows/labeler.yaml", + ".github/workflows/lint.yaml", + ".github/workflows/renovate.yaml", + ".github/workflows/test-go.yaml" + ] +} \ No newline at end of file