-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(daisctl): add first version of the cli (#825)
* include releases cmd * include version cmd * build multi platform release (macos, unix, windows)
- Loading branch information
Showing
21 changed files
with
991 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Daisctl PRs | ||
|
||
env: | ||
WORKDIR: tools/daisctl | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
paths: | ||
- "tools/daisctl/**/*.go" | ||
- "tools/daisctl/go.*" | ||
- "tools/daisctl/Makefile" | ||
- "./github/workflows/daisctl-pr.yml" | ||
|
||
jobs: | ||
tidy: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ${{ env.WORKDIR }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: '${{ env.WORKDIR }}/go.mod' | ||
cache: true | ||
- name: Check go mod | ||
run: | | ||
go mod tidy | ||
git diff --exit-code go.mod | ||
git diff --exit-code go.sum | ||
lint: | ||
needs: tidy | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ${{ env.WORKDIR }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: '${{ env.WORKDIR }}/go.mod' | ||
cache: true | ||
- name: lint | ||
uses: golangci/[email protected] | ||
with: | ||
version: latest | ||
working-directory: ${{ env.WORKDIR }} | ||
|
||
test: | ||
needs: lint | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
include: | ||
- os: ubuntu-latest | ||
shell: bash | ||
test-cmd: make test | ||
- os: macos-latest | ||
shell: bash | ||
test-cmd: make test | ||
- os: windows-latest | ||
shell: powershell | ||
test-cmd: make.exe test | ||
name: Test - ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
working-directory: ${{ env.WORKDIR }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: '${{ env.WORKDIR }}/go.mod' | ||
cache: true | ||
- name: Run tests | ||
run: ${{ matrix.test-cmd }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Release Daisctl | ||
|
||
env: | ||
WORKDIR: tools/daisctl | ||
|
||
on: | ||
push: | ||
tags: | ||
- "daisctl-*" | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: '${{ env.WORKDIR }}/go.mod' | ||
cache: true | ||
- uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
distribution: goreleaser | ||
version: 'latest' | ||
args: release --clean | ||
working-directory: ${{ env.WORKDIR }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Output of the `go build` command | ||
*.out | ||
|
||
# Directories for Go tools | ||
bin/ | ||
dist/ | ||
|
||
# Go test binary and coverage profiles | ||
*.test | ||
*.coverprofile | ||
*.cov | ||
*.out | ||
*.cover | ||
|
||
# IDE and editor-specific files | ||
.vscode/ | ||
.idea/ | ||
|
||
|
||
# Git-specific files | ||
.gitattributes | ||
.gitmodules | ||
.git/ | ||
|
||
# Common build system files | ||
.env | ||
|
||
# Godoc | ||
.doc/ | ||
|
||
# System files | ||
.DS_Store | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
project_name: daisctl | ||
|
||
builds: | ||
- binary: dais | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w -X github.com/altinn/altinn-platform/daisctl/internal/version.version={{ .Version }} | ||
- -X github.com/altinn/altinn-platform/daisctl/internal/version.commit={{ .Commit }} | ||
- -X github.com/altinn/altinn-platform/daisctl/internal/version.date={{ .CommitDate }} | ||
|
||
|
||
changelog: | ||
sort: asc | ||
use: github | ||
filters: | ||
exclude: | ||
- "^test:" | ||
- "^chore" | ||
- "merge conflict" | ||
- Merge pull request | ||
- Merge remote-tracking branch | ||
- Merge branch | ||
- go mod tidy | ||
include: | ||
- cli | ||
- daisctl | ||
|
||
archives: | ||
- format: tar.gz | ||
wrap_in_directory: true | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' | ||
files: | ||
- LICENSE | ||
- README.md | ||
|
||
source: | ||
enabled: false | ||
# name_template: '{{ .ProjectName }}-{{ .Version }}-source' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 The Norwegian Digitalisation Agency | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
.DEFAULT_GOAL = all | ||
|
||
BINARY = dais | ||
PROJECT_NAME = github.com/altinn/altinn-platform/daisctl | ||
VERSION_PKG = github.com/altinn/altinn-platform/daisctl/internal/version | ||
CONCURRENCY := 4 | ||
GO := go | ||
TAGS ?= "" | ||
COMMIT := $(shell git rev-parse HEAD) | ||
VERSION := "dev" | ||
DATE := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ') | ||
|
||
|
||
# Check if windows | ||
ifeq ($(OS),Windows_NT) | ||
BINARY := $(BINARY).exe | ||
endif | ||
|
||
all: test build | ||
build: | ||
$(GO) build -o $(BINARY) -ldflags "-X $(VERSION_PKG).version=$(VERSION) -X $(VERSION_PKG).commit=$(COMMIT) -X $(VERSION_PKG).date=$(DATE) -s -w" -v | ||
|
||
tidy: | ||
${GO} mod tidy | ||
|
||
deps: | ||
$(GO) get -tags ${TAGS} -t ./... | ||
make tidy | ||
|
||
test: build | ||
${GO} test --timeout 30m -short -count 1 -parallel ${CONCURRENCY} ./... | ||
|
||
coverage: build | ||
${GO} test --timeout 30m -count 1 -coverpkg=${PROJECT_NAME}/... -race -coverprofile=coverage.out -parallel ${CONCURRENCY} ./... | ||
${GO} tool cover -html=coverage.out -o=coverage-report.html | ||
printf "Coverage report available at coverage-report.html\n" | ||
|
||
clean: | ||
$(GO) clean | ||
rm -f $(BINARY) | ||
rm -f coverage* | ||
rm -rf dist | ||
|
||
format: | ||
$(GO) fmt ./... | ||
|
||
lint: | ||
golangci-lint run | ||
|
||
snapshot: | ||
goreleaser build --snapshot --clean | ||
|
||
.PHONY: all build test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# daisctl | ||
|
||
Welcome to **daisctl**! This is a command-line tool built with Go and Cobra that provides various utilities for managing and interacting with our platform. | ||
|
||
## Table of Contents | ||
|
||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Commands](#commands) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
|
||
## Installation | ||
|
||
To install daisctl, you can download the latest release from the [releases page](https://github.com/Altinn/altinn-platform/releases) or build it from source. | ||
|
||
### Building from Source | ||
|
||
1. **Clone the repository**: | ||
```sh | ||
git clone https://github.com/altinn/altinn-platform.git | ||
cd altinn-platform/tools/daisctl | ||
``` | ||
|
||
2. **Build the application**: | ||
```sh | ||
make build | ||
``` | ||
|
||
3. **Add the executable to your PATH** (optional): | ||
- On **Windows**: | ||
Add it to Environment variables in system properties | ||
- On **macOS/Linux**: | ||
```sh | ||
export PATH=$PATH:/path/to/daisctl | ||
``` | ||
|
||
## Usage | ||
|
||
After installation, you can use daisctl by running the `dais` command followed by a specific command and options. | ||
|
||
```sh | ||
dais [command] [flags] | ||
``` | ||
|
||
### Example | ||
|
||
To check the version of daisctl: | ||
|
||
```sh | ||
dais version | ||
Dais version: dais-v0.0.1 | ||
Commit: f6e5cacf1029e28a260b4a28fffee85eb4f67aa9 | ||
Build Date: 2024-07-30T10:58:16Z | ||
``` | ||
|
||
## Commands | ||
|
||
The CLI Application currently supports the following commands: | ||
|
||
- **version**: Displays the current version of daisctl. | ||
```sh | ||
dais version | ||
``` | ||
|
||
- **releases**: Lists the current releases running. | ||
```sh | ||
dais releases --app my-app | ||
dais r | ||
dais rel --app=myapp | ||
``` | ||
|
||
- **help**: Displays help information for daisctl and its commands. | ||
```sh | ||
dais help | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
Oops, something went wrong.