Skip to content

Commit

Permalink
feat: fix build version and update build
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsNotGoodName committed Dec 18, 2023
1 parent 1adaae1 commit 1e8465d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 32 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ gen: gen-proto gen-openapi gen-webrpc

tooling: tooling-air tooling-goreleaser tooling-protoc-gen-go tooling-oapi-codegen tooling-webrpc tooling-java tooling-taskfile

build:
task build

# Docker

docker-build-demo:
Expand Down
43 changes: 23 additions & 20 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@

version: "3"

vars:
CMD_NAME: radiomux
PACKAGE_NAME: "github.com/ItsNotGoodName/radiomux"
APK_NAME: radiomuxplayer

tasks:
clean:
cmds:
- rm -rf dist
- mkdir -p dist/artifacts
- mkdir dist dist/artifacts dist/files dist/files-windows

build-apk:
internal: true
Expand All @@ -20,7 +25,7 @@ tasks:
- echo $ANDROID_KEYSTORE | base64 --decode > my-release-key.jks
- apksigner sign --ks my-release-key.jks --ks-pass env:ANDROID_KEYSTORE_PASSWORD --out {{.RELEASE_DIR}}/app-release.apk {{.RELEASE_DIR}}/app-release-unsigned-aligned.apk
- apksigner verify {{.RELEASE_DIR}}/app-release.apk
- cp {{.RELEASE_DIR}}/app-release.apk ../dist/radiomuxplayer-release.apk
- cp {{.RELEASE_DIR}}/app-release.apk ../dist/{{.APK_NAME}}-release.apk
vars:
RELEASE_DIR: app/build/outputs/apk/release
env:
Expand All @@ -33,7 +38,7 @@ tasks:
cmds:
- chmod +x gradlew
- ./gradlew :app:assembleDebug -x test
- cp {{.DEBUG_DIR}}/app-debug.apk ../dist/radiomuxplayer-debug.apk
- cp {{.DEBUG_DIR}}/app-debug.apk ../dist/{{.APK_NAME}}-debug.apk
vars:
DEBUG_DIR: app/build/outputs/apk/debug

Expand All @@ -42,40 +47,38 @@ tasks:
cmds:
- go mod tidy
- go generate ./...
- GOOS=linux GOARCH=amd64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Linux_x86_64 {{.MAIN_PACKAGE}}
- GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Linux_armv7 {{.MAIN_PACKAGE}}
- GOOS=linux GOARCH=arm64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Linux_arm64 {{.MAIN_PACKAGE}}
- GOOS=darwin GOARCH=arm64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Darwin_arm64 {{.MAIN_PACKAGE}}
- GOOS=windows GOARCH=amd64 go build -ldflags="{{.LDFLAGS}}" -o ./dist/radiomux_Windows_x86_64.exe {{.MAIN_PACKAGE}}
- GOOS=linux GOARCH=amd64 go build -ldflags="{{.MAIN_LDFLAGS}}" -o ./dist/{{.CMD_NAME}}_Linux_x86_64/{{.CMD_NAME}} {{.MAIN_PACKAGE}}
- GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="{{.MAIN_LDFLAGS}}" -o ./dist/{{.CMD_NAME}}_Linux_armv7/{{.CMD_NAME}} {{.MAIN_PACKAGE}}
- GOOS=linux GOARCH=arm64 go build -ldflags="{{.MAIN_LDFLAGS}}" -o ./dist/{{.CMD_NAME}}_Linux_arm64/{{.CMD_NAME}} {{.MAIN_PACKAGE}}
- GOOS=darwin GOARCH=arm64 go build -ldflags="{{.MAIN_LDFLAGS}}" -o ./dist/{{.CMD_NAME}}_Darwin_arm64/{{.CMD_NAME}} {{.MAIN_PACKAGE}}
- GOOS=windows GOARCH=amd64 go build -ldflags="{{.MAIN_LDFLAGS}}" -o ./dist/{{.CMD_NAME}}_Windows_x86_64/{{.CMD_NAME}}.exe {{.MAIN_PACKAGE}}
env:
CGO_ENABLED: 0
vars:
PACKAGE_NAME: "github.com/ItsNotGoodName/radiomux"

BUILD_PACKAGE_NAME: "{{.PACKAGE_NAME}}/internal/build/build"
BUILD_PACKAGE_NAME: "{{.PACKAGE_NAME}}/internal/build"
BUILD_VERSION: "nightly"
BUILD_DATE: '{{now | date "2006-01-02T15:04:05Z07:00"}}'
BUILD_COMMIT:
sh: git rev-parse HEAD
BUILD_REPO_URL: "https://{{.PACKAGE_NAME}}"

