mirror of
https://github.com/appleboy/drone-scp.git
synced 2026-06-04 18:23:59 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bb2dd5543b | |||
| 8b963288b3 | |||
| bd2ddc2b6c | |||
| d098811ced | |||
| de6f344960 | |||
| cf87fecefa |
@@ -71,6 +71,10 @@ builds:
|
||||
{{- else }}{{ .Arch }}{{ end }}
|
||||
{{- if .Arm }}-{{ .Arm }}{{ end }}
|
||||
no_unique_dist_dir: true
|
||||
hooks:
|
||||
post:
|
||||
- cmd: xz -k -9 {{ .Path }}
|
||||
dir: ./dist/
|
||||
|
||||
archives:
|
||||
- format: binary
|
||||
@@ -79,6 +83,17 @@ archives:
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
extra_files:
|
||||
- glob: ./**.xz
|
||||
|
||||
snapshot:
|
||||
name_template: "{{ incpatch .Version }}"
|
||||
|
||||
release:
|
||||
# You can add extra pre-existing files to the release.
|
||||
# The filename on the release will be the last part of the path (base).
|
||||
# If another file with the same name exists, the last one found will be used.
|
||||
#
|
||||
# Templates: allowed
|
||||
extra_files:
|
||||
- glob: ./**.xz
|
||||
|
||||
+8
-1
@@ -1,22 +1,29 @@
|
||||
package main
|
||||
|
||||
// This function returns the appropriate command for removing a file/directory based on the operating system.
|
||||
func rmcmd(os, target string) string {
|
||||
switch os {
|
||||
case "windows":
|
||||
// On Windows, use DEL command to delete files and folders recursively
|
||||
return "DEL /F /S " + target
|
||||
case "unix":
|
||||
// On Unix-based systems, use rm command to delete files and folders recursively
|
||||
return "rm -rf " + target
|
||||
}
|
||||
// Return an empty string if the operating system is not recognized
|
||||
return ""
|
||||
}
|
||||
|
||||
// This function returns the appropriate command for creating a directory based on the operating system.
|
||||
func mkdircmd(os, target string) string {
|
||||
switch os {
|
||||
case "windows":
|
||||
// On Windows, use mkdir command to create directory and check if it exists
|
||||
return "if not exist " + target + " mkdir " + target
|
||||
case "unix":
|
||||
// On Unix-based systems, use mkdir command with -p option to create directories recursively
|
||||
return "mkdir -p " + target
|
||||
}
|
||||
|
||||
// Return an empty string if the operating system is not recognized
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
// Unit tests for rmcmd and mkdircmd
|
||||
func TestCommands(t *testing.T) {
|
||||
// Test rmcmd on Windows
|
||||
os1 := "windows"
|
||||
target1 := "C:\\path\\to\\file"
|
||||
expected1 := "DEL /F /S " + target1
|
||||
actual1 := rmcmd(os1, target1)
|
||||
if actual1 != expected1 {
|
||||
t.Errorf("rmcmd(%s, %s) = %s; expected %s", os1, target1, actual1, expected1)
|
||||
}
|
||||
|
||||
// Test rmcmd on Unix-based system
|
||||
os2 := "unix"
|
||||
target2 := "/path/to/folder"
|
||||
expected2 := "rm -rf " + target2
|
||||
actual2 := rmcmd(os2, target2)
|
||||
if actual2 != expected2 {
|
||||
t.Errorf("rmcmd(%s, %s) = %s; expected %s", os2, target2, actual2, expected2)
|
||||
}
|
||||
|
||||
// Test mkdircmd on Windows
|
||||
os3 := "windows"
|
||||
target3 := "C:\\path\\to\\folder"
|
||||
expected3 := "if not exist " + target3 + " mkdir " + target3
|
||||
actual3 := mkdircmd(os3, target3)
|
||||
if actual3 != expected3 {
|
||||
t.Errorf("mkdircmd(%s, %s) = %s; expected %s", os3, target3, actual3, expected3)
|
||||
}
|
||||
|
||||
// Test mkdircmd on Unix-based system
|
||||
os4 := "unix"
|
||||
target4 := "/path/to/folder"
|
||||
expected4 := "mkdir -p " + target4
|
||||
actual4 := mkdircmd(os4, target4)
|
||||
if actual4 != expected4 {
|
||||
t.Errorf("mkdircmd(%s, %s) = %s; expected %s", os4, target4, actual4, expected4)
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ require (
|
||||
github.com/fatih/color v1.15.0
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/stretchr/testify v1.8.2
|
||||
github.com/urfave/cli/v2 v2.25.1
|
||||
github.com/urfave/cli/v2 v2.25.3
|
||||
golang.org/x/crypto v0.8.0
|
||||
)
|
||||
|
||||
@@ -22,6 +22,6 @@ require (
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
golang.org/x/sys v0.7.0 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -32,8 +32,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
|
||||
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
||||
github.com/urfave/cli/v2 v2.25.3 h1:VJkt6wvEBOoSjPFQvOkv6iWIrsJyCrKGtCtxXWwmGeY=
|
||||
github.com/urfave/cli/v2 v2.25.3/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
@@ -46,8 +46,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
|
||||
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/appleboy/easyssh-proxy"
|
||||
@@ -24,7 +25,7 @@ func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "Drone SCP"
|
||||
app.Usage = "Copy files and artifacts via SSH."
|
||||
app.Copyright = "Copyright (c) 2020 Bo-Yi Wu"
|
||||
app.Copyright = "Copyright (c) " + strconv.Itoa(time.Now().Year()) + " Bo-Yi Wu"
|
||||
app.Version = Version
|
||||
app.Authors = []*cli.Author{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user