Compare commits

...

4 Commits

Author SHA1 Message Date
kayos@tcp.direct 921beaeeb4
CD: Setup target tag as input 2023-02-02 23:11:58 -08:00
kayos@tcp.direct 130f127bb3
CD: Setup triggers (fix dispatch) 2023-02-02 23:05:56 -08:00
kayos@tcp.direct a9ca163e17
CD: Setup triggers (fix dispatch) 2023-02-02 22:56:06 -08:00
kayos b9b85e858f
Tidy up + Enable automatic releases (#31) (#65) 2023-02-02 21:23:32 -08:00
4 changed files with 93 additions and 16 deletions

View File

@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: go vet -v ./...
run: go vet -v ./...
- name: gosec ./...
@ -22,5 +22,7 @@ jobs:
export PATH=$PATH:$(go env GOPATH)/bin
go install github.com/securego/gosec/v2/cmd/gosec@latest
gosec ./...
- name: go test -v ./...
run: go test -v ./...
- name: go build -v ./...
run: go build -v ./...

49
.github/workflows/release-command.yml vendored Normal file
View File

@ -0,0 +1,49 @@
name: Build and Release
on:
workflow_dispatch:
inputs:
repository:
description: 'The repository from which the slash command was dispatched'
required: true
comment-id:
description: 'The comment-id of the slash command'
required: true
tag:
description: 'The tag to be released'
required: true
jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: ["386", amd64, arm64]
exclude:
- goarch: "386"
goos: darwin
- goarch: arm64
goos: windows
steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1.35
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "https://dl.google.com/go/go1.19.5.linux-amd64.tar.gz"
project_path: "./cmd/HellPot"
binary_name: "HellPot"
extra_files: LICENSE README.md
build_flags: -trimpath
pre_command: export CGO_ENABLED=0
ldflags: -s -w
release_tag: ${{ github.event.inputs.tag }}
- name: Add reaction
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.PAT }}
repository: ${{ github.event.inputs.repository }}
comment-id: ${{ github.event.inputs.comment-id }}
reaction-type: hooray

21
.github/workflows/trigger.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Slash Command Dispatch
on:
issue_comment:
types: [created]
jobs:
slashCommandDispatch:
runs-on: ubuntu-latest
steps:
- name: Slash Command Dispatch
id: scd
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.PAT }}
commands: |
release
dispatch-type: workflow
permission: admin
repository: yunginnanet/HellPot
static-args: |
repository=${{ github.repository }}
comment-id=${{ github.event.comment.id }}

View File

@ -18,20 +18,25 @@ func listenOnUnixSocket(addr string, r *router.Router) error {
var unixAddr *net.UnixAddr
var unixListener *net.UnixListener
unixAddr, err = net.ResolveUnixAddr("unix", addr)
if err == nil {
// Always unlink sockets before listening on them
_ = syscall.Unlink(addr)
// Before we set socket permissions, we want to make sure only the user HellPot is running under
// has permission to the socket.
oldmask := syscall.Umask(0o077)
unixListener, err = net.ListenUnix("unix", unixAddr)
syscall.Umask(oldmask)
if err == nil {
err = os.Chmod(unixAddr.Name, os.FileMode(config.UnixSocketPermissions))
if err == nil {
err = fasthttp.Serve(unixListener, r.Handler)
}
}
if err != nil {
return err
}
return err
// Always unlink sockets before listening on them
_ = syscall.Unlink(addr)
// Before we set socket permissions, we want to make sure only the user HellPot is running under
// has permission to the socket.
oldmask := syscall.Umask(0o077)
unixListener, err = net.ListenUnix("unix", unixAddr)
syscall.Umask(oldmask)
if err != nil {
return err
}
if err = os.Chmod(
unixAddr.Name,
os.FileMode(config.UnixSocketPermissions),
); err != nil {
return err
}
return fasthttp.Serve(unixListener, r.Handler)
}