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
31 changes: 31 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
root = true

[*]
charset = utf-8

end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

indent_style = tab
indent_size = 4
tab_width = 4

[*.go]

[*.json]
indent_style = space
indent_size = 2
trim_trailing_whitespace = false

[{*.yml,*.yaml,*.toml}]
indent_style = space
indent_size = 2

[*.sql]
indent_style = space
indent_size = 4

[*.md]
indent_style = space
indent_size = 2
45 changes: 45 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: 2
updates:
# Go modules
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
time: "10:00"
timezone: "Asia/Tokyo"
cooldown:
default-days: 3
open-pull-requests-limit: 10
labels:
- "dependencies"
- "go"
commit-message:
prefix: "chore"
include: "scope"
groups:
all:
patterns:
- "*"

# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
time: "10:00"
timezone: "Asia/Tokyo"
cooldown:
default-days: 3
open-pull-requests-limit: 10
labels:
- "dependencies"
- "github-actions"
commit-message:
prefix: "chore"
include: "scope"
groups:
all:
patterns:
- "*"
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
check:
name: check
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Set up Go
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version-file: 'go.mod'

- name: Install dependencies
run: go mod download

- name: Install go-task
uses: go-task/setup-task@0ab1b2a65bc55236a3bc64cde78f80e20e8885c2 # v1.0.0

- name: Build
run: go build -v ./cmd/goose

- name: Run linter
run: task lint

- name: Run vuln check
run: task vuln
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Set up Go
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version-file: 'go.mod'

- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Build binaries
run: |
mkdir -p dist

# linux/amd64
GOOS=linux GOARCH=amd64 go build -o dist/goose-linux-amd64 -ldflags="-s -w -X main.version=${{ steps.get_version.outputs.VERSION }}" ./cmd/goose
tar czf dist/goose-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz -C dist goose-linux-amd64

# linux/arm64
GOOS=linux GOARCH=arm64 go build -o dist/goose-linux-arm64 -ldflags="-s -w -X main.version=${{ steps.get_version.outputs.VERSION }}" ./cmd/goose
tar czf dist/goose-${{ steps.get_version.outputs.VERSION }}-linux-arm64.tar.gz -C dist goose-linux-arm64

# darwin/amd64
GOOS=darwin GOARCH=amd64 go build -o dist/goose-darwin-amd64 -ldflags="-s -w -X main.version=${{ steps.get_version.outputs.VERSION }}" ./cmd/goose
tar czf dist/goose-${{ steps.get_version.outputs.VERSION }}-darwin-amd64.tar.gz -C dist goose-darwin-amd64

# darwin/arm64
GOOS=darwin GOARCH=arm64 go build -o dist/goose-darwin-arm64 -ldflags="-s -w -X main.version=${{ steps.get_version.outputs.VERSION }}" ./cmd/goose
tar czf dist/goose-${{ steps.get_version.outputs.VERSION }}-darwin-arm64.tar.gz -C dist goose-darwin-arm64

# windows/amd64
GOOS=windows GOARCH=amd64 go build -o dist/goose-windows-amd64.exe -ldflags="-s -w -X main.version=${{ steps.get_version.outputs.VERSION }}" ./cmd/goose
zip -j dist/goose-${{ steps.get_version.outputs.VERSION }}-windows-amd64.zip dist/goose-windows-amd64.exe

# windows/arm64
GOOS=windows GOARCH=arm64 go build -o dist/goose-windows-arm64.exe -ldflags="-s -w -X main.version=${{ steps.get_version.outputs.VERSION }}" ./cmd/goose
zip -j dist/goose-${{ steps.get_version.outputs.VERSION }}-windows-arm64.zip dist/goose-windows-arm64.exe

- name: Generate checksums
run: |
cd dist
sha256sum *.tar.gz *.zip > checksums.txt

- name: Create Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
files: |
dist/*.tar.gz
dist/*.zip
dist/checksums.txt
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ go.work.sum
# Editor/IDE
# .idea/
# .vscode/

# Build output
bin/
128 changes: 128 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
version: '2'
run:
modules-download-mode: readonly
relative-path-mode: gomod

linters:
exclusions:
rules:
# Even after correction, it still detects false positives.
- source: "log.Fatalf\\(\"goose run: %v\", err\\)"
linters:
- gocritic
enable:
- copyloopvar
- dogsled
- gocognit
- misspell
- unconvert
- whitespace
- gocritic
- gocyclo
- dupl
# - lll
# - revive
# - asasalint
# - asciicheck
# - bidichk
# - bodyclose
# - canonicalheader
# - containedctx
# - contextcheck
# - cyclop
# - decorder
# - depguard
# - dupword
# - durationcheck
# - err113
# - errcheck
# - errchkjson
# - errname
# - errorlint
# - exhaustive
# - exhaustruct
# - exptostd
# - fatcontext
# - forbidigo
# - forcetypeassert
# - funlen
# - ginkgolinter
# - gocheckcompilerdirectives
# - gochecknoglobals
# - gochecknoinits
# - gochecksumtype
# - goconst
# - godot
# - godox
# - goheader
# - gomoddirectives
# - gomodguard
# - goprintffuncname
# - gosec
# - gosmopolitan
# - govet
# - grouper
# - iface
# - importas
# - inamedparam
# - ineffassign
# - interfacebloat
# - intrange
# - ireturn
# - lll
# - loggercheck
# - maintidx
# - makezero
# - mirror
# - mnd
# - musttag
# - nakedret
# - nestif
# - nilerr
# - nilnesserr
# - nilnil
# - nlreturn
# - noctx
# - nolintlint
# - nonamedreturns
# - nosprintfhostport
# - paralleltest
# - perfsprint
# - prealloc
# - predeclared
# - promlinter
# - protogetter
# - reassign
# - recvcheck
# - revive
# - rowserrcheck
# - sloglint
# - spancheck
# - sqlclosecheck
# - staticcheck
# - tagalign
# - tagliatelle
# - testableexamples
# - testifylint
# - testpackage
# - thelper
# - tparallel
# - unparam
# - unused
# - usestdlibvars
# - usetesting
# - varnamelen
# - wastedassign
# - wrapcheck
# - wsl
# - zerologlint
- staticcheck
# disable:

formatters:
enable:
- goimports
# - gci
# - gofmt
# - gofumpt
# - golines
17 changes: 17 additions & 0 deletions .yamlfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# https://github.com/google/yamlfmt/blob/v0.9.0/docs/config-file.md#configuration
line_ending: 'lf'
doublestar: true
include:
- '.github/**/*.{yaml,yml}'
- './.yamlfmt'
- './*.{yaml,yml}'

formatter:
type: basic
# https://github.com/google/yamlfmt/blob/v0.9.0/docs/config-file.md#basic-formatter
indent: 2
retain_line_breaks: true
max_line_length: 0
scan_folded_as_literal: true
drop_merge_tag: true
pad_line_comments: 1
Loading