Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
mv cmd to cli, update workflows, init taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Apr 14, 2022
1 parent 498a0e6 commit 5e5b504
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: Building From Source
run: |
go mod tidy -compat=1.18
go mod tidy
go run ./scripts/date.go >> date.txt
go build -ldflags "-X main.version=$(git describe --abbrev=0 --tags) -X main.buildDate=$(cat date.txt)" -o doko
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ jobs:
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Build Doko Container
run: make brcwc
run: |
docker pull $DK_CONTAINER:latest
docker build -t $DK_CONTAINER --cache-from $DK_CONTAINER:latest .
docker push $DK_CONTAINER
dk_container_run:
runs-on: ubuntu-latest
Expand All @@ -51,4 +54,7 @@ jobs:
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Build Doko Full Container
run: make bfrcwc
run: |
docker pull $DK_FULL_CONTAINER:latest
docker build -t $DK_FULL_CONTAINER --cache-from $DK_FULL_CONTAINER:latest .
docker push $DK_FULL_CONTAINER
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- name: Build
run: |
go mod tidy -compat=1.18
go mod tidy
go run ./scripts/date.go >> date.txt
go build -ldflags "-X main.version=$(git describe --abbrev=0 --tags) -X main.buildDate=$(cat date.txt)" -o doko
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ jobs:
with:
install-only: true

- name: Set up `Tag`
id: ghtag
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Set up `Task`
uses: arduino/setup-task@v1

- name: Set up `Date`
run: go run ./scripts/date.go >> date.txt
- name: Set up Build Info
run: task setup

- name: Build
run: BuildDate="$(cat date.txt)" goreleaser release --rm-dist --timeout 100m
run: task release

- name: Login to Docker Hub
uses: docker/login-action@v1
Expand All @@ -47,6 +46,4 @@ jobs:
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Build Doko Containers
run: |
make brc
make bfrc
run: task build-docker
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*.so
*.dylib
/doko
date.txt
*.txt

# Test binary, built with `go test -c`
*.test
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ release:

before:
hooks:
- go mod tidy -compat=1.18
- go mod tidy

builds:
- <<: &build_defaults
Expand Down
29 changes: 0 additions & 29 deletions Makefile

This file was deleted.

51 changes: 51 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# https://taskfile.dev

version: "3"

vars:
DOKO_UNIX_PATH: /usr/local/bin

tasks:
default:
cmds:
- task: build

setup:
cmds:
- if [ -f "date.txt" ]; then rm date.txt; fi
- if [ -f "tag.txt" ]; then rm tag.txt; fi
- go run ./scripts/date.go >> date.txt
- git describe --abbrev=0 --tags >> tag.txt

remove:
cmds:
- sudo rm -rf "{{ .DOKO_UNIX_PATH }}"/doko

install:
cmds:
- sudo mv doko "{{ .DOKO_UNIX_PATH }}"

release:
cmds:
- BuildDate="$(cat date.txt)" goreleaser release --rm-dist --timeout 100m

build:
cmds:
- task: setup
- go mod tidy
- go build -ldflags "-X main.version=$(cat tag.txt) -X main.buildDate=$(cat date.txt)" -o doko

build-docker:
cmds:
- task: build-docker-cli

build-docker-cli:
cmds:
- docker build -t dokocli/doko .
- docker push dokocli/doko

build-docker-full:
dir: ./docker/doko-full
cmds:
- docker build -t dokocli/doko-full .
- docker push dokocli/doko-full
2 changes: 1 addition & 1 deletion cli/settings.go → cli/commands/settings.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cli
package commands

import (
"fmt"
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions cmd/doko/root.go → cli/doko/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"runtime"

"github.com/abdfnx/doko/cli"
"github.com/abdfnx/doko/cmd/factory"
"github.com/abdfnx/doko/cli/commands"
"github.com/abdfnx/doko/cli/factory"
"github.com/abdfnx/doko/core"
"github.com/abdfnx/doko/core/opts"
"github.com/abdfnx/doko/docker"
Expand Down Expand Up @@ -134,7 +134,7 @@ func Execute(f *factory.Factory, version string, buildDate string) *cobra.Comman
rootCmd.SetFlagErrorFunc(rootFlagErrorFunc)

// add `versionCmd` to root command
rootCmd.AddCommand(cli.SettingsCMD(), versionCmd)
rootCmd.AddCommand(commands.SettingsCMD(), versionCmd)

// add flags
rootCmd.Flags().StringVarP(&dokoOpts.Endpoint, "endpoint", "e", client.DefaultDockerHost, "The docker endpoint to use")
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion core/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/abdfnx/doko/tools"
"github.com/abdfnx/doko/core/api"
"github.com/abdfnx/doko/cmd/factory"
"github.com/abdfnx/doko/cli/factory"

"github.com/mgutz/ansi"
"github.com/tidwall/gjson"
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"runtime"

"github.com/abdfnx/doko/tools"
"github.com/abdfnx/doko/cmd/doko"
"github.com/abdfnx/doko/cmd/factory"
"github.com/abdfnx/doko/cli/doko"
"github.com/abdfnx/doko/cli/factory"
"github.com/abdfnx/doko/core/checker"

"github.com/AlecAivazis/survey/v2/terminal"
Expand Down

0 comments on commit 5e5b504

Please sign in to comment.