Skip to content

Commit 0c4ce09

Browse files
authored
Merge pull request #1 from thinnect/gomod-actions
Gomod actions CORE-157 CORE-158 TS-541
2 parents 96b50a4 + 07ded1d commit 0c4ce09

37 files changed

Lines changed: 405 additions & 263 deletions
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: build-deviceparameters
2+
on: [push]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-20.04
6+
steps:
7+
- uses: actions/checkout@v2
8+
9+
- name: Setup Go
10+
uses: actions/setup-go@v2
11+
with:
12+
go-version: '1.17.2'
13+
14+
- name: Install build tools
15+
run: sudo apt update && sudo apt install -y lsb-release build-essential debhelper upx ruby ruby-dev
16+
17+
- name: Install ronn for converting manpages
18+
run: sudo gem install ronn
19+
20+
# AMD64
21+
- name: Build for amd64
22+
run: cd support && make amd64
23+
24+
- name: Install amd64
25+
run: sudo dpkg -i mist-device-parameters_*_amd64.deb
26+
27+
- name: Run installed deviceparamter
28+
run: deviceparameter -V
29+
30+
- name: Run installed deviceparamters
31+
run: deviceparameters -V
32+
33+
# ARMv5 / armel
34+
- name: Build for armel(arm5)
35+
run: cd support && make armel
36+
37+
# ARMv6 / armhf
38+
- name: Build for armhf(arm6)
39+
run: cd support && make armhf
40+
41+
# Windows
42+
- name: Build for Windows
43+
run: cd support && make win64
44+
45+
# Publish
46+
- uses: ncipollo/release-action@v1
47+
if: startsWith(github.ref, 'refs/tags/')
48+
with:
49+
artifacts: "mist-device-parameters_*.deb,mist-device-parameters_*.zip"
50+
token: ${{ secrets.GITHUB_TOKEN }}
51+
draft: true

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
vendor
1+
*.deb
2+
*.zip
3+
*.buildinfo
4+
*.changes

.gitmodules

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,14 @@ See the [deviceparameter README](cmd/deviceparameter/README.md) for details.
1111
A utility for dealing with several parameters on multiple nodes.
1212
See the [deviceparameters README](cmd/deviceparameters/README.md) for details.
1313

14-
# Dependencies
15-
Go dependencies have been vendored as submodules under the vendor directory.
16-
17-
Building the _deb_ package requires `checkinstall` and `ronn`.
18-
19-
`ronn` can be obtained from <https://github.com/rtomayko/ronn>.
20-
2114
# Building
2215

23-
Check out all submodules, install `ronn` and `checkinstall`.
16+
Enter `cmd/deviceparameter` or `cmd/deviceparameters` and execute `make` to
17+
see supported targets. Both applications can be cross-compiled for Windows and
18+
for use on ARM based Linux platforms.
2419

25-
Enter `cmd/deviceparameter` or `cmd/deviceparameters` and execute `make` or
26-
enter `cmd` and execute the `build-deb.sh` script.
20+
Packaged versions can be built from the support directory, see the
21+
[support/Makefile](support/Makefile) for available options.
2722

28-
Both applications can be cross-compiled for Windows and for use on ARM based
29-
Linux platforms, though packaging only works on the native architecture. Take a
30-
look at the Makefiles for details.
23+
Building the deb packages requires `ronn`, which can be installed with ruby's
24+
`gem` or can be obtained from <https://github.com/rtomayko/ronn>.

cmd/Makefile

Lines changed: 0 additions & 20 deletions
This file was deleted.

cmd/build-deb.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

cmd/description-pak

Lines changed: 0 additions & 1 deletion
This file was deleted.

cmd/deviceparameter/.gitignore

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

cmd/deviceparameter/Makefile

Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,93 @@
33
BUILD_DATE = $(shell date -u '+%Y-%m-%d_%H:%M:%S')
44
BUILD_DISTRO = $(shell lsb_release -sd)
55

6-
all: deviceparameter manual
6+
USE_UPX ?= 0
7+
ifneq ($(USE_UPX),0)
8+
BUILD_PARTS := build compress-brute
9+
else
10+
BUILD_PARTS := build
11+
endif
712

