@@ -7,20 +7,36 @@ error () {
77}
88
99readonly ops_repo=" input-output-hk/plutus-ops"
10+ readonly ops_branch=" master"
1011readonly plutus_rev=" ${GITHUB_SHA:- } "
12+
1113if [ -z " ${plutus_rev} " ]
1214then
1315 error " GITHUB_SHA environment variable not set!"
1416fi
1517
16- # ## Argument parsing
18+ readonly plutus_ref= " ${GITHUB_REF_SLUG :- } "
1719
18- if [ " $# " -ne 1 ]
20+ if [ -z " ${plutus_ref} " ]
1921then
20- error " USAGE: $0 OPS_BRANCH "
22+ error " GITHUB_REF_SLUG environment variable not set! "
2123fi
2224
23- readonly ops_branch=" $1 "
25+ declare -A ref_env_mapping=(
26+ # TODO Make this the production branch
27+ [bitte]=production
28+ )
29+
30+ if [ ! -v ' ref_env_mapping[${plutus_ref}]' ]
31+ then
32+ error " Ref ${plutus_ref} does not correspond to any known env"
33+ fi
34+ plutus_env=" ${ref_env_mapping[${plutus_ref}]} "
35+
36+ if [ " $# " -ne 0 ]
37+ then
38+ error " USAGE: $0 "
39+ fi
2440
2541# ## Set up scratch space
2642
@@ -38,31 +54,31 @@ tmp="$(mktemp -d)"
3854
3955declare -r tmp
4056
41- # ## Write the new plutus-rev. cue
57+ # ## Write the new revision cue file
4258
43- cat > " ${tmp} /plutus-rev .cue" << EOF
44- package bitte
59+ cat > " ${tmp} /${plutus_env} .cue" << EOF
60+ package revisions
4561
46- plutusRev : "${plutus_rev} "
62+ ${plutus_env} : "${plutus_rev} "
4763EOF
4864
4965
5066
51- # ## Get the old plutus-rev. cue, exit if it's unchanged
52- hub api -XGET -F ref=" ${ops_branch} " " /repos/${ops_repo} /contents/plutus-rev .cue" > " ${tmp} /plutus-rev .cue-contents.json"
53- prev_hash=" $( jq --join-output ' .sha' < " ${tmp} /plutus-rev .cue-contents.json" ) "
54- jq --join-output ' .content' < " ${tmp} /plutus-rev .cue-contents.json" | base64 -d > " ${tmp} /plutus-rev -old.cue"
55- if diff -q " ${tmp} /plutus-rev .cue" " ${tmp} /plutus-rev -old.cue" > /dev/null
67+ # ## Get the old revision cue file , exit if it's unchanged
68+ hub api -XGET -F ref=" ${ops_branch} " " /repos/${ops_repo} /contents/revisions/ ${plutus_env} .cue" > " ${tmp} /${plutus_env} .cue-contents.json"
69+ prev_hash=" $( jq --join-output ' .sha' < " ${tmp} /${plutus_env} .cue-contents.json" ) "
70+ jq --join-output ' .content' < " ${tmp} /${plutus_env} .cue-contents.json" | base64 -d > " ${tmp} /${plutus_env} -old.cue"
71+ if diff -q " ${tmp} /${plutus_env} .cue" " ${tmp} /${plutus_env} -old.cue" > /dev/null
5672then
5773 exit 0
5874fi
5975
60- # ## Commit the new plutus-rev. cue
61- base64 " ${tmp} /plutus-rev .cue" > " ${tmp} /plutus-rev .cue-encoded"
62- echo " Automatic update : Bump plutus to ${plutus_rev} " > " ${tmp} /commit-message"
76+ # ## Commit the new revision cue file
77+ base64 " ${tmp} /${plutus_env} .cue" > " ${tmp} /${plutus_env} .cue-encoded"
78+ echo " ${plutus_env} : Bump plutus to ${plutus_rev} " > " ${tmp} /commit-message"
6379hub api -XPUT \
6480 -F message=@" ${tmp} /commit-message" \
65- -F content=@" ${tmp} /plutus-rev .cue-encoded" \
81+ -F content=@" ${tmp} /${plutus_env} .cue-encoded" \
6682 -F sha=" ${prev_hash} " \
6783 -F branch=" ${ops_branch} " \
68- " /repos/${ops_repo} /contents/plutus-rev .cue"
84+ " /repos/${ops_repo} /contents/revisions/ ${plutus_env} .cue"
0 commit comments