all repos — min @ a78d9cb90091d81450cbf3e85f42bd8e5ed7ae63

A small but practical concatenative programming language.

Started implementing asset management.
h3rald h3rald@h3rald.com
Sun, 06 Dec 2020 18:20:50 +0100
commit

a78d9cb90091d81450cbf3e85f42bd8e5ed7ae63

parent

435af004eb27b9d60cb97f99a9b40a4e48c73986

2 files changed, 48 insertions(+), 14 deletions(-)

jump to
M tasks/github.mintasks/github.min

@@ -1,18 +1,20 @@

+#!/usr/bin/env min + +; Read files ".env.yml" fread from-yaml :vars "min.yml" fread from-yaml :config -config /version :min-version -"current-release.md" fread escape :release-body +"next-release.md" fread escape :release-body "tasks/templates/draft-release.json" fread :draft-release-template -draft-release-template ("version" min-version "body" release-body) =% :draft-release-body -config /version :minversion +config /version :min-version vars /github-token :token +draft-release-template ("version" min-version "body" release-body) =% :draft-release-body -;"https://api.github.com/repos/h3rald/min/releases/$#/assets" (id) =% :assets-url -"https://api.github.com/repos/h3rald/min/releases" :releases-url +; Helper symbols {} - "token $#" (token) =% %Authorization :headers -headers + "application/vnd.github.v3+json" %Accept + "token $#" (token) =% %Authorization +:headers ( response to-json "response.json" fwrite

@@ -24,15 +26,18 @@ status string @status

"Error $#: $#" (status message) =% error status int exit ) when ) :handle-errors - ( :data data /endpoint :endpoint + "api" :subdomain "https://api.github.com/repos/h3rald/min$#" (endpoint) =% :url {} url %url data /method %method - headers %headers + (data ?headers) + (data /headers %headers) + (headers %headers) + if (data ?body) (data /body %body) when request :response response /status :status

@@ -40,6 +45,8 @@ response /body :body

handle-errors body from-json ) :gh-req + +; Module symbols ( {} "/releases" %endpoint

@@ -48,8 +55,8 @@ draft-release-body %body

gh-req /id string :id ; Save Release ID to min.yml config id %id to-yaml "min.yml" fwrite - "Draft release v$# ($#) created successfully" (minversion id) =% notice -) %draft-release + "Draft release v$# ($#) created successfully" (min-version id) =% notice +) %draft ( config /id :id {}

@@ -57,8 +64,35 @@ "/releases/$#" (id) =% %endpoint

"PATCH" %method draft-release-body %body gh-req /id string :id - "Draft release v$# ($#) updated successfully" (minversion id) =% notice -) %update-release + "Draft release v$# ($#) updated successfully" (min-version id) =% notice +) %update +( + config /id :id + {} + "/releases/$#/assets" (id) =% %endpoint + "GET" %method + gh-req =assets + assets size :total + "There are $# assets in release $#" (total min-version) =% notice + assets ("- $#" swap cons % notice) foreach + assets +) %assets +( + config /id :id + . ls ("\.zip$" match) filter + ( + filename :file + "Uploading: $#" (file) =% notice + file fread :body + headers "application/zip" %Content-Type :asset-headers + {} + "/releases/$#/assets" (id) =% %endpoint + asset-headers %headers + "POST" %method + body %body + gh-req + ) foreach +) %upload +github-tasks