Compare commits

..

4 Commits

Author SHA1 Message Date
d3m0k1d
c1d8faecf7 chore: fix piplines 2026-02-19 19:17:14 +03:00
d3m0k1d
80fd7e9192 chore: add configs for gorealeaser and liners 2026-02-19 13:33:31 +03:00
d3m0k1d
b7be6647f8 feat: add logger logic 2026-02-19 13:14:48 +03:00
d3m0k1d
4b64e118e0 feat: add project struct 2026-02-19 13:04:01 +03:00
8 changed files with 217 additions and 0 deletions

36
.github/workflows/cd.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Install syft
run: curl -sSfL https://get.anchore.io/syft | sudo sh -s -- -b /usr/local/bin
- name: Checkout
uses: actions/checkout@v6
- name: Go setup
uses: actions/setup-go@v6
with:
go-version: '1.25'
- name: Install deps
run: go mod tidy
- name: Golangci-lint
uses: golangci/golangci-lint-action@v9.2.0
with:
args: --timeout=5m
- name: Run tests
run: go test ./...
- name: GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

24
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
name: ci.yml
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Go setup
uses: actions/setup-go@v6
with:
go-version: '1.25.7'
- name: Install deps
run: go mod tidy
- name: Run tests
run: go test ./...
- name: Build
run: go build ./...

22
.golangci.yml Normal file
View File

@@ -0,0 +1,22 @@
version: "2"
run:
timeout: 5m
tests: false
build-tags:
- integration
linters:
enable:
- errcheck
- errname
- govet
- staticcheck
- gosec
- nilerr
formatters:
enable:
- gofmt
- goimports
- golines

67
.goreleaser.yml Normal file
View File

@@ -0,0 +1,67 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
version: 2
project_name: ciweave
builds:
- id: ciweave
main: ./cmd/ciweave
binary: ciweave
ignore:
- goos: windows
- goos: darwin
- goos: freebsd
goos:
- linux
goarch:
- amd64
- arm64
ldflags:
- "-s -w"
env:
- CGO_ENABLED=0
archives:
- format: tar.gz
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
nfpms:
- id: ciweave
package_name: ciweave
file_name_template: "{{ .PackageName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
homepage: https://gitea.d3m0k1d.ru/d3m0k1d/BanForge
description: ciweave generator ci/cd pipelines
maintainer: d3m0k1d <contact@d3m0k1d.ru>
license: GPLv3.0
formats:
- apk
- deb
- rpm
- archlinux
bindir: /usr/bin
scripts:
postinstall: build/postinstall.sh
postremove: build/postremove.sh
release:
github:
owner: d3m0k1d
name: ciweave
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
algorithm: sha256
sboms:
- artifacts: archive
documents:
- "{{ .ArtifactName }}.spdx.json"
cmd: syft
args: ["$artifact", "--output", "spdx-json=$document"]

22
cmd/main.go Normal file
View File

@@ -0,0 +1,22 @@
package main
import (
"github.com/spf13/cobra"
"os"
)
var rootCmd = &cobra.Command{
Use: "ciweave",
Short: "automatic pipeline generator",
Long: "ciweave is a automatic pipeline generator for ci/cd written in golang",
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}
func main() {
Execute()
}

9
go.mod Normal file
View File

@@ -0,0 +1,9 @@
module github.com/d3m0k1d/ciweave
go 1.25.7
require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/cobra v1.10.2 // indirect
github.com/spf13/pflag v1.0.10 // indirect
)

11
go.sum Normal file
View File

@@ -0,0 +1,11 @@
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

26
internal/logger/logger.go Normal file
View File

@@ -0,0 +1,26 @@
package logger
import (
"log/slog"
"os"
)
type Logger struct {
*slog.Logger
}
func New(debug bool) *Logger {
var level slog.Level
if debug {
level = slog.LevelDebug
} else {
level = slog.LevelInfo
}
handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
Level: level,
})
return &Logger{
Logger: slog.New(handler),
}
}