Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: latest
args: --timeout=5m

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true

- name: Run tests
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...

- name: Upload coverage
uses: codecov/codecov-action@v5
with:
files: coverage.out
fail_ci_if_error: false

build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
exclude:
- goos: windows
goarch: arm64
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true

- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build -ldflags="-s -w" -o azswitch-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} ./cmd/azswitch

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: azswitch-${{ matrix.goos }}-${{ matrix.goarch }}
path: azswitch-${{ matrix.goos }}-${{ matrix.goarch }}*
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

permissions:
contents: write
packages: write

jobs:
goreleaser:
name: GoReleaser
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
cache: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Build output
/bin/
/dist/

# Test binary
*.test

# Coverage reports
/coverage/

# Dependency directories
vendor/

# Go workspace file
go.work

# IDE
.idea/
.vscode/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Debug
debug.log
75 changes: 75 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
version: "2"
run:
issues-exit-code: 1
linters:
enable:
- gocritic
- misspell
- revive
- unconvert
settings:
gocritic:
disabled-checks:
- hugeParam
enabled-tags:
- diagnostic
- style
- performance
misspell:
locale: US
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- errcheck
- gocritic
path: _test\.go
paths:
- third_party$
- builtin$
- examples$
issues:
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
simplify: true
goimports:
local-prefixes:
- github.com/l2D/azswitch
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
127 changes: 127 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
version: 2

before:
hooks:
- go mod tidy

builds:
- id: azswitch
main: ./cmd/azswitch
binary: azswitch
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
ldflags:
- -s -w
- -X github.com/l2D/azswitch/internal/version.Version={{.Version}}
- -X github.com/l2D/azswitch/internal/version.CommitSHA={{.Commit}}
- -X github.com/l2D/azswitch/internal/version.BuildTime={{.Date}}

archives:
- id: default
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
format: tar.gz
format_overrides:
- goos: windows
format: zip
files:
- LICENSE
- README.md

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: '{{ incpatch .Version }}-next'

changelog:
sort: desc
use: github
groups:
- title: Features
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 0
- title: Bug Fixes
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 1
- title: Performance Improvements
regexp: '^.*?perf(\([[:word:]]+\))??!?:.+$'
order: 2
- title: Documentation
regexp: '^.*?docs(\([[:word:]]+\))??!?:.+$'
order: 3
- title: Others
order: 999
filters:
exclude:
- '^style:'
- '^chore:'
- '^ci:'

release:
github:
owner: l2D
name: azswitch
draft: false
prerelease: auto
footer: |
## Docker Image
```
docker pull ghcr.io/l2d/azswitch:{{ .Tag }}
```

## Quick Install
```bash
# Go install
go install github.com/l2D/azswitch/cmd/azswitch@{{ .Tag }}
```

dockers:
- image_templates:
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-amd64'
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- '--pull'
- '--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.source={{.GitURL}}'
goarch: amd64

- image_templates:
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-arm64'
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- '--pull'
- '--platform=linux/arm64'
- '--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.source={{.GitURL}}'
goarch: arm64

docker_manifests:
- name_template: 'ghcr.io/l2d/azswitch:{{ .Tag }}'
image_templates:
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-amd64'
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-arm64'

- name_template: 'ghcr.io/l2d/azswitch:latest'
image_templates:
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-amd64'
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-arm64'
10 changes: 10 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tools]
act = "0.2.84"
actionlint = "1.7.10"
azure-cli = "2.82.0"
gitleaks = "8.24.3"
go = "1.25.6"
golangci-lint = "2.8.0"
pre-commit = "4.5.1"
trivy = "0.68.2"
yamlfmt = "0.21.0"
Loading