mirror of
https://github.com/khorevaa/go-app-template.git
synced 2025-05-31 22:29:32 +02:00
first init
This commit is contained in:
commit
353a7a8ade
44
.github/workflows/releaser.yaml
vendored
Normal file
44
.github/workflows/releaser.yaml
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
name: goreleaser
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
jobs:
|
||||||
|
goreleaser:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
-
|
||||||
|
name: Set up Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.16
|
||||||
|
-
|
||||||
|
name: Docker Login
|
||||||
|
if: success() && startsWith(github.ref, 'refs/tags/v')
|
||||||
|
env:
|
||||||
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
|
run: |
|
||||||
|
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
|
||||||
|
echo "${GITHUB_TOKEN}" | docker login ghcr.io --username $GITHUB_ACTOR --password-stdin
|
||||||
|
-
|
||||||
|
name: Run GoReleaser
|
||||||
|
uses: goreleaser/goreleaser-action@v2
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
args: release --rm-dist
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Clear
|
||||||
|
if: always() && startsWith(github.ref, 'refs/tags/v')
|
||||||
|
run: |
|
||||||
|
rm -f ${HOME}/.docker/config.json
|
22
.github/workflows/test.yml
vendored
Normal file
22
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
on: [push, pull_request]
|
||||||
|
name: Test
|
||||||
|
jobs:
|
||||||
|
Build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version: [1.16.x]
|
||||||
|
platform: [ubuntu-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go-version }}
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup modules
|
||||||
|
run: |
|
||||||
|
go mod tidy
|
||||||
|
- name: Run Test
|
||||||
|
run: |
|
||||||
|
go test -race
|
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
*.exe
|
||||||
|
*.gz
|
||||||
|
*.zip
|
||||||
|
|
||||||
|
|
||||||
|
dist
|
||||||
|
.idea
|
||||||
|
*.logs
|
||||||
|
|
66
.goreleaser.yaml
Normal file
66
.goreleaser.yaml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
project_name: app-template
|
||||||
|
|
||||||
|
env:
|
||||||
|
- GO111MODULE=on
|
||||||
|
# - GOPROXY=https://goproxy.io
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy
|
||||||
|
builds:
|
||||||
|
- env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
- darwin
|
||||||
|
- windows
|
||||||
|
goarch:
|
||||||
|
# - 386
|
||||||
|
- amd64
|
||||||
|
# - arm
|
||||||
|
# - arm64
|
||||||
|
dist: dist
|
||||||
|
|
||||||
|
checksum:
|
||||||
|
name_template: '{{ .ProjectName }}_checksums.txt'
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- '^docs:'
|
||||||
|
- '^test:'
|
||||||
|
- Merge pull request
|
||||||
|
- Merge branch
|
||||||
|
dockers:
|
||||||
|
- image_templates:
|
||||||
|
- 'khorevaa/{{.ProjectName}}:{{ .Tag }}'
|
||||||
|
- 'khorevaa/{{.ProjectName}}:v{{ .Major }}.{{ .Minor }}'
|
||||||
|
- 'khorevaa/{{.ProjectName}}:latest'
|
||||||
|
- 'ghcr.io/khorevaa/{{.ProjectName}}:{{ .Tag }}'
|
||||||
|
- 'ghcr.io/khorevaa/{{.ProjectName}}:v{{ .Major }}.{{ .Minor }}'
|
||||||
|
- 'ghcr.io/khorevaa/{{.ProjectName}}:latest'
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
binaries:
|
||||||
|
- app-template
|
||||||
|
build_flag_templates:
|
||||||
|
- "--label=org.label-schema.schema-version=1.0"
|
||||||
|
- "--label=org.label-schema.version={{.Version}}"
|
||||||
|
- "--label=org.label-schema.name={{.ProjectName}}"
|
||||||
|
- "--label=com.github.actions.name={{.ProjectName}}"
|
||||||
|
- "--label=com.github.actions.description=Setup new app-template description"
|
||||||
|
- "--label=com.github.actions.icon=terminal"
|
||||||
|
- "--label=com.github.actions.color=blue"
|
||||||
|
- "--label=repository=http://github.com/khorevaa/app-template"
|
||||||
|
- "--label=homepage=http://github.com/khorevaa/app-template"
|
||||||
|
- "--label=maintainerAleksey Khorev khorevaa@gmail.com"
|
||||||
|
archives:
|
||||||
|
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
|
||||||
|
replacements:
|
||||||
|
darwin: Darwin
|
||||||
|
linux: Linux
|
||||||
|
windows: Windows
|
||||||
|
386: i386
|
||||||
|
amd64: x86_64
|
||||||
|
format_overrides:
|
||||||
|
- goos: windows
|
||||||
|
format: zip
|
||||||
|
|
3
Dockerfile
Normal file
3
Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FROM scratch
|
||||||
|
COPY app-template /
|
||||||
|
ENTRYPOINT ["/app-template"]
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021 khorevaa
|
||||||
|
|
||||||
|
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.
|
19
cmd/commands.go
Normal file
19
cmd/commands.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Commands = []Command{
|
||||||
|
|
||||||
|
&someCommand{},
|
||||||
|
//&commandWithSub{
|
||||||
|
// sub: []Command{
|
||||||
|
// &subCommand{},
|
||||||
|
// },
|
||||||
|
//},
|
||||||
|
}
|
||||||
|
|
||||||
|
type Command interface {
|
||||||
|
Cmd() *cli.Command
|
||||||
|
}
|
61
cmd/some_command.go
Normal file
61
cmd/some_command.go
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type someCommand struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *someCommand) run(context *cli.Context) error {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *someCommand) Cmd() *cli.Command {
|
||||||
|
|
||||||
|
cmd := &cli.Command{
|
||||||
|
//Category: "some_category",
|
||||||
|
Name: "some_command",
|
||||||
|
Usage: "Usage decription",
|
||||||
|
Description: `Full usage description `,
|
||||||
|
Action: c.run,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
//&cli.StringFlag{
|
||||||
|
// Destination: &c.cluster, Name: "cluster-id",
|
||||||
|
// Value: "", Usage: "cluster uuid for join new work server"},
|
||||||
|
//&cli.StringFlag{
|
||||||
|
// Destination: &c.Name, Name: "name", Aliases: []string{"N"},
|
||||||
|
// Value: "", Usage: "work server name", EnvVars: []string{"SERVER_NAME"}, Required: true},
|
||||||
|
//&cli.StringFlag{
|
||||||
|
// Destination: &c.AgentHost, Name: "host",
|
||||||
|
// Value: "", Usage: "work server agent host", EnvVars: []string{"SERVER_AGENT_HOST"}, Required: true},
|
||||||
|
//&cli.IntFlag{
|
||||||
|
// Destination: &c.AgentPort, Name: "port",
|
||||||
|
// Value: 1540, Usage: "work server agent port", EnvVars: []string{"SERVER_AGENT_HOST"}, DefaultText: "1540"},
|
||||||
|
//&cli.StringFlag{
|
||||||
|
// Destination: &c.PortRange, Name: "port-range",
|
||||||
|
// Value: "1560:1591", Usage: "work server port range", EnvVars: []string{"SERVER_PORT_RANGE"}, DefaultText: "1560:1591"},
|
||||||
|
//&cli.StringFlag{
|
||||||
|
// Destination: &c.Using, Name: "using",
|
||||||
|
// Value: "normal", Usage: "variant of using work server (main, normal)", EnvVars: []string{"SERVER_USING"}, DefaultText: "normal"},
|
||||||
|
//&cli.StringFlag{
|
||||||
|
// Destination: &c.DedicateManagers, Name: "dedicate-managers",
|
||||||
|
// Value: "none", Usage: "вариант размещения менеджеров сервисов (all, none)", EnvVars: []string{"SERVER_DEDICATE_MANAGERS"}, DefaultText: "none"},
|
||||||
|
//&cli.IntFlag{
|
||||||
|
// Destination: &c.ClusterPort, Name: "cluster-port",
|
||||||
|
// Value: 1541, Usage: "номер порта главного менеджера кластера", EnvVars: []string{"SERVER_CLUSTER_PORT"}, DefaultText: "1541"},
|
||||||
|
//&cli.Int64Flag{
|
||||||
|
// Destination: &c.MemoryLimit, Name: "memory-limit",
|
||||||
|
// Value: 0, Usage: "предел использования памяти рабочими процессами (kilobytes)", EnvVars: []string{"SERVER_MEMORY_LIMIT"}},
|
||||||
|
//&cli.Int64Flag{
|
||||||
|
// Destination: &c.ConnectionsLimit, Name: "connections-limit",
|
||||||
|
// Value: 128, Usage: "максимальное количество соединения на рабочий процесс", EnvVars: []string{"SERVER_CONNECTIONS_LIMIT"}, DefaultText: "128"},
|
||||||
|
//&cli.Int64Flag{
|
||||||
|
// Destination: &c.CriticalTotalMemory, Name: "total-memory",
|
||||||
|
// Value: 0, Usage: "максимальный объем памяти процессов рабочего сервера (bytes)", EnvVars: []string{"SERVER_TOTAL_MEMORY"}},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
1
goreleaser.bat
Normal file
1
goreleaser.bat
Normal file
@ -0,0 +1 @@
|
|||||||
|
docker run --rm --privileged -v %cd%:/go/src/app -v /var/run/docker.sock:/var/run/docker.sock -w /go/src/app goreleaser/goreleaser:latest release --snapshot --skip-publish --rm-dist
|
7
goreleaser.sh
Normal file
7
goreleaser.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
docker run --rm --privileged \
|
||||||
|
-v $PWD:/go/src/app \
|
||||||
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
|
-w /go/src/app \
|
||||||
|
goreleaser/goreleaser:latest release --snapshot --skip-publish --rm-dist
|
41
main.go
Normal file
41
main.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/khorevaa/go-app-template/cmd"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// nolint: gochecknoglobals
|
||||||
|
var (
|
||||||
|
version = "dev"
|
||||||
|
commit = ""
|
||||||
|
date = ""
|
||||||
|
builtBy = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
app := &cli.App{
|
||||||
|
Name: "go-app-template",
|
||||||
|
Version: version,
|
||||||
|
Authors: []*cli.Author{
|
||||||
|
{
|
||||||
|
Name: "Aleksey Khorev",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Usage: "Description for go-app-template",
|
||||||
|
Copyright: "(c) 2021 Khorevaa",
|
||||||
|
//Description: "Command line utilities for server 1S.Enterprise",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, command := range cmd.Commands {
|
||||||
|
app.Commands = append(app.Commands, command.Cmd())
|
||||||
|
}
|
||||||
|
|
||||||
|
err := app.Run(os.Args)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
25
readme.md
Normal file
25
readme.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# go-app-template
|
||||||
|
|
||||||
|
[](https://github.com/khorevaa/go-app-template/releases/latest)
|
||||||
|
[](/LICENSE.md)
|
||||||
|
[](https://github.com/khorevaa/go-app-template/actions?workflow=releaser)
|
||||||
|
[](https://codecov.io/gh/khorevaa/go-app-template)
|
||||||
|
[](http://godoc.org/github.com/khorevaa/go-app-template)
|
||||||
|
[](https://saythanks.io/to/khorevaa)
|
||||||
|
[](https://github.com/goreleaser)
|
||||||
|
[](https://conventionalcommits.org)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
|
||||||
|
### Github Release
|
||||||
|
|
||||||
|
## License
|
Loading…
x
Reference in New Issue
Block a user