Skip to content

Commit 9aef9fa

Browse files
committed
Updated for deb packing
1 parent fee46ea commit 9aef9fa

File tree

8 files changed

+119
-22
lines changed

8 files changed

+119
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Release
2+
on:
3+
release:
4+
types: [ created ]
5+
jobs:
6+
build-arm:
7+
runs-on: [self-hosted, linux, arm]
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Install Go for ARM
11+
run: |
12+
install -d ${RUNNER_TEMP}/go
13+
curl -s -L https://golang.org/dl/go1.17.linux-armv6l.tar.gz | tar -C ${RUNNER_TEMP} -xz
14+
echo ${RUNNER_TEMP}/go/bin >> $GITHUB_PATH
15+
echo ${HOME}/go/bin >> $GITHUB_PATH
16+
- name: Build for Linux on ARM
17+
run: |
18+
make deb
19+
- name: Upload DEBs to release
20+
run: |
21+
TAG=`git describe --abbrev=0 --tags`
22+
gh release upload ${TAG} build/*.deb
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

+34-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Paths to packages
22
GO=$(shell which go)
3+
SED=$(shell which sed)
34
NPM=$(shell which npm)
45

56
# Paths to locations, etc
@@ -16,15 +17,24 @@ BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GitBranch=$(shell git name-rev H
1617
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GitHash=$(shell git rev-parse HEAD)
1718
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GoBuildTime=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
1819
BUILD_FLAGS = -ldflags "-s -w $(BUILD_LD_FLAGS)"
20+
BUILD_VERSION = $(shell git describe --tags)
21+
BUILD_ARCH = $(shell $(GO) env GOARCH)
22+
BUILD_PLATFORM = $(shell $(GO) env GOOS)
1923

20-
.PHONY: all test server npm cmd plugins dependencies mkdir clean
21-
22-
all: clean plugins server npm cmd
24+
all: clean server plugins npm cmd
2325

2426
server: dependencies mkdir
2527
@echo Build server
2628
@${GO} build -o ${BUILD_DIR}/server ${BUILD_FLAGS} github.com/mutablelogic/go-server/cmd/server
2729

30+
plugins: $(PLUGIN_DIR)
31+
@echo Build plugin httpserver
32+
@${GO} build -buildmode=plugin -o ${BUILD_DIR}/httpserver.plugin ${BUILD_FLAGS} github.com/mutablelogic/go-server/plugin/httpserver
33+
@echo Build plugin log
34+
@${GO} build -buildmode=plugin -o ${BUILD_DIR}/log.plugin ${BUILD_FLAGS} github.com/mutablelogic/go-server/plugin/log
35+
@echo Build plugin static
36+
@${GO} build -buildmode=plugin -o ${BUILD_DIR}/static.plugin ${BUILD_FLAGS} github.com/mutablelogic/go-server/plugin/static
37+
2838
npm: $(NPM_DIR)
2939

3040
cmd: dependencies mkdir $(CMD_DIR)
@@ -37,20 +47,24 @@ $(CMD_DIR): FORCE
3747
@echo Build cmd $(notdir $@)
3848
@${GO} build -o ${BUILD_DIR}/$(notdir $@) ${BUILD_FLAGS} ./$@
3949

40-
plugins: $(PLUGIN_DIR)
41-
@echo Build plugin httpserver
42-
@${GO} build -buildmode=plugin -o ${BUILD_DIR}/httpserver.plugin ${BUILD_FLAGS} github.com/mutablelogic/go-server/plugin/httpserver
43-
@echo Build plugin log
44-
@${GO} build -buildmode=plugin -o ${BUILD_DIR}/log.plugin ${BUILD_FLAGS} github.com/mutablelogic/go-server/plugin/log
45-
@echo Build plugin static
46-
@${GO} build -buildmode=plugin -o ${BUILD_DIR}/static.plugin ${BUILD_FLAGS} github.com/mutablelogic/go-server/plugin/static
47-
4850
$(PLUGIN_DIR): FORCE
4951
@echo Build plugin $(notdir $@)
5052
@${GO} build -buildmode=plugin -o ${BUILD_DIR}/$(notdir $@).plugin ${BUILD_FLAGS} ./$@
5153

5254
FORCE:
5355

56+
57+
deb: nfpm go-server-sqlite3-deb
58+
59+
go-server-sqlite3-deb: plugin/sqlite3
60+
@echo Package go-server-sqlite3 deb
61+
@${SED} \
62+
-e 's/^version:.*$$/version: $(BUILD_VERSION)/' \
63+
-e 's/^arch:.*$$/arch: $(BUILD_ARCH)/' \
64+
-e 's/^platform:.*$$/platform: $(BUILD_PLATFORM)/' \
65+
etc/nfpm/go-server-sqlite3/nfpm.yaml > $(BUILD_DIR)/go-server-sqlite3-nfpm.yaml
66+
@nfpm pkg -f $(BUILD_DIR)/go-server-sqlite3-nfpm.yaml --packager deb --target $(BUILD_DIR)
67+
5468
test:
5569
@echo Test sys/sqlite3
5670
@${GO} test ./sys/sqlite3
@@ -69,13 +83,22 @@ test:
6983
@echo Test pkg/sqobj
7084
@${GO} test ./pkg/sqobj
7185

86+
87+
nfpm:
88+
@echo Installing nfpm
89+
@${GO} mod tidy
90+
@${GO} install github.com/goreleaser/nfpm/v2/cmd/[email protected]
91+
7292
dependencies:
7393
ifeq (,${GO})
7494
$(error "Missing go binary")
7595
endif
7696
ifeq (,${NPM})
7797
$(error "Missing npm binary")
7898
endif
99+
ifeq (,${SED})
100+
$(error "Missing sed binary")
101+
endif
79102

80103
mkdir:
81104
@install -d ${BUILD_DIR}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Plugins to load, the order of these is important
2+
plugins:
3+
- plugin/sqlite3.plugin
4+
- plugin/log.plugin
5+
6+
# Handlers for sqlite3
7+
handlers:
8+
sqlite3:
9+
# The sqlite3 plugin can be viewed at http://localhost/api/sqlite3
10+
prefix: /api/sqlite3
11+
# Requests are logged
12+
middleware:
13+
- log
14+
15+
sqlite3:
16+
# Databases to load and/or create. Only the 'main' database is required.
17+
databases:
18+
main: ":memory:"
19+
20+
# Set create to true to allow databases which don't exist to be created, or
21+
# else error will be reported on server start. In-memory databases can always
22+
# be created.
23+
create: true
24+
25+
# Set trace to true to enable the ability to profile queries. Profiling information
26+
# can be displayed through the API.
27+
trace: false
28+
29+
# Set max number of connections that can be simultaneously opened
30+
max: 5

etc/nfpm/go-server-sqlite3/nfpm.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "go-server-sqlite3"
2+
arch: ""
3+
version: ""
4+
section: "default"
5+
priority: "extra"
6+
maintainer: "David Thorpe <[email protected]>"
7+
description: |
8+
Plugggable go-server monolith: sqlite3
9+
vendor: "mutablelogic.com"
10+
homepage: "https://github.com/mutablelogic/go-sqlite3"
11+
depends:
12+
- go-server-httpserver
13+
14+
contents:
15+
- src: ./build/sqlite3.plugin
16+
dst: /opt/go-server/plugin/sqlite3.plugin
17+
- src: ./etc/nfpm/go-server-sqlite3/go-server-30-sqlite3.yaml
18+
dst: /opt/go-server/etc/go-server-30-sqlite3.yaml
19+
type: config
20+
21+
scripts:
22+
postinstall: ./etc/nfpm/go-server-sqlite3/postinstall.deb.sh
23+
postremove: ./etc/nfpm/go-server-sqlite3/postremove.deb.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Restart server
4+
systemctl restart go-server.service
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Restart server
4+
systemctl restart go-server.service

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.17
55
require (
66
github.com/djthorpe/go-errors v1.0.2
77
github.com/djthorpe/go-marshaler v0.0.15
8-
github.com/djthorpe/go-sqlite v1.0.35
98
github.com/hashicorp/go-multierror v1.1.1
109
github.com/mutablelogic/go-server v1.0.33
1110
github.com/rjeczalik/notify v0.9.2

go.sum

-10
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
66
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
77
github.com/djthorpe/go-errors v1.0.2 h1:kZuNLhb6Yo1iNHaenGa9s5CpRbOG6KxbUtrME4LrAkk=
88
github.com/djthorpe/go-errors v1.0.2/go.mod h1:HtfrZnMd6HsX75Mtbv9Qcnn0BqOrrFArvCaj3RMnZhY=
9-
github.com/djthorpe/go-marshaler v0.0.4/go.mod h1:xCXhTzj52UL3YStRsqUSfrKses7ofmfTXYQfVedn8Lw=
10-
github.com/djthorpe/go-marshaler v0.0.14/go.mod h1:xCXhTzj52UL3YStRsqUSfrKses7ofmfTXYQfVedn8Lw=
119
github.com/djthorpe/go-marshaler v0.0.15 h1:ZXq5YHCsbREbbYJtc0ie9hz7HJ7vIeeDlMbe7cGh0C0=
1210
github.com/djthorpe/go-marshaler v0.0.15/go.mod h1:xCXhTzj52UL3YStRsqUSfrKses7ofmfTXYQfVedn8Lw=
13-
github.com/djthorpe/go-server v1.0.8/go.mod h1:FShgU8xZdpIiNDhBD/SGytAEW1t3O4+eJdcBRU1vQwQ=
14-
github.com/djthorpe/go-sqlite v1.0.28/go.mod h1:TiGX+dIFea54xxIBVmFemTI/8KUjVUlEoDN2A5HKaMs=
15-
github.com/djthorpe/go-sqlite v1.0.35 h1:72Z8h3wmxN490nbLIzDs2Dr9W5PcAfZEYCPjbACx3ug=
16-
github.com/djthorpe/go-sqlite v1.0.35/go.mod h1:3zUz5/pbiQlVRSt+d5Hbj9tOtimKKwlmd4RttJ3tcrA=
1711
github.com/go-asn1-ber/asn1-ber v1.5.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
1812
github.com/go-asn1-ber/asn1-ber v1.5.3/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
1913
github.com/go-ldap/ldap/v3 v3.4.1/go.mod h1:iYS1MdmrmceOJ1QOTnRXrIs7i3kloqtmGQjRvjKpyMg=
@@ -23,7 +17,6 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY
2317
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
2418
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
2519
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
26-
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
2720
github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4=
2821
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
2922
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
@@ -49,7 +42,6 @@ github.com/xuri/excelize/v2 v2.4.1/go.mod h1:rSu0C3papjzxQA3sdK8cU544TebhrPUoTOa
4942
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
5043
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
5144
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
52-
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
5345
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
5446
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
5547
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
@@ -58,7 +50,6 @@ golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+o
5850
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
5951
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
6052
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
61-
golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
6253
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
6354
golang.org/x/net v0.0.0-20210929193557-e81a3d93ecf6 h1:Z04ewVs7JhXaYkmDhBERPi41gnltfQpMWDnTnQbaCqk=
6455
golang.org/x/net v0.0.0-20210929193557-e81a3d93ecf6/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
@@ -71,7 +62,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
7162
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7263
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7364
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
74-
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7565
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7666
golang.org/x/sys v0.0.0-20210930141918-969570ce7c6c h1:ayiZ33F3u3LIXB03Y5VKNdaFO79a18Fr+SB30o/KFyw=
7767
golang.org/x/sys v0.0.0-20210930141918-969570ce7c6c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

0 commit comments

Comments
 (0)