Compare commits

...

5 Commits

Author SHA1 Message Date
kolaente 7b2997bdb8
Add all functions as stubs 2020-08-18 21:27:33 +02:00
kolaente 65cdb76d0f
Add all variables based on the makefile 2020-08-18 21:22:40 +02:00
kolaente 1ff0fc6085
Print command 2020-08-18 21:09:25 +02:00
kolaente feacc1a323
Fix Version 2020-08-18 21:06:57 +02:00
kolaente fb8ac67d45
Add magefile 2020-08-18 21:03:28 +02:00
5 changed files with 222 additions and 1 deletions

1
go.mod
View File

@ -46,6 +46,7 @@ require (
github.com/labstack/gommon v0.3.0
github.com/laurent22/ical-go v0.1.1-0.20181107184520-7e5d6ade8eef
github.com/lib/pq v1.8.0
github.com/magefile/mage v1.10.0
github.com/mailru/easyjson v0.7.0 // indirect
github.com/mattn/go-sqlite3 v1.14.0
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect

2
go.sum
View File

@ -421,6 +421,8 @@ github.com/lib/pq v1.6.0 h1:I5DPxhYJChW9KYc66se+oKFFQX6VuQrKiprsX6ivRZc=
github.com/lib/pq v1.6.0/go.mod h1:4vXEAYvW1fRQ2/FhZ78H73A60MHw1geSm145z2mdY1g=
github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg=
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/magefile/mage v1.10.0 h1:3HiXzCUY12kh9bIuyXShaVe529fJfyqoVM42o/uom2g=
github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=

216
magefile.go Normal file
View File

@ -0,0 +1,216 @@
// Vikunja is a to-do list application to facilitate your life.
// Copyright 2018-2020 Vikunja and contributors. All rights reserved.
//
// 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 <https://www.gnu.org/licenses/>.
// +build mage
package main
import (
"fmt"
"github.com/magefile/mage/mg"
"os"
"os/exec"
"runtime"
"strings"
)
const (
PACKAGE = `code.vikunja.io/api`
DIST = `dist`
)
var (
Goflags = []string{
"-v",
}
Executable = "vikunja"
Ldflags = ""
Tags = ""
VersionNumber = "dev"
Version = "master" // This holds the built version, master by default, when building from a tag or release branch, their name
BinLocation = ""
PkgVersion = "master"
)
func setVersion() {
versionCmd := exec.Command("git", "describe", "--tags", "--always", "--abbrev=10")
version, err := versionCmd.Output()
if err != nil {
fmt.Printf("Error getting version: %s\n", err)
os.Exit(1)
}
VersionNumber = strings.Trim(string(version), "\n")
VersionNumber = strings.Replace(VersionNumber, "-", "+", 1)
VersionNumber = strings.Replace(VersionNumber, "-g", "-", 1)
if os.Getenv("DRONE_TAG") != "" {
Version = os.Getenv("DRONE_TAG")
} else if os.Getenv("DRONE_BRANCH") != "" {
Version = strings.Replace(os.Getenv("DRONE_BRANCH"), "release/v", "", 1)
}
}
func setBinLocation() {
if os.Getenv("DRONE_WORKSPACE") != "" {
BinLocation = DIST + `/binaries/` + Executable + `-` + Version + `-linux-amd64`
} else {
BinLocation = Executable
}
}
func setPkgVersion() {
if Version == "master" {
PkgVersion = VersionNumber
}
}
func setExecutable() {
if runtime.GOOS == "windows" {
Executable += ".exe"
}
}
func init() {
Tags = os.Getenv("TAGS")
setVersion()
setExecutable()
setBinLocation()
setPkgVersion()
Ldflags = `-X "` + PACKAGE + `/pkg/version.VersionNumber=` + VersionNumber + `" -X "main.Tags=` + Tags + `"`
}
func Clean() {
}
func Test() {
}
func TestCoverage() {
}
func IntegrationTest() {
}
func Lint() {
}
func Fmt() {
}
func FmtCheck() {
}
// Generates static content into the final binary
func Generate() error {
return exec.Command("go", "generate", PACKAGE+"/pkg/static").Run()
}
// Builds a vikunja binary, ready to run.
func Build() error {
mg.Deps(Generate)
cmd := exec.Command("go", "build", Goflags[0], "-tags", Tags, "-ldflags", "-s -w "+Ldflags, "-o", Executable)
fmt.Println(cmd.String())
out, err := cmd.CombinedOutput()
fmt.Print(string(out))
return err
}
func CompressBuild() {
}
func Release() {
}
func ReleaseDirs() {
}
func ReleaseWindows() {
}
func ReleaseLinux() {
}
func ReleaseDarwin() {
}
func ReleaseCompress() {
}
func ReleaseCopy() {
}
func ReleaseOsPackage() {
}
func ReleaseZip() {
}
func BuildDeb() {
}
func Reprepro() {
}
func GotSwag() {
}
func DoTheSwag() {
}
func MisspellCheck() {
}
func IneffassignCheck() {
}
func GocycloCheck() {
}
func StaticCheck() {
}
func GoSecCheck() {
}
func GoconstCheck() {
}

View File

@ -20,4 +20,4 @@ package version
// It is an own package to avoid import cycles
// Version sets the version to be printed to the user. Gets overwritten by "make release" or "make build" with last git commit or tag.
var Version = "0.7"
var Version = "dev"

View File

@ -33,4 +33,6 @@ import (
_ "honnef.co/go/tools/cmd/staticcheck"
_ "github.com/shurcooL/vfsgen"
_ "github.com/magefile/mage"
)