feat: install Pominal with make
This commit adds an install target in the Makefile to install Pominal on the user's system. The default installation path is /usr/local/bin but this can be configured by overriding the INSTALL_PREFIX variable. Changes include: - cleaning up .gitignore - adding workflow to .gitlab-ci.yml - bumping Go version in .gitlab-ci.yml - excluding main.go for gochecknoglobals - adding copyright notice in Makefile - adding install and uninstall targets in Makefile - adding installation instructions in the README - adding a config.mk file for make arguments - updating Pominal to specify where the icon is installed
This commit is contained in:
parent
8b8f55f577
commit
ec84a11036
10 changed files with 93 additions and 74 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,6 +1,3 @@
|
|||
tags
|
||||
bin/*
|
||||
!bin/.gitkeep
|
||||
dist/
|
||||
Pominal
|
||||
pominal
|
||||
cover.out
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
---
|
||||
include:
|
||||
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
|
||||
|
||||
stages:
|
||||
- test
|
||||
- deploy
|
||||
|
@ -16,7 +19,7 @@ test:unit:
|
|||
paths:
|
||||
- code-coverage.html
|
||||
extends: .install-make
|
||||
image: golang:1.13.7-alpine
|
||||
image: golang:1.14.4-alpine
|
||||
script:
|
||||
- make test_cover_report
|
||||
stage: test
|
||||
|
|
|
@ -63,7 +63,7 @@ linters:
|
|||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: version.go
|
||||
- path: main.go
|
||||
linters:
|
||||
- gochecknoglobals
|
||||
- path: _test.go
|
||||
|
|
48
Makefile
48
Makefile
|
@ -1,24 +1,46 @@
|
|||
NAME := pominal
|
||||
BIN_DIR := ./bin
|
||||
BIN_FILE := $(BIN_DIR)/$(NAME)
|
||||
# Pominal
|
||||
# Copyright (C) 2020 Daniel Anglin
|
||||
|
||||
.PHONY: all test_unit build clean
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
all: test_unit build
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
include config.mk
|
||||
|
||||
.PHONY: test_unit test_cover_report test_lint pominal clean
|
||||
|
||||
test_unit:
|
||||
@go test -v -coverprofile=cover.out .
|
||||
go test -v -coverprofile=cover.out .
|
||||
|
||||
test_cover_report: test_unit
|
||||
@go tool cover -html=cover.out -o code-coverage.html
|
||||
go tool cover -html=cover.out -o code-coverage.html
|
||||
|
||||
test_lint:
|
||||
@golangci-lint run --color always
|
||||
golangci-lint run --color always
|
||||
|
||||
build:
|
||||
@go build -a -o $(BIN_FILE)
|
||||
@cp -a assets bin/assets
|
||||
pominal:
|
||||
go build -ldflags=$(LDFLAGS) -v -a -o pominal
|
||||
|
||||
install: pominal
|
||||
mkdir -p $(INSTALL_PREFIX)/bin
|
||||
mkdir -p $(INSTALL_PREFIX)/share/pominal
|
||||
cp -f pominal $(INSTALL_PREFIX)/bin
|
||||
chmod 0755 $(INSTALL_PREFIX)/bin/pominal
|
||||
cp -a assets/* $(INSTALL_PREFIX)/share/pominal
|
||||
chmod -R a-rwx,u+rwX,g+rX,o+rX $(INSTALL_PREFIX)/share/pominal
|
||||
|
||||
uninstall:
|
||||
rm -f $(INSTALL_PREFIX)/bin/pominal
|
||||
rm -fr $(INSTALL_PREFIX)/share/pominal
|
||||
|
||||
clean:
|
||||
@go clean
|
||||
@rm -rf $(BIN_FILE) $(BIN_DIR)/assets
|
||||
go clean
|
||||
|
|
28
README.md
28
README.md
|
@ -1,6 +1,32 @@
|
|||
# Pominal
|
||||
|
||||
Pominal is a Pomodoro application for the terminal. Pominal is written in Go.
|
||||
## Summary
|
||||
|
||||
Pominal is a Pomodoro application for the terminal written in Go.
|
||||
Pominal is primarily written for GNU/Linux but might also run fine on Windows and OSX.
|
||||
|
||||
## Installation
|
||||
|
||||
Before installing Pominal make sure that you have the tools listed below installed on your system:
|
||||
|
||||
- Make
|
||||
- The latest version of [Go](https://golang.org)
|
||||
|
||||
Run the below command to build and install Pominal.
|
||||
By default Pominal is installed in /usr/local so you may have to run the command with sudo.
|
||||
|
||||
```sh
|
||||
$ make clean install
|
||||
```
|
||||
|
||||
To change the installation path you can edit `INSTALL_PREFIX` in config.mk or set the `INSTALL_PREFIX` variable as you execute `make`:
|
||||
|
||||
```sh
|
||||
# example install Pominal in your home directory
|
||||
$ INSTALL_PREFIX=${HOME}/.local make clean install
|
||||
```
|
||||
|
||||
If you are installing Pominal on an OS other than GNU/Linux and/or an architecture other than AMD64 then update the `GOOS` and `GOARCH` variables in config.mk.
|
||||
|
||||
## Assets
|
||||
|
||||
|
|
24
alert.go
24
alert.go
|
@ -20,40 +20,20 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/0xAX/notificator"
|
||||
)
|
||||
|
||||
const iconPath string = "assets/icon/tomato.png"
|
||||
const iconPath string = "share/pominal/icons/tomato.png"
|
||||
|
||||
// initNotifier initialises the new desktop notifier.
|
||||
func initNotifier() *notificator.Notificator {
|
||||
return notificator.New(notificator.Options{
|
||||
DefaultIcon: getNotificationIconPath(),
|
||||
DefaultIcon: installPrefix + "/" + iconPath,
|
||||
AppName: "Pominal",
|
||||
})
|
||||
}
|
||||
|
||||
// getNotificationIconPath returns the absolute path of the tomoato icon
|
||||
// used for desktop notifications.
|
||||
// If there is an error getting the path to the executing program
|
||||
// then an empty string is returned.
|
||||
func getNotificationIconPath() string {
|
||||
var result string
|
||||
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: Unable to determine path to this executable. %s", err.Error())
|
||||
return result
|
||||
}
|
||||
|
||||
result = filepath.Dir(exe) + "/" + iconPath
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// alert creates a new desktop notification.
|
||||
func desktopAlert(label, msg string, notifier *notificator.Notificator) {
|
||||
if len(msg) == 0 {
|
||||
|
|
Before Width: | Height: | Size: 151 KiB After Width: | Height: | Size: 151 KiB |
13
config.mk
Normal file
13
config.mk
Normal file
|
@ -0,0 +1,13 @@
|
|||
# pominal version
|
||||
VERSION = 0.3.0
|
||||
|
||||
# Default installation path
|
||||
INSTALL_PREFIX ?= /usr/local
|
||||
|
||||
# Go environment variables
|
||||
CGO_ENABLED = 0
|
||||
GOOS = linux
|
||||
GOARCH = amd64
|
||||
|
||||
# Build flags
|
||||
LDFLAGS = "-s -w -X main.version=$(VERSION) -X main.installPrefix=$(INSTALL_PREFIX)"
|
10
main.go
10
main.go
|
@ -20,12 +20,18 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
var (
|
||||
version string
|
||||
installPrefix string
|
||||
)
|
||||
|
||||
const (
|
||||
workTimerLabel string = "Work"
|
||||
shortBreakTimerLabel string = "Short break"
|
||||
|
@ -82,3 +88,7 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func Version() {
|
||||
fmt.Printf("Pominal version %s\n", version)
|
||||
}
|
||||
|
|
32
version.go
32
version.go
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
Pominal
|
||||
Copyright (C) 2020 Daniel Anglin
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
commit string
|
||||
date string
|
||||
goversion string
|
||||
version string
|
||||
)
|
||||
|
||||
func Version() {
|
||||
fmt.Printf("Pominal\n\nVersion: %s\nCommit: %s\nGo Version: %s\nDate: %s", version, commit, goversion, date)
|
||||
}
|
Loading…
Reference in a new issue