first commit
This commit is contained in:
39
development/build.yaml
Normal file
39
development/build.yaml
Normal file
@@ -0,0 +1,39 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
options:
|
||||
- name: "update"
|
||||
default: false
|
||||
description: "update Dependencies"
|
||||
type: "bool"
|
||||
|
||||
- name: "test"
|
||||
default: true
|
||||
description: "test"
|
||||
type: "bool"
|
||||
|
||||
- name: "verbose"
|
||||
default: false
|
||||
description: "verbose testing"
|
||||
type: "bool"
|
||||
|
||||
- name: "integration"
|
||||
default: false
|
||||
description: "integration testing"
|
||||
type: "bool"
|
||||
|
||||
- name: "release"
|
||||
default: ""
|
||||
description: "release one of major,minor or patch"
|
||||
type: "string"
|
||||
|
||||
tasks:
|
||||
- call:
|
||||
script: "@(development)/update.yaml"
|
||||
when: $(update)
|
||||
|
||||
- call:
|
||||
script: "@(development)/compile.yaml"
|
||||
args:
|
||||
release: $(release)
|
||||
test: $(test)
|
||||
verbose: $(verbose)
|
||||
integration: $(integration)
|
||||
16
development/check-git-repository.yaml
Normal file
16
development/check-git-repository.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- execute:
|
||||
description: "Git Check For Changes"
|
||||
exec: "git"
|
||||
dir: "."
|
||||
args:
|
||||
- "status"
|
||||
- "--porcelain"
|
||||
response:
|
||||
name: "gitChanges"
|
||||
|
||||
- throw:
|
||||
description: "Check if repository is clean"
|
||||
message: "Git repository not clean, please commit changes ..."
|
||||
when: $(gitChanges != "")
|
||||
24
development/commands.yaml
Normal file
24
development/commands.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-commands-schema.json
|
||||
commands:
|
||||
- name: "update"
|
||||
description: "Update project"
|
||||
script: "@(development)/update.yaml"
|
||||
|
||||
- name: "build"
|
||||
description: "Build project"
|
||||
script: "@(development)/build.yaml"
|
||||
|
||||
- name: "release"
|
||||
description: "Release project"
|
||||
script: "@(development)/release.yaml"
|
||||
|
||||
- name: "deploy"
|
||||
description: "Deloy project"
|
||||
script: "@(development)/deploy.yaml"
|
||||
configs:
|
||||
- "@(development)/deploy-config.yaml"
|
||||
|
||||
- name: "upload"
|
||||
description: "Upload tasks"
|
||||
script: "@(development)/upload.yaml"
|
||||
|
||||
48
development/compile.yaml
Normal file
48
development/compile.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- execute:
|
||||
description: "Format"
|
||||
exec: "go"
|
||||
dir: "."
|
||||
args:
|
||||
- "fmt"
|
||||
- "./..."
|
||||
|
||||
- execute:
|
||||
description: "Check Source"
|
||||
exec: "go"
|
||||
dir: "."
|
||||
args:
|
||||
- "vet"
|
||||
- "./..."
|
||||
|
||||
- execute:
|
||||
description: "GolangCi Lint"
|
||||
exec: "golangci-lint"
|
||||
dir: "."
|
||||
args:
|
||||
- "run"
|
||||
- "./..."
|
||||
|
||||
- execute:
|
||||
description: "Clean Testcache"
|
||||
exec: "go"
|
||||
dir: "."
|
||||
args:
|
||||
- "clean"
|
||||
- "-testcache"
|
||||
when: $(test == true && release != "")
|
||||
|
||||
- execute:
|
||||
description: "Test"
|
||||
exec: "go"
|
||||
dir: "."
|
||||
args:
|
||||
- "test"
|
||||
- '$(verbose ? "-v" : "-v=false")'
|
||||
- "-cover"
|
||||
- "-race"
|
||||
- "-tags"
|
||||
- '$(integration ? "integration" : "")'
|
||||
- "./..."
|
||||
when: $(test == true)
|
||||
16
development/deploy-app.yaml
Normal file
16
development/deploy-app.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- call:
|
||||
script: "@(development)/deploy-target.yaml"
|
||||
loop:
|
||||
values: $(app.deployments)
|
||||
as: name
|
||||
args:
|
||||
name: $(name)
|
||||
when: $(has("app.deployments"))
|
||||
onSuccess: return
|
||||
|
||||
- call:
|
||||
script: "@(development)/deploy-target.yaml"
|
||||
args:
|
||||
name: $(app.name)
|
||||
53
development/deploy-target.yaml
Normal file
53
development/deploy-target.yaml
Normal file
@@ -0,0 +1,53 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- loadVersion:
|
||||
varName: version
|
||||
file: .mstr.json
|
||||
|
||||
- template:
|
||||
args:
|
||||
version: "$(version)"
|
||||
templates:
|
||||
- "@(development)/version.yaml"
|
||||
target: "@(provisioning)/roles/$(name)/vars/version.yaml"
|
||||
|
||||
- execute:
|
||||
dir: "@(provisioning)"
|
||||
exec: "orchestra"
|
||||
args:
|
||||
- "-roles"
|
||||
- "$(name)"
|
||||
|
||||
- execute:
|
||||
description: "Check health endpoint"
|
||||
exec: "curl"
|
||||
args:
|
||||
- "--retry"
|
||||
- "10"
|
||||
- "--silent"
|
||||
- $(settings.health_url)
|
||||
when: $(has("settings.health_url"))
|
||||
|
||||
- execute:
|
||||
dir: "@(provisioning)"
|
||||
exec: git
|
||||
args:
|
||||
- add
|
||||
- "@(provisioning)/roles/$(name)/vars/version.yaml"
|
||||
|
||||
- execute:
|
||||
dir: "@(provisioning)"
|
||||
exec: git
|
||||
args:
|
||||
- commit
|
||||
- "-m"
|
||||
- "New $(name) release"
|
||||
|
||||
- execute:
|
||||
dir: "@(provisioning)"
|
||||
exec: git
|
||||
args:
|
||||
- push
|
||||
|
||||
- print:
|
||||
format: "### Application $(name) version $(version) deployed ###"
|
||||
9
development/deploy.yaml
Normal file
9
development/deploy.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- call:
|
||||
script: "@(development)/deploy-app.yaml"
|
||||
loop:
|
||||
values: $(apps)
|
||||
as: app
|
||||
args:
|
||||
app: $(app)
|
||||
16
development/get-git-repo.yaml
Normal file
16
development/get-git-repo.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- execute:
|
||||
description: "Get git repo and owner name"
|
||||
exec: "git"
|
||||
dir: "."
|
||||
args:
|
||||
- "config"
|
||||
- "--get"
|
||||
- "remote.origin.url"
|
||||
parsers:
|
||||
- name: "Get gitRepo"
|
||||
parser: "regexp"
|
||||
expression: "(?m)(?P<text>\\w*).git$"
|
||||
variables:
|
||||
- "gitRepo"
|
||||
73
development/manage-version.yaml
Normal file
73
development/manage-version.yaml
Normal file
@@ -0,0 +1,73 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
|
||||
tasks:
|
||||
- execute:
|
||||
description: "Git Hash"
|
||||
exec: "git"
|
||||
dir: "."
|
||||
args:
|
||||
- "rev-parse"
|
||||
- "HEAD"
|
||||
parsers:
|
||||
- name: "Parse Text"
|
||||
expression: "(.*)"
|
||||
parser: "regexp"
|
||||
variables:
|
||||
- "githash"
|
||||
|
||||
- loadVersion:
|
||||
description: "Load version file and increment release level"
|
||||
varName: "version"
|
||||
file: ".mstr.json"
|
||||
increment: $(release)
|
||||
|
||||
- saveVersion:
|
||||
description: "Save version file"
|
||||
varName: "version"
|
||||
file: ".mstr.json"
|
||||
|
||||
- execute:
|
||||
description: "Git Add Changes"
|
||||
exec: "git"
|
||||
dir: "."
|
||||
args:
|
||||
- "add"
|
||||
- ".mstr.json"
|
||||
|
||||
- execute:
|
||||
description: "Git Commit Changes"
|
||||
exec: "git"
|
||||
dir: "."
|
||||
args:
|
||||
- "commit"
|
||||
- "-m"
|
||||
- "Version file updated"
|
||||
|
||||
- execute:
|
||||
description: "Git Push Changes"
|
||||
exec: "git"
|
||||
dir: "."
|
||||
args:
|
||||
- "push"
|
||||
- "--all"
|
||||
|
||||
- execute:
|
||||
description: "Release Version"
|
||||
exec: "curl"
|
||||
args:
|
||||
- "-sS"
|
||||
- "-X"
|
||||
- "POST"
|
||||
- "-H"
|
||||
- "Authorization: token $(decrypt(gitToken,keyfile))"
|
||||
- "-H"
|
||||
- "Content-Type: application/json"
|
||||
- "@(git)/api/v1/repos/golang/$(gitRepo)/releases"
|
||||
- "-d"
|
||||
- '{"tag_name": "$(version)","name": "$(version)","body": "## Changes\n- Release via API","draft": false,"prerelease": false}'
|
||||
parsers:
|
||||
- name: "Get release ID"
|
||||
parser: "jq"
|
||||
expression: ".id"
|
||||
variables:
|
||||
- "releaseId"
|
||||
18
development/release-app.yaml
Normal file
18
development/release-app.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- call:
|
||||
script: "@(development)/release-target.yaml"
|
||||
args:
|
||||
version: $(version)
|
||||
githash: $(githash)
|
||||
release: $(release)
|
||||
releaseId: $(releaseId)
|
||||
target: $(target)
|
||||
name: $(app.name)
|
||||
gitToken: $(gitToken)
|
||||
unixPassword: $(unixPassword)
|
||||
installPath: $(installPath)
|
||||
keyfile: $(keyfile)
|
||||
loop:
|
||||
values: $(app.targets)
|
||||
as: target
|
||||
85
development/release-target.yaml
Normal file
85
development/release-target.yaml
Normal file
@@ -0,0 +1,85 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- set:
|
||||
description: "Set default destination dir"
|
||||
variables:
|
||||
- varName: destDir
|
||||
value: "$(tempdir())/$(target.buildGoos)-$(target.buildGoarch)"
|
||||
|
||||
- execute:
|
||||
description: "Create destination dir"
|
||||
exec: "mkdir"
|
||||
args:
|
||||
- "-p"
|
||||
- "$(destDir)"
|
||||
|
||||
- execute:
|
||||
description: "Build $(target.buildGoos)-$(target.buildGoarch)"
|
||||
exec: "go"
|
||||
dir: "cmd/$(name)"
|
||||
env:
|
||||
GOOS: "$(target.buildGoos)"
|
||||
GOARCH: "$(target.buildGoarch)"
|
||||
args:
|
||||
- "build"
|
||||
- "-o"
|
||||
- "$(destDir)/$(name)"
|
||||
- "-ldflags"
|
||||
- "-X main.Version=$(version) -X main.Githash=$(githash) -s -w"
|
||||
|
||||
- tar:
|
||||
description: "Compress binary with tar"
|
||||
source: "$(destDir)/$(name)"
|
||||
archiveFile: "$(destDir)/$(name)_$(version)_$(target.buildGoos)-$(target.buildGoarch).tar.gz"
|
||||
gzip: true
|
||||
|
||||
- sha256:
|
||||
description: "Compute checksum from tar file"
|
||||
file: "$(destDir)/$(name)_$(version)_$(target.buildGoos)-$(target.buildGoarch).tar.gz"
|
||||
varName: "checksum"
|
||||
|
||||
- write:
|
||||
description: "Save checksum to ...sha256 file"
|
||||
format: "$(checksum)"
|
||||
file: "$(destDir)/$(name)_$(version)_$(target.buildGoos)-$(target.buildGoarch).sha256"
|
||||
|
||||
- execute:
|
||||
description: "Upload Tar File"
|
||||
exec: "curl"
|
||||
args:
|
||||
- "-sS"
|
||||
- "-X"
|
||||
- "POST"
|
||||
- "-H"
|
||||
- "Authorization: token $(decrypt(gitToken,keyfile))"
|
||||
- "-H"
|
||||
- "Content-Type: application/octet-stream"
|
||||
- "--data-binary"
|
||||
- "@$(destDir)/$(name)_$(version)_$(target.buildGoos)-$(target.buildGoarch).tar.gz"
|
||||
- "@(git)/api/v1/repos/golang/$(name)/releases/$(releaseId)/assets?name=$(name)_$(version)_$(target.buildGoos)-$(target.buildGoarch).tar.gz"
|
||||
|
||||
- execute:
|
||||
description: "Upload Checksum File"
|
||||
exec: "curl"
|
||||
args:
|
||||
- "-sS"
|
||||
- "-X"
|
||||
- "POST"
|
||||
- "-H"
|
||||
- "Authorization: token $(decrypt(gitToken,keyfile))"
|
||||
- "-H"
|
||||
- "Content-Type: application/octet-stream"
|
||||
- "--data-binary"
|
||||
- "@$(destDir)/$(name)_$(version)_$(target.buildGoos)-$(target.buildGoarch).sha256"
|
||||
- "@(git)/api/v1/repos/golang/$(name)/releases/$(releaseId)/assets?name=$(name)_$(version)_$(target.buildGoos)-$(target.buildGoarch).sha256"
|
||||
|
||||
- execute:
|
||||
description: "Install binary"
|
||||
stdin: "$(decrypt(unixPassword,keyfile))"
|
||||
exec: "sudo"
|
||||
args:
|
||||
- "--stdin"
|
||||
- "cp"
|
||||
- "$(tempdir())/$(GOOS)-$(GOARCH)/$(name)"
|
||||
- "$(installPath)"
|
||||
when: $(installPath != nil && target.buildGoos == GOOS && target.buildGoarch == GOARCH)
|
||||
92
development/release.yaml
Normal file
92
development/release.yaml
Normal file
@@ -0,0 +1,92 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
arguments:
|
||||
- name: "release"
|
||||
description: "release one of major,minor or patch"
|
||||
|
||||
options:
|
||||
- name: "test"
|
||||
default: true
|
||||
description: "test"
|
||||
type: "bool"
|
||||
|
||||
- name: "verbose"
|
||||
default: false
|
||||
description: "verbose testing"
|
||||
type: "bool"
|
||||
|
||||
- name: "integration"
|
||||
default: true
|
||||
description: "integration testing"
|
||||
type: "bool"
|
||||
|
||||
- name: "keyfile"
|
||||
default: "$(homedir())/.mstr.pem"
|
||||
description: "Keyfile for encrypting"
|
||||
type: "string"
|
||||
|
||||
- name: "deploy"
|
||||
default: false
|
||||
description: "Deploy application"
|
||||
type: "bool"
|
||||
|
||||
tasks:
|
||||
- call:
|
||||
script: "@(development)/compile.yaml"
|
||||
args:
|
||||
release: $(release)
|
||||
test: $(test)
|
||||
verbose: $(verbose)
|
||||
integration: $(integration)
|
||||
|
||||
- call:
|
||||
script: "@(development)/check-git-repository.yaml"
|
||||
|
||||
- call:
|
||||
script: "@(development)/get-git-repo.yaml"
|
||||
returns:
|
||||
- "gitRepo"
|
||||
|
||||
- call:
|
||||
script: "@(development)/manage-version.yaml"
|
||||
args:
|
||||
keyfile: $(keyfile)
|
||||
release: $(release)
|
||||
gitToken: $(git_token)
|
||||
gitRepo: $(gitRepo)
|
||||
returns:
|
||||
- "version"
|
||||
- "githash"
|
||||
- "releaseId"
|
||||
|
||||
- call:
|
||||
script: "@(development)/release-app.yaml"
|
||||
args:
|
||||
version: $(version)
|
||||
githash: $(githash)
|
||||
release: $(release)
|
||||
releaseId: $(releaseId)
|
||||
app: $(app)
|
||||
keyfile: $(keyfile)
|
||||
gitToken: $(git_token)
|
||||
unixPassword: $(unix_password)
|
||||
installPath: $(install_path)
|
||||
loop:
|
||||
values: $(apps)
|
||||
as: app
|
||||
|
||||
- execute:
|
||||
description: "Git pull tags"
|
||||
exec: "git"
|
||||
dir: "."
|
||||
args:
|
||||
- "pull"
|
||||
- "--tags"
|
||||
|
||||
- call:
|
||||
script: "@(development)/deploy-app.yaml"
|
||||
loop:
|
||||
values: $(apps)
|
||||
as: app
|
||||
args:
|
||||
app: $(app)
|
||||
when: $(deploy)
|
||||
26
development/update.yaml
Normal file
26
development/update.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- execute:
|
||||
description: "Update Dependencies"
|
||||
exec: "go"
|
||||
dir: "."
|
||||
args:
|
||||
- "get"
|
||||
- "-u"
|
||||
- "./..."
|
||||
|
||||
- execute:
|
||||
description: "Update Vendor"
|
||||
exec: "go"
|
||||
dir: "."
|
||||
args:
|
||||
- "mod"
|
||||
- "vendor"
|
||||
|
||||
- execute:
|
||||
description: "Clean Dependencies"
|
||||
exec: "go"
|
||||
dir: "."
|
||||
args:
|
||||
- "mod"
|
||||
- "tidy"
|
||||
13
development/upload.yaml
Normal file
13
development/upload.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- execute:
|
||||
description: "Upload Tasks"
|
||||
exec: "mc"
|
||||
args:
|
||||
- "cp"
|
||||
- "--quiet"
|
||||
- "$(file)"
|
||||
- "jesof/artifactory/$(file)"
|
||||
loop:
|
||||
values: $(dirlist("tasks/", dirlistRecursive(), dirlistWithFilesOnly(), dirlistWithGlob("*.yaml")))
|
||||
as: "file"
|
||||
3
development/version.yaml
Normal file
3
development/version.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
# Orchestra version variables
|
||||
|
||||
app_version: "{{.version}}"
|
||||
Reference in New Issue
Block a user