Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
feat: ci release
Browse files Browse the repository at this point in the history
  • Loading branch information
0x2E committed Jul 13, 2023
1 parent 82b653a commit b0a1b52
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 57 deletions.
38 changes: 0 additions & 38 deletions .github/workflows/build.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: release

on:
push:
tags:
- v*

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "stable"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.vscode/
*.txt
*.pprof
.DS_Store
._*

*.pprof
.DS_Store
._*
dist/
35 changes: 35 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- 386
- arm64
ignore:
- goos: darwin
goarch: "386"
binary: "{{ .ProjectName }}"
ldflags:
- -s -w -X main.Version={{.Version}} -X main.Branch={{.Branch}} -X main.Commit={{.ShortCommit}}
main: ./cmd/sf

archives:
- format: zip

checksum:
algorithm: sha256
name_template: "checksums.txt"

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

changelog:
use: github
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# SF

[![build status](https://img.shields.io/github/actions/workflow/status/0x2E/sf/build.yml?branch=main)](https://github.com/0x2E/sf/actions)
[![Go Report Card](https://goreportcard.com/badge/github.com/0x2E/sf)](https://goreportcard.com/report/github.com/0x2E/sf)
[![go version](https://img.shields.io/github/go-mod/go-version/0x2E/sf)](https://github.com/0x2E/sf/blob/main/go.mod)

Expand All @@ -13,11 +12,7 @@ SF 是一个高效的子域名爆破工具:

## 安装

1. 编译好的可执行文件

- [Release](https://github.com/0x2E/sf/releases)
- 主分支的最新提交:[Actions](https://github.com/0x2E/sf/actions) 中任意一次 workflow 的 Artifacts

1. [Release](https://github.com/0x2E/sf/releases)
2. 编译源码

```shell
Expand Down
29 changes: 22 additions & 7 deletions cmd/sf/sf.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ import (
"github.com/sirupsen/logrus"
)

var Version, Branch, Commit string

func main() {
var (
c = conf.C
output string
slient bool
debug bool
help bool
c = conf.C
output string
slient bool
debug bool
showHelp bool
showVersion bool
)
flag.StringVarP(&c.Target, "domain", "d", "", "Target domain name")
flag.StringVarP(&c.Wordlist, "wordlist", "w", "", "Wordlist file")
Expand All @@ -36,26 +39,34 @@ It is recommended to determine if the rate is appropriate by the send/recv stati
flag.BoolVar(&c.ValidCheck, "check", false, "Check the validity of the subdomains")
flag.BoolVar(&slient, "slient", false, "Only output valid subdomains, and logs that caused abnormal exit, e.g., fatal and panic")
flag.BoolVar(&debug, "debug", false, "Set the log level to debug, and enable golang pprof with web service")
flag.BoolVarP(&help, "help", "h", false, "Show help message")
flag.BoolVarP(&showVersion, "version", "v", false, "Show version")
flag.BoolVarP(&showHelp, "help", "h", false, "Show help message")
flag.CommandLine.SortFlags = false
flag.Parse()

if help {
if showHelp {
flag.Usage()
os.Exit(0)
}

if showVersion {
version()
os.Exit(0)
}

logrus.SetFormatter(&logrus.TextFormatter{
TimestampFormat: "20060102 15:04:05",
FullTimestamp: true,
})

if slient {
if debug {
logrus.Fatal("cannot enable 'debug' and 'slient' at the same time")
}
logrus.SetLevel(logrus.FatalLevel)
} else {
fmt.Print(banner)
version()
}

if debug {
Expand Down Expand Up @@ -103,3 +114,7 @@ func pprof() {
logrus.Error(err)
}
}

func version() {
fmt.Printf("version: %s. branch: %s. commit: %s\n", Version, Branch, Commit)
}

0 comments on commit b0a1b52

Please sign in to comment.