Skip to content

Commit 3039063

Browse files
committed
feat: add an upload artifacts question after release
1 parent f36ff62 commit 3039063

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

scripts/make-release.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
46107
if [ ! -f ./vendor/autoload.php ]; then
47108
echo "Composer dependencies are missing"
48109
echo "Updating..."
@@ -128,3 +189,7 @@ else
128189
echo "Versions do not match."
129190
exit 1;
130191
fi
192+
193+
if [ -z "${SKIP_PUBLISH_QUESTION}" ] && [ -z "${VERSION_MATCH_DEV}" ]; then
194+
publishArtifacts
195+
fi

tests/phar/tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
set -e
66

77
oneTimeSetUp() {
8-
SKIP_GPG="yes" $(dirname $0)/../../scripts/make-release.sh
8+
SKIP_GPG="yes" SKIP_PUBLISH_QUESTION="yes" $(dirname $0)/../../scripts/make-release.sh
99
PHAR_PATH="$(realpath $(dirname $0)/../../build/doctum.phar)"
1010
echo "Using the phar: ${PHAR_PATH}"
1111
}

0 commit comments

Comments
 (0)