Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint
name: 🧪 Lint

on:
push:
Expand All @@ -11,17 +11,16 @@ permissions:

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout Code
- name: ⬇️ Checkout Code
uses: actions/checkout@v5

- name: Install Mise
- name: 📦 Install Mise
run: |
curl https://mise.run | sh
mise install

- name: Lint
- name: 🧪 Lint
run: |
mise run lint
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: ☁️ Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+[0-9A-Za-z]?'

env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

jobs:
release:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: ⬇️ Checkout Code
uses: actions/checkout@v5

- name: 📦 Install Mise
run: |
curl https://mise.run | sh
mise install

- name: ☁️ Release
run: |
mise release
9 changes: 4 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: 🧪 Test

on:
push:
Expand All @@ -8,17 +8,16 @@ on:

jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: Checkout Code
- name: ⬇️ Checkout Code
uses: actions/checkout@v5

- name: Install Mise
- name: 📦 Install Mise
run: |
curl https://mise.run | sh
mise install

- name: Test
- name: 🧪 Test
run: |
mise run test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea
/vendor
/bin
/dist
60 changes: 60 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
project_name: skpr

version: 2

builds:
- id: skpr-cli
main: ./cmd/skpr
binary: skpr
ldflags:
- -extldflags '-static' -X github.com/skpr/cli/cmd/skpr/version.GitVersion={{.Version}} -X github.com/skpr/cli/cmd/skpr/version.BuildDate={{time "2006-01-02"}}
env:
- CGO_ENABLED=0
goos: [ linux, darwin ]
goarch: [ amd64, arm64 ]

- id: skpr-rsh
main: ./cmd/skpr-rsh
binary: skpr-rsh
ldflags:
- -extldflags '-static'
env:
- CGO_ENABLED=0
goos: [ linux, darwin ]
goarch: [ amd64, arm64 ]

archives:
- id: nix
builds: [ skpr-cli, skpr-rsh ]
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ if eq .Os "darwin" }}macOS{{ else }}{{ .Os }}{{ end }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
wrap_in_directory: true
format: tar.gz
files:
- ./share/man/man1/skpr*.1

release:
prerelease: auto
name_template: "Skpr CLI {{.Version}}"
github:
owner: skpr
name: cli

dockers:
- ids:
- skpr-cli
- skpr-rsh
image_templates:
- ghcr.io/skpr/cli:latest
- ghcr.io/skpr/cli:{{ .Tag }}
dockerfile: Dockerfile
build_flag_templates:
- "--pull"

nfpms:
- license: Proprietary
maintainer: Skpr
homepage: https://www.skpr.io
recommends: [ rsync, docker.io ]
description: CLI for the Skpr Hosting Platform
builds: [ skpr-cli, skpr-rsh ]
formats: [ deb, rpm ]
5 changes: 5 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ run = "golangci-lint run"
description = "Checks to verify code correctness"
run = "go test -cover ./..."
depends = ["vendor"]

[tasks.release]
description = "Release the command line interface"
run = "goreleaser"
depends = ["vendor"]
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM alpine:3.21

RUN apk --no-cache add bash ca-certificates git openssh-client curl rsync docker-cli jq yq
COPY skpr skpr-rsh /usr/local/bin/

CMD ["skpr"]
5 changes: 3 additions & 2 deletions cmd/skpr/version/command.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package version

import (
v1version "github.com/skpr/cli/internal/command/version"
"github.com/spf13/cobra"

v1version "github.com/skpr/cli/internal/command/version"
)

var (
Expand Down Expand Up @@ -38,7 +39,7 @@ func NewCommand() *cobra.Command {
Long: cmdLong,
Example: cmdExample,
RunE: func(cmd *cobra.Command, args []string) error {
return command.Run(cmd.Context())
return command.Run(cmd.Context(), GitVersion, BuildDate)
},
}

Expand Down
15 changes: 3 additions & 12 deletions internal/command/version/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,16 @@ import (
"github.com/skpr/cli/internal/version"
)

var (
// GitVersion overridden at build time by:
// -ldflags="-X github.com/skpr/cli/cmd/skpr/version.GitVersion=${VERSION}"
GitVersion string
// BuildDate overridden at build time by:
// -ldflags="-X github.com/skpr/cli/cmd/skpr/version.BuildDate=${BUILD_DATE}"
BuildDate string
)

// Command that print the client and server versions.
type Command struct {
Debug bool
}

// Run the command.
func (cmd *Command) Run(ctx context.Context) error {
func (cmd *Command) Run(ctx context.Context, gitVersion, buildDate string) error {
params := version.PrintParams{
ClientVersion: GitVersion,
ClientBuildDate: BuildDate,
ClientVersion: gitVersion,
ClientBuildDate: buildDate,
}

// Get server version if we are in a project directory.
Expand Down