Skip to content

Commit c1df182

Browse files
committed
Setup release process
1 parent 7190b7e commit c1df182

File tree

6 files changed

+93
-4
lines changed

6 files changed

+93
-4
lines changed

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build release
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags:
7+
- '*'
8+
9+
jobs:
10+
11+
build-release:
12+
name: Build release
13+
runs-on: ubuntu-latest
14+
steps:
15+
16+
- name: Checkout
17+
uses: actions/checkout@master
18+
19+
- name: Set up Go 1.15
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.15
23+
id: go
24+
25+
- name: Build release
26+
run: |
27+
make build-all
28+
29+
- name: Publish release
30+
run: |
31+
echo '${{ secrets.GITHUB_TOKEN }}' | gh auth login --with-token
32+
make release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_build

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
NAME=videotranscoder
2+
VERSION=$(shell cat VERSION)
3+
BUILD=$(shell git rev-parse --short HEAD)
4+
LD_FLAGS="-w -X main.version=$(VERSION) -X main.build=$(BUILD)"
5+
6+
clean:
7+
rm -rf _build/ release/
8+
9+
build:
10+
go mod download
11+
CGO_ENABLED=0 go build -tags release -ldflags $(LD_FLAGS) -o ${NAME}
12+
13+
build-all:
14+
mkdir -p _build
15+
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -tags release -ldflags $(LD_FLAGS) -o _build/${NAME}-$(VERSION)-darwin-amd64
16+
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags release -ldflags $(LD_FLAGS) -o _build/${NAME}-$(VERSION)-linux-amd64
17+
GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -tags release -ldflags $(LD_FLAGS) -o _build/${NAME}-$(VERSION)-linux-arm
18+
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags release -ldflags $(LD_FLAGS) -o _build/${NAME}-$(VERSION)-linux-arm64
19+
# GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -tags release -ldflags $(LD_FLAGS) -o _build/${NAME}-$(VERSION)-windows-amd64
20+
cd _build; sha256sum * > sha256sums.txt
21+
22+
release:
23+
mkdir release
24+
cp _build/* release
25+
cd release; sha256sum --quiet --check sha256sums.txt && \
26+
gh release create $(VERSION) -d -t v$(VERSION) *
27+
28+
.PHONY: build

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/TrafeX/videotranscoder
22

33
go 1.15
44

5-
require github.com/fatih/color v1.10.0 // indirect
5+
require github.com/fatih/color v1.10.0

main.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,54 @@ import (
99
"os/exec"
1010
"path"
1111
"path/filepath"
12+
"runtime"
1213

1314
"github.com/fatih/color"
1415
)
1516

17+
var (
18+
name = "videotranscoder"
19+
build = "none"
20+
version = "dev-build"
21+
goVersion = runtime.Version()
22+
versionStr = fmt.Sprintf("%s version %v, build %v %v", name, version, build, goVersion)
23+
)
24+
1625
func parseCliArguments() (string, string, bool) {
1726
var sourcePath string
1827
var targetPath string
1928
var overwriteExisting bool
29+
var printVersion bool
30+
var printHelp bool
2031

2132
flag.StringVar(&sourcePath, "source", "", "Path to source folder")
2233
flag.StringVar(&targetPath, "target", "", "Path to target folder")
23-
flag.BoolVar(&overwriteExisting, "overwrite", false, "Overwrite existing files")
34+
flag.BoolVar(&overwriteExisting, "overwrite", false, "Overwrite existing files in the target folder")
35+
flag.BoolVar(&printVersion, "version", false, "Print version information")
36+
flag.BoolVar(&printHelp, "help", false, "Print help and usage information")
2437

2538
flag.Parse()
2639

40+
if printVersion {
41+
fmt.Println(versionStr)
42+
os.Exit(0)
43+
}
44+
45+
if printHelp {
46+
fmt.Printf("%s - transcode media to Apple's ProRes encoding\n", name)
47+
fmt.Printf("usage: %s -source /path/to/media/files -target /path/to/output/folder\n\n", name)
48+
fmt.Println("options:")
49+
flag.PrintDefaults()
50+
fmt.Println(versionStr)
51+
os.Exit(0)
52+
}
53+
2754
if sourcePath == "" {
28-
fmt.Fprintf(os.Stderr, "missing required -source argument\n")
55+
fmt.Fprintf(os.Stderr, "missing required -source argument\ntry '%s -help' for usage information\n", name)
2956
os.Exit(2)
3057
}
3158
if targetPath == "" {
32-
fmt.Fprintf(os.Stderr, "missing required -target argument\n")
59+
fmt.Fprintf(os.Stderr, "missing required -target argument\ntry '%s -help' for usage information\n", name)
3360
os.Exit(2)
3461
}
3562

0 commit comments

Comments
 (0)