mirror of
https://github.com/cnbattle/drone-upx.git
synced 2026-06-04 18:24:03 +08:00
add upx step
This commit is contained in:
+9
-2
@@ -60,7 +60,7 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.14
|
||||
commands:
|
||||
- "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-upx"
|
||||
- "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-upx-original"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
when:
|
||||
@@ -72,13 +72,20 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.14
|
||||
commands:
|
||||
- "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-upx"
|
||||
- "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-upx-original"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
- name : upx
|
||||
image: cnbattle/drone-upx
|
||||
settings:
|
||||
level: 9
|
||||
save_file: ./release/linux/amd64/drone-upx
|
||||
original_file: ./release/linux/amd64/drone-upx-original
|
||||
|
||||
- name: executable
|
||||
pull: always
|
||||
image: golang:1.14
|
||||
|
||||
+9
-12
@@ -6,19 +6,16 @@ import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// Cmd Cmd
|
||||
// Cmd exec.Command
|
||||
func Cmd(name string, arg ...string) {
|
||||
fmt.Println(name, arg)
|
||||
cmd0 := exec.Command(name, arg...)
|
||||
var outputBuf1 bytes.Buffer
|
||||
cmd0.Stdout = &outputBuf1
|
||||
if err := cmd0.Start(); err != nil {
|
||||
fmt.Printf("Error: The first command can not be startup %s\n", err)
|
||||
return
|
||||
command := exec.Command(name, arg...)
|
||||
var buffer bytes.Buffer
|
||||
command.Stdout = &buffer
|
||||
if err := command.Start(); err != nil {
|
||||
panic(fmt.Sprintf("Error: The first command can not be startup %s\n", err))
|
||||
}
|
||||
if err := cmd0.Wait(); err != nil {
|
||||
fmt.Printf("Error: Couldn't wait for the second command: %s\n", err)
|
||||
return
|
||||
if err := command.Wait(); err != nil {
|
||||
panic(fmt.Sprintf("Error: Couldn't wait for the second command: %s\n", err))
|
||||
}
|
||||
fmt.Printf("%s\n", outputBuf1.Bytes())
|
||||
fmt.Printf("%s", buffer.Bytes())
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cnbattle/drone-upx/cmd"
|
||||
"os"
|
||||
)
|
||||
@@ -9,12 +10,14 @@ var (
|
||||
level string
|
||||
saveFile string
|
||||
originalFile string
|
||||
Version string
|
||||
)
|
||||
|
||||
func init() {
|
||||
level = os.Getenv("PLUGIN_LEVEL")
|
||||
saveFile = os.Getenv("PLUGIN_SAVE_FILE")
|
||||
originalFile = os.Getenv("PLUGIN_ORIGINAL_FILE")
|
||||
fmt.Println("Version:", Version)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
Reference in New Issue
Block a user