@@ -43,6 +43,67 @@ function restoreVendorFolder {
4343 rmdir " ${TEMP_FOLDER} "
4444}
4545
46+ function loadEnvGitHubToken {
47+ GITHUB_TOKEN=$( git config github.token)
48+ if [ -z " $token " ]; then
49+ echo ' GitHub token is empty. Please run git config --add github.token "123"' ;
50+ exit 1;
51+ fi
52+ }
53+
54+ function publishArtifacts {
55+
56+ if ! command -v jq & > /dev/null
57+ then
58+ echo " jq could not be found"
59+ exit
60+ fi
61+
62+ if ! command -v git & > /dev/null
63+ then
64+ echo " git could not be found"
65+ exit
66+ fi
67+
68+ loadEnvGitHubToken
69+ user=${GH_ORG:- " code-lts" }
70+ repo=${GH_REPO:- " doctum" }
71+ echo " Create release ${VERSION} for repo: $user /$repo branch: $branch "
72+ read -r -p " Are you sure to publish the draft? [Y/n]" response
73+ response=${response,,} # tolower
74+ if [[ $response =~ ^(yes| y| ) ]] || [[ -z $response ]]; then
75+ RELEASE_OUT=" $( curl -H " Authorization: token ${GITHUB_TOKEN} " --data " $( generate_post_data) " " https://api.github.com/repos/$user /$repo /releases" ) "
76+ fi
77+
78+ echo " Make and publish the signature for this release."
79+ read -r -p " Are you sure to upload artifacts to the draft? [Y/n]" response
80+ response=${response,,} # tolower
81+ if [[ $response =~ ^(yes| y| ) ]] || [[ -z $response ]]; then
82+ releaseId=$( echo $RELEASE_OUT | jq -r ' .id' )
83+ curl -L \
84+ -H " Authorization: token ${GITHUB_TOKEN} " \
85+ -H " Content-Type: application/pgp-signature" \
86+ --data-binary @doctum.phar \
87+ " https://uploads.github.com/repos/$user /$repo /releases/$releaseId /assets?name=doctum.phar"
88+ curl -L \
89+ -H " Authorization: token ${GITHUB_TOKEN} " \
90+ -H " Content-Type: application/pgp-signature" \
91+ --data-binary @doctum.phar.sha256 \
92+ " https://uploads.github.com/repos/$user /$repo /releases/$releaseId /assets?name=doctum.phar.sha256"
93+ curl -L \
94+ -H " Authorization: token ${GITHUB_TOKEN} " \
95+ -H " Content-Type: application/pgp-signature" \
96+ --data-binary @doctum.phar.asc \
97+ " https://uploads.github.com/repos/$user /$repo /releases/$releaseId /assets?name=doctum.phar.asc"
98+ curl -L \
99+ -H " Authorization: token ${GITHUB_TOKEN} " \
100+ -H " Content-Type: application/pgp-signature" \
101+ --data-binary @doctum.phar.sha256.asc \
102+ " https://uploads.github.com/repos/$user /$repo /releases/$releaseId /assets?name=doctum.phar.sha256.asc"
103+ fi
104+
105+ }
106+
46107if [ ! -f ./vendor/autoload.php ]; then
47108 echo " Composer dependencies are missing"
48109 echo " Updating..."
128189 echo " Versions do not match."
129190 exit 1;
130191fi
192+
193+ if [ -z " ${SKIP_PUBLISH_QUESTION} " ] && [ -z " ${VERSION_MATCH_DEV} " ]; then
194+ publishArtifacts
195+ fi
0 commit comments