-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
333 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Build | ||
on: | ||
workflow_dispatch: | ||
push: | ||
paths-ignore: | ||
- "README.md" | ||
# branches: | ||
# - main | ||
tags: | ||
- "v*" | ||
pull_request_target: | ||
branches: | ||
- main | ||
- dev | ||
jobs: | ||
build: | ||
permissions: write-all | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-22.04] | ||
fail-fast: false | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: . | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set variables | ||
if: ${{github.ref_name=='main'}} | ||
run: echo "VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Set variables | ||
if: ${{github.ref_name=='' || github.ref_type=='tag'}} | ||
run: echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.23.0" | ||
check-latest: true | ||
|
||
- name: Install UPX | ||
uses: crazy-max/ghaction-upx@v3 | ||
with: | ||
install-only: true | ||
|
||
- name: Build dssh | ||
run: make all | ||
|
||
- name: Compress binaries | ||
run: make compress | ||
|
||
- name: Upload Release | ||
if: ${{ success() && github.ref_type=='tag' }} | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag: ${{ github.ref_name }} | ||
tag_name: ${{ github.ref_name }} | ||
files: bin/dssh-* | ||
generate_release_notes: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
VERSION := $(shell git describe --tags --always) | ||
GIT_COMMIT := $(shell git rev-parse --short HEAD) | ||
|
||
GO_BUILD_COMMAND := go build -a -ldflags '-s -w -extldflags "-static" -X "github.com/PWZER/dssh/cmd.Version=$(VERSION)" -X "github.com/PWZER/dssh/cmd.GitCommit=$(GIT_COMMIT)"' | ||
|
||
all: darwin linux | ||
|
||
compress: | ||
upx --best bin/* || true | ||
|
||
darwin-amd64: | ||
GOOS=darwin GOARCH=amd64 $(GO_BUILD_COMMAND) -o bin/dssh-darwin-amd64 . | ||
|
||
darwin-arm64: | ||
GOOS=darwin GOARCH=arm64 $(GO_BUILD_COMMAND) -o bin/dssh-darwin-arm64 . | ||
|
||
darwin: darwin-amd64 darwin-arm64 | ||
|
||
linux-amd64: | ||
GOOS=linux GOARCH=amd64 $(GO_BUILD_COMMAND) -o bin/dssh-linux-amd64 . | ||
|
||
linux-arm64: | ||
GOOS=linux GOARCH=arm64 $(GO_BUILD_COMMAND) -o bin/dssh-linux-arm64 . | ||
|
||
linux: linux-amd64 linux-arm64 | ||
|
||
install: | ||
GOOS=$(shell uname | tr '[:upper:]' '[:lower:]') GOARCH=$(shell go env GOARCH) $(GO_BUILD_COMMAND) -o ~/.local/bin/dssh . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Copyright © 2024 PWZER <pwzergo@gmail.com> | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"github.com/PWZER/dssh/utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
dummy bool | ||
) | ||
|
||
var upgradeCmd = &cobra.Command{ | ||
Use: "upgrade", | ||
Short: "upgrade dssh to the latest version", | ||
Long: "upgrade dssh to the latest version", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return utils.Upgrade(dummy, Version) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(upgradeCmd) | ||
upgradeCmd.Flags().BoolVar(&dummy, "dummy", false, "dummy flag for testing") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var Version = "v0.0.1" | ||
var GitCommit = "<unknown>" | ||
|
||
var versionCmd = &cobra.Command{ | ||
Use: "version", | ||
Short: "print dssh version", | ||
Long: "print dssh version", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Printf("dssh version: %s, git commit: %s\n", Version, GitCommit) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(versionCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,37 @@ | ||
module github.com/PWZER/dssh | ||
|
||
go 1.15 | ||
go 1.20 | ||
|
||
require ( | ||
github.com/mitchellh/go-homedir v1.1.0 | ||
github.com/pelletier/go-toml/v2 v2.0.2 // indirect | ||
github.com/pkg/sftp v1.13.5 | ||
github.com/schollz/progressbar/v3 v3.8.6 | ||
github.com/spf13/cobra v1.5.0 | ||
github.com/spf13/viper v1.12.0 | ||
github.com/subosito/gotenv v1.4.0 // indirect | ||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d | ||
gopkg.in/yaml.v2 v2.4.0 | ||
) | ||
|
||
require ( | ||
github.com/fsnotify/fsnotify v1.5.4 // indirect | ||
github.com/hashicorp/hcl v1.0.0 // indirect | ||
github.com/inconshreveable/mousetrap v1.0.0 // indirect | ||
github.com/kr/fs v0.1.0 // indirect | ||
github.com/magiconair/properties v1.8.6 // indirect | ||
github.com/mattn/go-runewidth v0.0.13 // indirect | ||
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/pelletier/go-toml v1.9.5 // indirect | ||
github.com/pelletier/go-toml/v2 v2.0.2 // indirect | ||
github.com/rivo/uniseg v0.2.0 // indirect | ||
github.com/spf13/afero v1.8.2 // indirect | ||
github.com/spf13/cast v1.5.0 // indirect | ||
github.com/spf13/jwalterweatherman v1.1.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/subosito/gotenv v1.4.0 // indirect | ||
golang.org/x/sys v0.0.0-20220624220833-87e55d714810 // indirect | ||
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
gopkg.in/ini.v1 v1.66.6 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
Oops, something went wrong.