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}}"
|
||||
34
system/backup.yaml
Normal file
34
system/backup.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- set:
|
||||
variables:
|
||||
- varName: "volume"
|
||||
value: "/Volumes/Backup-1"
|
||||
|
||||
- set:
|
||||
variables:
|
||||
- varName: "volume"
|
||||
value: "/Volumes/Backup-2"
|
||||
when: $(dirExists("/Volumes/Backup-2"))
|
||||
|
||||
- execute:
|
||||
description: "Start backup rp02"
|
||||
exec: "rsync"
|
||||
timeout: 6h
|
||||
dir: "$(volume)"
|
||||
args:
|
||||
- "-a"
|
||||
- "-v"
|
||||
- "root@rp02.localnet:/backup/*"
|
||||
- "."
|
||||
|
||||
- execute:
|
||||
description: "Start backup rp03"
|
||||
exec: "rsync"
|
||||
timeout: 6h
|
||||
dir: "$(volume)"
|
||||
args:
|
||||
- "-a"
|
||||
- "-v"
|
||||
- "root@rp03.localnet:/backup/*"
|
||||
- "."
|
||||
5
system/backup_commands.yaml
Normal file
5
system/backup_commands.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-commands-schema.json
|
||||
commands:
|
||||
- name: "backup"
|
||||
description: "Start system backup"
|
||||
script: "@(system)/backup.yaml"
|
||||
11
system/check-git-repository.yaml
Normal file
11
system/check-git-repository.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
# 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: $(path)
|
||||
args:
|
||||
- "status"
|
||||
- "--porcelain"
|
||||
response:
|
||||
name: "gitChanges"
|
||||
9
system/repos.yaml
Normal file
9
system/repos.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: "@(system)/repos_actions.yaml"
|
||||
args:
|
||||
path: $(target)
|
||||
loop:
|
||||
values: $(dirlist(".", dirlistWithDirsOnly()))
|
||||
as: target
|
||||
47
system/repos_actions.yaml
Normal file
47
system/repos_actions.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- print:
|
||||
format: "Path: $(path)"
|
||||
|
||||
- return:
|
||||
description: "Not a git repository"
|
||||
when: $(!dirExists(format("%s/.git",path)))
|
||||
|
||||
- execute:
|
||||
description: "Pull git repository"
|
||||
exec: "git"
|
||||
dir: $(path)
|
||||
args:
|
||||
- "pull"
|
||||
|
||||
- execute:
|
||||
description: "Check repository"
|
||||
exec: "git"
|
||||
dir: $(path)
|
||||
args:
|
||||
- "remote"
|
||||
- "-v"
|
||||
matchers:
|
||||
- name: "Check for jesof repository"
|
||||
expression: "^origin.*https://git.jesof.ch/"
|
||||
onError: continue
|
||||
|
||||
- return:
|
||||
description: "Not jesof repository"
|
||||
when: $(lastError() != nil)
|
||||
|
||||
- execute:
|
||||
description: "Push all"
|
||||
exec: "git"
|
||||
dir: $(path)
|
||||
args:
|
||||
- "push"
|
||||
- "--all"
|
||||
|
||||
- execute:
|
||||
description: "Push tags"
|
||||
exec: "git"
|
||||
dir: $(path)
|
||||
args:
|
||||
- "push"
|
||||
- "--tags"
|
||||
5
system/repos_commands.yaml
Normal file
5
system/repos_commands.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-commands-schema.json
|
||||
commands:
|
||||
- name: "repos"
|
||||
description: "Synchronize git repos"
|
||||
script: "@(system)/repos.yaml"
|
||||
28
system/upgrade.yaml
Normal file
28
system/upgrade.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- call:
|
||||
description: 'Upgrade project on "$(target)"'
|
||||
script: "@(system)/upgrade_project.yaml"
|
||||
args:
|
||||
path: $(target)
|
||||
loop:
|
||||
values: $(dirlist("@(projects)", dirlistWithDirsOnly()))
|
||||
as: target
|
||||
|
||||
- call:
|
||||
description: 'Upgrade github application "$(settings.name)"'
|
||||
script: "@(system)/upgrade_github_application.yaml"
|
||||
args:
|
||||
settings: $(settings)
|
||||
loop:
|
||||
values: $(github)
|
||||
as: settings
|
||||
|
||||
- call:
|
||||
description: 'Upgrade orchestra application "$(settings.role)"'
|
||||
script: "@(system)/upgrade_orchestra_application.yaml"
|
||||
args:
|
||||
settings: $(settings)
|
||||
loop:
|
||||
values: $(orchestra)
|
||||
as: settings
|
||||
19
system/upgrade_applications.yaml
Normal file
19
system/upgrade_applications.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- call:
|
||||
description: 'Upgrade github application "$(settings.name)"'
|
||||
script: "@(system)/upgrade_github_application.yaml"
|
||||
args:
|
||||
settings: $(settings)
|
||||
loop:
|
||||
values: $(github)
|
||||
as: settings
|
||||
|
||||
- call:
|
||||
description: 'Upgrade orchestra application "$(settings.role)"'
|
||||
script: "@(system)/upgrade_orchestra_application.yaml"
|
||||
args:
|
||||
settings: $(settings)
|
||||
loop:
|
||||
values: $(orchestra)
|
||||
as: settings
|
||||
56
system/upgrade_applications_config.yaml
Normal file
56
system/upgrade_applications_config.yaml
Normal file
@@ -0,0 +1,56 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-config-schema.json
|
||||
variables:
|
||||
tag_name: ""
|
||||
github:
|
||||
- name: "alertmanager"
|
||||
api_url: "https://api.github.com/repos/prometheus/alertmanager/releases/latest"
|
||||
search: "linux-arm64.tar.gz$"
|
||||
bin_file: ""
|
||||
os_family: "linux"
|
||||
architecture: "arm64"
|
||||
|
||||
- name: "coredns"
|
||||
api_url: "https://api.github.com/repos/coredns/coredns/releases/latest"
|
||||
search: "linux_arm64.tgz$"
|
||||
bin_file: ""
|
||||
os_family: "linux"
|
||||
architecture: "arm64"
|
||||
|
||||
- name: "nodeexporter"
|
||||
api_url: "https://api.github.com/repos/prometheus/node_exporter/releases/latest"
|
||||
search: "linux-arm64.tar.gz$"
|
||||
bin_file: ""
|
||||
os_family: "linux"
|
||||
architecture: "arm64"
|
||||
|
||||
- name: "prometheus"
|
||||
api_url: "https://api.github.com/repos/prometheus/prometheus/releases/latest"
|
||||
search: "linux-arm64.tar.gz$"
|
||||
bin_file: ""
|
||||
os_family: "linux"
|
||||
architecture: "arm64"
|
||||
|
||||
- name: "traefik"
|
||||
api_url: "https://api.github.com/repos/traefik/traefik/releases/latest"
|
||||
search: "linux_arm64.tar.gz$"
|
||||
bin_file: ""
|
||||
os_family: "linux"
|
||||
architecture: "arm64"
|
||||
|
||||
- name: "ttyd"
|
||||
api_url: "https://api.github.com/repos/tsl0922/ttyd/releases/latest"
|
||||
search: "ttyd.arm$"
|
||||
bin_file: "ttyd"
|
||||
os_family: "linux"
|
||||
architecture: "arm64"
|
||||
|
||||
- name: "git"
|
||||
api_url: "https://api.github.com/repos/go-gitea/gitea/releases/latest"
|
||||
health_url: "https://git.jesof.ch/api/healthz"
|
||||
search: "linux-arm64$"
|
||||
bin_file: "gitea"
|
||||
os_family: "linux"
|
||||
architecture: "arm64"
|
||||
|
||||
orchestra:
|
||||
- role: "minio"
|
||||
3
system/upgrade_applications_version.yaml
Normal file
3
system/upgrade_applications_version.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
# Orchestra version variables
|
||||
|
||||
app_version: "{{.version}}"
|
||||
17
system/upgrade_commands.yaml
Normal file
17
system/upgrade_commands.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-commands-schema.json
|
||||
commands:
|
||||
- name: "upgrade"
|
||||
description: "Upgrade projects and applications"
|
||||
script: "@(system)/upgrade.yaml"
|
||||
configs:
|
||||
- "@(system)/upgrade_applications_config.yaml"
|
||||
|
||||
- name: "upgrade-projects"
|
||||
description: "Upgrade projects"
|
||||
script: "@(system)/upgrade_projects.yaml"
|
||||
|
||||
- name: "upgrade-applications"
|
||||
description: "Upgrade applications"
|
||||
script: "@(system)/upgrade_applications.yaml"
|
||||
configs:
|
||||
- "@(system)/upgrade_applications_config.yaml"
|
||||
148
system/upgrade_github_application.yaml
Normal file
148
system/upgrade_github_application.yaml
Normal file
@@ -0,0 +1,148 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- execute:
|
||||
description: "Get URL for latest version"
|
||||
exec: "curl"
|
||||
hideStdout: true
|
||||
args:
|
||||
- "-s"
|
||||
- "$(settings.api_url)"
|
||||
parsers:
|
||||
- name: "Get Download URL"
|
||||
parser: "jq"
|
||||
expression: '.assets[] | select(.name | test("$(settings.search)")) | .browser_download_url'
|
||||
variables:
|
||||
- download_url
|
||||
- name: "Get Tag Name"
|
||||
parser: "jq"
|
||||
expression: ".tag_name"
|
||||
variables:
|
||||
- tag_name
|
||||
|
||||
- set:
|
||||
description: "Set variables"
|
||||
variables:
|
||||
- varName: "new_version"
|
||||
value: '$(trimPrefix(tag_name,"v"))'
|
||||
- varName: "archive_file"
|
||||
value: '$(settings.name)_$(trimPrefix(tag_name,"v"))_$(settings.os_family)-$(settings.architecture).tar.gz'
|
||||
- varName: "sha256_file"
|
||||
value: '$(settings.name)_$(trimPrefix(tag_name,"v"))_$(settings.os_family)-$(settings.architecture).sha256'
|
||||
|
||||
- loadVariables:
|
||||
description: "Load variables for $(settings.name)"
|
||||
url: "@(provisioning)/roles/$(settings.name)/vars/version.yaml"
|
||||
|
||||
- return:
|
||||
description: "Latest version installed $(new_version)"
|
||||
when: $(new_version == app_version)
|
||||
|
||||
- execute:
|
||||
description: "Download application from $(download_url)"
|
||||
exec: "curl"
|
||||
args:
|
||||
- "-L"
|
||||
- "--silent"
|
||||
- "-o"
|
||||
- "$(tempdir())/$(archive_file)"
|
||||
- "$(download_url)"
|
||||
|
||||
- execute:
|
||||
exec: "mv"
|
||||
args:
|
||||
- "$(tempdir())/$(archive_file)"
|
||||
- "$(tempdir())/$(settings.bin_file)"
|
||||
when: '$(settings.bin_file != "")'
|
||||
|
||||
- tar:
|
||||
source: "$(tempdir())/$(settings.bin_file)"
|
||||
archiveFile: "$(tempdir())/$(archive_file)"
|
||||
when: '$(settings.bin_file != "")'
|
||||
|
||||
- sha256:
|
||||
description: "Calculate checksum"
|
||||
file: "$(tempdir())/$(archive_file)"
|
||||
varName: "checkSum"
|
||||
|
||||
- write:
|
||||
description: "Save checksum file $(sha256_file) "
|
||||
file: "$(tempdir())/$(sha256_file)"
|
||||
format: "%s"
|
||||
args:
|
||||
- "$(checkSum)"
|
||||
|
||||
- execute:
|
||||
description: "Upload application $(archive_file)"
|
||||
exec: "mc"
|
||||
args:
|
||||
- "cp"
|
||||
- "--quiet"
|
||||
- "$(tempdir())/$(archive_file)"
|
||||
- "jesof/binaries/$(archive_file)"
|
||||
|
||||
- execute:
|
||||
description: "Upload checksum $(sha256_file)"
|
||||
exec: "mc"
|
||||
args:
|
||||
- "cp"
|
||||
- "--quiet"
|
||||
- "$(tempdir())/$(sha256_file)"
|
||||
- "jesof/binaries/$(sha256_file)"
|
||||
|
||||
- call:
|
||||
script: "@(system)/check-git-repository.yaml"
|
||||
args:
|
||||
path: "@(provisioning)"
|
||||
returns:
|
||||
- gitChanges
|
||||
|
||||
- throw:
|
||||
description: "Check if repository is clean"
|
||||
message: 'Git repository "@(provisioning)" not clean, please commit changes ...'
|
||||
when: $(gitChanges != "")
|
||||
|
||||
- template:
|
||||
templates:
|
||||
- "@(system)/upgrade_applications_version.yaml"
|
||||
target: "@(provisioning)/roles/$(settings.name)/vars/version.yaml"
|
||||
args:
|
||||
version: "$(new_version)"
|
||||
|
||||
- execute:
|
||||
description: "Deploy $(settings.name)"
|
||||
exec: "orchestra"
|
||||
dir: "@(provisioning)"
|
||||
args:
|
||||
- "-roles"
|
||||
- "$(settings.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"
|
||||
- "."
|
||||
|
||||
- execute:
|
||||
dir: "@(provisioning)"
|
||||
exec: "git"
|
||||
args:
|
||||
- "commit"
|
||||
- "-m"
|
||||
- "New $(settings.name) release"
|
||||
|
||||
- execute:
|
||||
dir: "@(provisioning)"
|
||||
exec: "git"
|
||||
args:
|
||||
- "push"
|
||||
21
system/upgrade_orchestra_application.yaml
Normal file
21
system/upgrade_orchestra_application.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- execute:
|
||||
description: "Deploy $(settings.role)"
|
||||
exec: "orchestra"
|
||||
dir: "@(provisioning)"
|
||||
args:
|
||||
- "-roles"
|
||||
- "$(settings.role)"
|
||||
- "-tags"
|
||||
- "update"
|
||||
|
||||
- execute:
|
||||
description: "Check health endpoint"
|
||||
exec: "curl"
|
||||
args:
|
||||
- "--retry"
|
||||
- "10"
|
||||
- "--silent"
|
||||
- $(settings.health_url)
|
||||
when: $(has("settings.health_url"))
|
||||
78
system/upgrade_project.yaml
Normal file
78
system/upgrade_project.yaml
Normal file
@@ -0,0 +1,78 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- loadVariables:
|
||||
url: $(path)/.mstr.yaml
|
||||
path: "variables"
|
||||
|
||||
- return:
|
||||
when: $(!has("orchestra"))
|
||||
|
||||
- return:
|
||||
when: $(orchestra != "deploy")
|
||||
|
||||
- call:
|
||||
script: "@(system)/check-git-repository.yaml"
|
||||
args:
|
||||
path: $(path)
|
||||
returns:
|
||||
- gitChanges
|
||||
|
||||
- throw:
|
||||
description: "Check if repository is clean"
|
||||
message: 'Git repository "$(path)" not clean, please commit changes ...'
|
||||
when: $(gitChanges != "")
|
||||
|
||||
- execute:
|
||||
description: "Update application $(path)"
|
||||
exec: "mstr"
|
||||
dir: "$(path)"
|
||||
args:
|
||||
- "update"
|
||||
|
||||
- call:
|
||||
script: "@(system)/check-git-repository.yaml"
|
||||
args:
|
||||
path: $(path)
|
||||
returns:
|
||||
- gitChanges
|
||||
|
||||
- return:
|
||||
description: 'Git repository "$(path)" clean, continue ...'
|
||||
when: $(gitChanges == "")
|
||||
|
||||
- execute:
|
||||
description: "Update application $(path)"
|
||||
exec: "mstr"
|
||||
dir: "$(path)"
|
||||
args:
|
||||
- "build"
|
||||
|
||||
- execute:
|
||||
dir: "$(path)"
|
||||
exec: "git"
|
||||
args:
|
||||
- "add"
|
||||
- "."
|
||||
|
||||
- execute:
|
||||
dir: "$(path)"
|
||||
exec: "git"
|
||||
args:
|
||||
- "commit"
|
||||
- "-m"
|
||||
- "Dependency upgrades"
|
||||
|
||||
- execute:
|
||||
dir: "$(path)"
|
||||
exec: "git"
|
||||
args:
|
||||
- "push"
|
||||
|
||||
- execute:
|
||||
description: "Release application $(path)"
|
||||
dir: "$(path)"
|
||||
exec: "mstr"
|
||||
args:
|
||||
- "release"
|
||||
- "minor"
|
||||
- "--deploy"
|
||||
10
system/upgrade_projects.yaml
Normal file
10
system/upgrade_projects.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- call:
|
||||
description: 'Upgrade project on "$(target)"'
|
||||
script: "@(system)/upgrade_project.yaml"
|
||||
args:
|
||||
path: $(target)
|
||||
loop:
|
||||
values: $(dirlist("@(projects)", dirlistWithDirsOnly()))
|
||||
as: target
|
||||
Reference in New Issue
Block a user