8-
win32: export GOOS=windows
9-
win32: export GOARCH=386
10-
win32: deviceparameter.exe
13+
# In this setup arm5=armel and arm6=armhf for widest compatibility
14+
GOALS := amd64 arm5 armel arm6 armhf arm7 arm64 win64 clean
15+
ifeq (,$(filter $(GOALS),$(MAKECMDGOALS)))
16+
$(error Build with make amd64/arm5/armel/arm6/armhf/arm7/arm64/win64)
17+
endif
18+
19+
amd64:
20+
amd64: export GOOS=linux
21+
amd64: export GOARCH=amd64
22+
amd64: export FLAVOUR=$(GOOS)-$(GOARCH)
23+
amd64: $(BUILD_PARTS) manual
24+
25+
arm5: export GOOS=linux
26+
arm5: export GOARCH=arm
27+
arm5: export GOARM=5
28+
arm5: export FLAVOUR=$(GOOS)-$(GOARCH)$(GOARM)
29+
arm5: $(BUILD_PARTS) manual
30+
31+
armel: export GOOS=linux
32+
armel: export GOARCH=arm
33+
armel: export GOARM=5
34+
armel: export FLAVOUR=$(GOOS)-armel
35+
armel: $(BUILD_PARTS) manual
36+
37+
arm6: export GOOS=linux
38+
arm6: export GOARCH=arm
39+
arm6: export GOARM=6
40+
arm6: export FLAVOUR=$(GOOS)-$(GOARCH)$(GOARM)
41+
arm6: $(BUILD_PARTS) manual
42+
43+
armhf: export GOOS=linux
44+
armhf: export GOARCH=arm
45+
armhf: export GOARM=6
46+
armhf: export FLAVOUR=$(GOOS)-armhf
47+
armhf: $(BUILD_PARTS) manual
48+
49+
arm7: export GOOS=linux
50+
arm7: export GOARCH=arm
51+
arm7: export GOARM=7
52+
arm7: export FLAVOUR=$(GOOS)-$(GOARCH)$(GOARM)
53+
arm7: $(BUILD_PARTS) manual
54+
55+
arm64: export GOOS=linux
56+
arm64: export GOARCH=arm64
57+
arm64: export FLAVOUR=$(GOOS)-$(GOARCH)
58+
arm64: $(BUILD_PARTS) manual
1159

1260
win64: export GOOS=windows
1361
win64: export GOARCH=amd64
62+
win64: export FLAVOUR=$(GOOS)-$(GOARCH)
1463
win64: deviceparameter.exe
1564

16-
raspberry: export GOOS=linux
17-
raspberry: export GOARCH=arm
18-
raspberry: export GOARM=6
19-
raspberry: deviceparameter
20-
21-
raspberry2: export GOOS=linux
22-
raspberry2: export GOARCH=arm
23-
raspberry2: export GOARM=7
24-
raspberry2: deviceparameter
65+
builddir: $(FLAVOUR)
66+
mkdir -p build/$(FLAVOUR)
2567

26-
deviceparameter:
27-
go build -o deviceparameter -ldflags "-X 'main.ApplicationBuildDate=$(BUILD_DATE)' -X 'main.ApplicationBuildDistro=$(BUILD_DISTRO)'"
68+
# -s disable symbol table
69+
# -w disable DWARF generation
70+
build: builddir
71+
go build -o build/$(FLAVOUR)/deviceparameter -ldflags "-w -s -X 'main.ApplicationBuildDate=$(BUILD_DATE)' -X 'main.ApplicationBuildDistro=$(BUILD_DISTRO)'"
2872

2973
deviceparameter.exe:
30-
go build -o deviceparameter.exe -ldflags "-X 'main.ApplicationBuildDate=$(BUILD_DATE)' -X 'main.ApplicationBuildDistro=$(BUILD_DISTRO)'"
74+
go build -o build/$(FLAVOUR)/deviceparameter.exe -ldflags "-w -s -X 'main.ApplicationBuildDate=$(BUILD_DATE)' -X 'main.ApplicationBuildDistro=$(BUILD_DISTRO)'"
75+
76+
# upx will make the binary much smaller
77+
compress: build
78+
upx build/$(FLAVOUR)/deviceparameter
3179

32-
deviceparameter.1.gz:
80+
# but will take quite a while with --brute
81+
compress-brute: build
82+
upx --brute build/$(FLAVOUR)/deviceparameter
83+
84+
build/$(FLAVOUR)/deviceparameter.1.gz:
3385
ronn --roff README.md
3486
mv README.1 deviceparameter.1
3587
gzip deviceparameter.1
88+
mv deviceparameter.1.gz build/$(FLAVOUR)/
3689

37-
manual: deviceparameter.1.gz
38-
39-
install: deviceparameter manual
40-
install -m 0755 deviceparameter /usr/local/bin
41-
install -m 0644 deviceparameter /usr/local/man/man1
90+
manual: build/$(FLAVOUR)/deviceparameter.1.gz
4291

4392
clean:
44-
rm -f deviceparameter
45-
rm -f deviceparameter.1.gz
93+
rm -Rf build
4694

4795
.PHONY: clean

cmd/deviceparameter/deviceparameter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
const ApplicationVersionMajor = 0
25-
const ApplicationVersionMinor = 3
25+
const ApplicationVersionMinor = 4
2626
const ApplicationVersionPatch = 0
2727

2828
var ApplicationBuildDate string
@@ -129,7 +129,7 @@ func parseValue(opts Options) ([]byte, bool, error) {
129129
return nil, false, errors.New("Multiple values specified for parameter")
130130
}
131131

132-
return value, true, err
132+
return value, c > 0, err
133133
}
134134

135135
type Options struct {

0 commit comments

Comments
 (0)