all repos — min @ 435af004eb27b9d60cb97f99a9b40a4e48c73986

A small but practical concatenative programming language.

tasks/github.min

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
".env.yml" fread from-yaml :vars
"min.yml" fread from-yaml :config
config /version :min-version
"current-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
vars /github-token :token

;"https://api.github.com/repos/h3rald/min/releases/$#/assets" (id) =% :assets-url
"https://api.github.com/repos/h3rald/min/releases" :releases-url
{}  
  "token $#" (token) =% %Authorization  :headers
headers

(
  response to-json "response.json" fwrite
  response /body from-json :body
  response /status :status
  (status 300 >) (
    body /message :message
    status string @status
    "Error $#: $#" (status message) =% error status int exit
  ) when
) :handle-errors

(
  :data
  data /endpoint :endpoint
  "https://api.github.com/repos/h3rald/min$#" (endpoint) =% :url
  {}
    url %url
    data /method %method
    headers %headers
    (data ?body) (data /body %body) when
  request :response 
  response /status :status
  response /body :body
  handle-errors
  body from-json
) :gh-req
(
  {}
    "/releases" %endpoint
    "POST" %method
    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
(
  config /id :id
  {}
    "/releases/$#" (id) =% %endpoint
    "PATCH" %method
    draft-release-body %body
  gh-req /id string :id
  "Draft release v$# ($#) updated successfully" (minversion id) =% notice
) %update-release
+github-tasks