LDFLAGS: -s -w -X {{.BUILD_PACKAGE_NAME}}.Version={{.BUILD_VERSION}} -X {{.BUILD_PACKAGE_NAME}}.Commit={{.BUILD_COMMIT}} -X {{.BUILD_PACKAGE_NAME}}.Date={{.BUILD_DATE}} -X {{.BUILD_PACKAGE_NAME}}.RepoURL={{.BUILD_REPO_URL}}
MAIN_PACKAGE: "{{.PACKAGE_NAME}}/cmd/radiomux"
MAIN_LDFLAGS: -s -w -X {{.BUILD_PACKAGE_NAME}}.version={{.BUILD_VERSION}} -X {{.BUILD_PACKAGE_NAME}}.commit={{.BUILD_COMMIT}} -X {{.BUILD_PACKAGE_NAME}}.date={{.BUILD_DATE}} -X {{.BUILD_PACKAGE_NAME}}.repoURL={{.BUILD_REPO_URL}}
MAIN_PACKAGE: "{{.PACKAGE_NAME}}/cmd/{{.CMD_NAME}}"

compile-artifacts:
internal: true
dir: dist
cmds:
- cp *.apk artifacts/
- for: { var: FILES }
cmd: cp ../{{.ITEM}} .
cmd: cp ../{{.ITEM}} "./files/$(basename {{.ITEM}})"
- for: { var: WINDOWS_FILES }
cmd: cp ../{{.ITEM}} .
- tar -czf artifacts/radiomux_Linux_x86_64.tar.gz radiomux_Linux_x86_64 {{.FILES}}
- tar -czf artifacts/radiomux_Linux_armv7.tar.gz radiomux_Linux_armv7 {{.FILES}}
- tar -czf artifacts/radiomux_Linux_arm64.tar.gz radiomux_Linux_arm64 {{.FILES}}
- tar -czf artifacts/radiomux_Darwin_arm64.tar.gz radiomux_Darwin_arm64 {{.FILES}}
- zip -q artifacts/radiomux_Windows_x86_64.zip radiomux_Windows_x86_64.exe {{.FILES}} {{.WINDOWS_FILES}}
cmd: cp ../{{.ITEM}} "./files-windows/$(basename {{.ITEM}})"
- cd {{.CMD_NAME}}_Linux_x86_64 && cp ../files/* . && tar -czf ../artifacts/{{.CMD_NAME}}_Linux_x86_64.tar.gz *
- cd {{.CMD_NAME}}_Linux_armv7 && cp ../files/* . && tar -czf ../artifacts/{{.CMD_NAME}}_Linux_armv7.tar.gz *
- cd {{.CMD_NAME}}_Linux_arm64 && cp ../files/* . && tar -czf ../artifacts/{{.CMD_NAME}}_Linux_arm64.tar.gz *
- cd {{.CMD_NAME}}_Darwin_arm64 && cp ../files/* . && tar -czf ../artifacts/{{.CMD_NAME}}_Darwin_arm64.tar.gz *
- cd {{.CMD_NAME}}_Windows_x86_64 && cp ../files/* . && cp ../files-windows/* . && zip -q ../artifacts/{{.CMD_NAME}}_Windows_x86_64.zip *
- cd artifacts && sha256sum *.tar.gz *.zip *.apk > checksum.txt
vars:
FILES: README.md LICENSE
Expand Down
2 changes: 1 addition & 1 deletion cmd/radiomux-demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func main() {
app := lieut.NewSingleCommandApp(
lieut.AppInfo{
Name: "radiomux",
Version: build.Version,
Version: build.Current.Version,
},
run(cfg),
flags,
Expand Down
2 changes: 1 addition & 1 deletion cmd/radiomux/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
app := lieut.NewSingleCommandApp(
lieut.AppInfo{
Name: "radiomux",
Version: build.Version,
Version: build.Current.Version,
},
run(cfg),
flags,
Expand Down
32 changes: 22 additions & 10 deletions internal/build/build.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
package build

var (
Version string
Commit string
Date string
RepoURL string
commit = ""
date = ""
version = "dev"
repoURL = ""
)

var (
func init() {
Current = Build{
Commit: commit,
Date: date,
Version: version,
RepoURL: repoURL,
CommitURL: repoURL + "/tree/" + commit,
LicenseURL: repoURL + "/blob/master/LICENSE",
}
}

var Current Build

type Build struct {
Commit string
Version string
Date string
RepoURL string
CommitURL string
LicenseURL string
)

func init() {
CommitURL = RepoURL + "/tree/" + Commit
LicenseURL = RepoURL + "/blob/master/LICENSE"
}

0 comments on commit 1e8465d

Please sign in to comment.