CI Work
continuous-integration/drone Build is failing Details

This commit is contained in:
Layla 2023-12-07 20:25:11 +01:00
parent b6df4c7c66
commit a7bf2bd2f0
5 changed files with 109 additions and 24 deletions

34
.drone.yaml Normal file
View File

@ -0,0 +1,34 @@
kind: pipeline
type: docker
name: Build and Release
when:
# branch:
# - main
event:
- tag
steps:
- name: install-taskfile
image: golang:1.21
commands:
- sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d
- name: build
image: golang:1.21
commands:
- task package
- name: release
image: plugins/gitea-release
settings:
base_url: https://gitea.layla.gg
api_key:
from_secret: gitea_api_key
repo: layla/gsquash
files:
- ./dist/gsquash.tar.gz
---
kind: secret
name: gitea_api_key
get:
path: secret/synology/gitea
name: token

18
.gitignore vendored Normal file
View File

@ -0,0 +1,18 @@
# Go binaries and executables
*.exe
*.exe~
*.dll
*.so
*.dylib
# Go test and coverage files
*.test
*.out
*.cover
# Go build and dependency directories
/bin/
/pkg/
/vendor/
/dist/

52
Taskfile.yml Normal file
View File

@ -0,0 +1,52 @@
# https://taskfile.dev
version: '3'
tasks:
test:
cmds:
- go test -v ./...
silent: true
desc: Run unit tests
clean:
cmds:
- go clean
- rm -rf ./bin
silent: true
desc: Remove build artifacts and clean up
build:
env:
VERSION: '{{.VERSION | default "0.0.0"}}'
cmds:
- go build -ldflags "-X main.Version=${VERSION}" -o ./bin/gsquash ./main.go
silent: true
package:
deps:
- build
cmds:
- mkdir -p ./dist
- tar -czvf ./dist/gsquash.tar.gz ./bin/gsquash
silent: true
desc: Package the binary into a tarball
install:
deps:
- build
cmds:
- cmd: sudo cp ./bin/gsquash /usr/local/bin/gsquash
platforms:
- darwin
- linux
- cmd: |
cp ./bin/gsquash.exe /Program Files(x86)/gsquash/gsquash.exe
setx PATH "%PATH%;C:\Program Files(x86)\gsquash"
platforms:
- windows
silent: true
desc: Install the binary into /usr/local/bin
default:
deps:
- test
- clean
- build
silent: true
desc: Run tests, clean up and build

View File

@ -1,22 +0,0 @@
//go:build mage
package main
import (
"github.com/magefile/mage/sh"
)
// Build builds the binary
func Build() error {
return sh.RunV("go", "build", "-o", "gsquash", "main.go")
}
// Install installs the binary
func Install() error {
return sh.RunV("go", "install")
}
// Test runs the tests
func Test() error {
return sh.RunV("go", "test", "./...")
}

View File

@ -2,17 +2,20 @@ package main
import (
"flag"
"fmt"
"os"
"gitea.layla.gg/layla/gsquash/git"
)
var Version string = "0.0.1"
func main() {
// Set flags
flagset := flag.NewFlagSet("git", flag.ExitOnError)
pull := flagset.Bool("pull", false, "Pull the latest changes from the remote")
message := flagset.String("m", "", "The commit message")
version := flagset.Bool("version", false, "Print the version")
version := flagset.Bool("v", false, "Print the version")
help := flagset.Bool("h", false, "Print the help")
// Parse flags
@ -20,7 +23,7 @@ func main() {
// Print version
if *version {
println("gsquash v0.0.1")
fmt.Printf("gsquash version %s\n", Version)
return
}