From 23da3d20b502d2a81a1e8df872a2b3bd4a460785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Jenzer?= Date: Mon, 26 Jan 2026 15:36:52 +0100 Subject: [PATCH] first commit --- development/build.yaml | 39 ++++++ development/check-git-repository.yaml | 16 +++ development/commands.yaml | 24 ++++ development/compile.yaml | 48 +++++++ development/deploy-app.yaml | 16 +++ development/deploy-target.yaml | 53 ++++++++ development/deploy.yaml | 9 ++ development/get-git-repo.yaml | 16 +++ development/manage-version.yaml | 73 +++++++++++ development/release-app.yaml | 18 +++ development/release-target.yaml | 85 +++++++++++++ development/release.yaml | 92 ++++++++++++++ development/update.yaml | 26 ++++ development/upload.yaml | 13 ++ development/version.yaml | 3 + system/backup.yaml | 34 +++++ system/backup_commands.yaml | 5 + system/check-git-repository.yaml | 11 ++ system/repos.yaml | 9 ++ system/repos_actions.yaml | 47 +++++++ system/repos_commands.yaml | 5 + system/upgrade.yaml | 28 ++++ system/upgrade_applications.yaml | 19 +++ system/upgrade_applications_config.yaml | 56 ++++++++ system/upgrade_applications_version.yaml | 3 + system/upgrade_commands.yaml | 17 +++ system/upgrade_github_application.yaml | 148 ++++++++++++++++++++++ system/upgrade_orchestra_application.yaml | 21 +++ system/upgrade_project.yaml | 78 ++++++++++++ system/upgrade_projects.yaml | 10 ++ 30 files changed, 1022 insertions(+) create mode 100644 development/build.yaml create mode 100644 development/check-git-repository.yaml create mode 100644 development/commands.yaml create mode 100644 development/compile.yaml create mode 100644 development/deploy-app.yaml create mode 100644 development/deploy-target.yaml create mode 100644 development/deploy.yaml create mode 100644 development/get-git-repo.yaml create mode 100644 development/manage-version.yaml create mode 100644 development/release-app.yaml create mode 100644 development/release-target.yaml create mode 100644 development/release.yaml create mode 100644 development/update.yaml create mode 100644 development/upload.yaml create mode 100644 development/version.yaml create mode 100644 system/backup.yaml create mode 100644 system/backup_commands.yaml create mode 100644 system/check-git-repository.yaml create mode 100644 system/repos.yaml create mode 100644 system/repos_actions.yaml create mode 100644 system/repos_commands.yaml create mode 100644 system/upgrade.yaml create mode 100644 system/upgrade_applications.yaml create mode 100644 system/upgrade_applications_config.yaml create mode 100644 system/upgrade_applications_version.yaml create mode 100644 system/upgrade_commands.yaml create mode 100644 system/upgrade_github_application.yaml create mode 100644 system/upgrade_orchestra_application.yaml create mode 100644 system/upgrade_project.yaml create mode 100644 system/upgrade_projects.yaml diff --git a/development/build.yaml b/development/build.yaml new file mode 100644 index 0000000..5f9379b --- /dev/null +++ b/development/build.yaml @@ -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) diff --git a/development/check-git-repository.yaml b/development/check-git-repository.yaml new file mode 100644 index 0000000..2bf368a --- /dev/null +++ b/development/check-git-repository.yaml @@ -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 != "") diff --git a/development/commands.yaml b/development/commands.yaml new file mode 100644 index 0000000..0c53b7a --- /dev/null +++ b/development/commands.yaml @@ -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" + diff --git a/development/compile.yaml b/development/compile.yaml new file mode 100644 index 0000000..206eadc --- /dev/null +++ b/development/compile.yaml @@ -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) diff --git a/development/deploy-app.yaml b/development/deploy-app.yaml new file mode 100644 index 0000000..233e26a --- /dev/null +++ b/development/deploy-app.yaml @@ -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) diff --git a/development/deploy-target.yaml b/development/deploy-target.yaml new file mode 100644 index 0000000..940fdac --- /dev/null +++ b/development/deploy-target.yaml @@ -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 ###" diff --git a/development/deploy.yaml b/development/deploy.yaml new file mode 100644 index 0000000..302b459 --- /dev/null +++ b/development/deploy.yaml @@ -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) diff --git a/development/get-git-repo.yaml b/development/get-git-repo.yaml new file mode 100644 index 0000000..c70fe63 --- /dev/null +++ b/development/get-git-repo.yaml @@ -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\\w*).git$" + variables: + - "gitRepo" diff --git a/development/manage-version.yaml b/development/manage-version.yaml new file mode 100644 index 0000000..e647c11 --- /dev/null +++ b/development/manage-version.yaml @@ -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" diff --git a/development/release-app.yaml b/development/release-app.yaml new file mode 100644 index 0000000..12c9273 --- /dev/null +++ b/development/release-app.yaml @@ -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 diff --git a/development/release-target.yaml b/development/release-target.yaml new file mode 100644 index 0000000..aedb50e --- /dev/null +++ b/development/release-target.yaml @@ -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) diff --git a/development/release.yaml b/development/release.yaml new file mode 100644 index 0000000..658dbcb --- /dev/null +++ b/development/release.yaml @@ -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) diff --git a/development/update.yaml b/development/update.yaml new file mode 100644 index 0000000..4c0755f --- /dev/null +++ b/development/update.yaml @@ -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" diff --git a/development/upload.yaml b/development/upload.yaml new file mode 100644 index 0000000..2535849 --- /dev/null +++ b/development/upload.yaml @@ -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" diff --git a/development/version.yaml b/development/version.yaml new file mode 100644 index 0000000..6803e45 --- /dev/null +++ b/development/version.yaml @@ -0,0 +1,3 @@ +# Orchestra version variables + +app_version: "{{.version}}" diff --git a/system/backup.yaml b/system/backup.yaml new file mode 100644 index 0000000..0ba0f02 --- /dev/null +++ b/system/backup.yaml @@ -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/*" + - "." diff --git a/system/backup_commands.yaml b/system/backup_commands.yaml new file mode 100644 index 0000000..8b5645e --- /dev/null +++ b/system/backup_commands.yaml @@ -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" diff --git a/system/check-git-repository.yaml b/system/check-git-repository.yaml new file mode 100644 index 0000000..06e446c --- /dev/null +++ b/system/check-git-repository.yaml @@ -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" diff --git a/system/repos.yaml b/system/repos.yaml new file mode 100644 index 0000000..0bcf42f --- /dev/null +++ b/system/repos.yaml @@ -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 diff --git a/system/repos_actions.yaml b/system/repos_actions.yaml new file mode 100644 index 0000000..fe780cd --- /dev/null +++ b/system/repos_actions.yaml @@ -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" diff --git a/system/repos_commands.yaml b/system/repos_commands.yaml new file mode 100644 index 0000000..f5919dd --- /dev/null +++ b/system/repos_commands.yaml @@ -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" diff --git a/system/upgrade.yaml b/system/upgrade.yaml new file mode 100644 index 0000000..570cfe8 --- /dev/null +++ b/system/upgrade.yaml @@ -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 diff --git a/system/upgrade_applications.yaml b/system/upgrade_applications.yaml new file mode 100644 index 0000000..bcf2c20 --- /dev/null +++ b/system/upgrade_applications.yaml @@ -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 diff --git a/system/upgrade_applications_config.yaml b/system/upgrade_applications_config.yaml new file mode 100644 index 0000000..f442740 --- /dev/null +++ b/system/upgrade_applications_config.yaml @@ -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" diff --git a/system/upgrade_applications_version.yaml b/system/upgrade_applications_version.yaml new file mode 100644 index 0000000..6803e45 --- /dev/null +++ b/system/upgrade_applications_version.yaml @@ -0,0 +1,3 @@ +# Orchestra version variables + +app_version: "{{.version}}" diff --git a/system/upgrade_commands.yaml b/system/upgrade_commands.yaml new file mode 100644 index 0000000..4db94c8 --- /dev/null +++ b/system/upgrade_commands.yaml @@ -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" diff --git a/system/upgrade_github_application.yaml b/system/upgrade_github_application.yaml new file mode 100644 index 0000000..e920e58 --- /dev/null +++ b/system/upgrade_github_application.yaml @@ -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" diff --git a/system/upgrade_orchestra_application.yaml b/system/upgrade_orchestra_application.yaml new file mode 100644 index 0000000..4018ad3 --- /dev/null +++ b/system/upgrade_orchestra_application.yaml @@ -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")) diff --git a/system/upgrade_project.yaml b/system/upgrade_project.yaml new file mode 100644 index 0000000..dd1035c --- /dev/null +++ b/system/upgrade_project.yaml @@ -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" diff --git a/system/upgrade_projects.yaml b/system/upgrade_projects.yaml new file mode 100644 index 0000000..851e571 --- /dev/null +++ b/system/upgrade_projects.yaml @@ -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