Update publish_release.sh script [skip ci]

This commit is contained in:
Artem Pavlenko 2024-06-16 14:52:57 +01:00
parent 52bde246d2
commit 02049bb811

View file

@ -97,7 +97,7 @@ step "creating tarball of ${TARBALL_COMPRESSED}"
cd ../ cd ../
tar cjf ${TARBALL_COMPRESSED} ${TARBALL_NAME}/ tar cjf ${TARBALL_COMPRESSED} ${TARBALL_NAME}/
step "uploading to github" step "uploading to github"
# https://developer.github.com/v3/repos/releases/#create-a-release # https://developer.github.com/v3/repos/rseleases/#create-a-release
IS_PRERELEASE=false IS_PRERELEASE=false
if [[ ${MAPNIK_VERSION} =~ 'rc' ]] || [[ ${MAPNIK_VERSION} =~ 'alpha' ]]; then if [[ ${MAPNIK_VERSION} =~ 'rc' ]] || [[ ${MAPNIK_VERSION} =~ 'alpha' ]]; then
IS_PRERELEASE=true IS_PRERELEASE=true
@ -105,27 +105,31 @@ fi
IS_DRAFT=true IS_DRAFT=true
step "creating a draft release" step "creating a draft release"
export CHANGELOG_REF=$(python -c "print '${MAPNIK_VERSION}'.replace('.','').replace('v','').split('-')[0]") export CHANGELOG_REF=$(python3 -c "print('${MAPNIK_VERSION}'.replace('.','').replace('v','').split('-')[0])")
export RELEASE_NOTES="Mapnik ${MAPNIK_VERSION}\r\n\r\n[Changelog](https://github.com/mapnik/mapnik/blob/${MAPNIK_VERSION}/CHANGELOG.md#${CHANGELOG_REF})" export RELEASE_NOTES="Mapnik ${MAPNIK_VERSION}\r\n\r\n[Changelog](https://github.com/mapnik/mapnik/blob/${MAPNIK_VERSION}/CHANGELOG.md#${CHANGELOG_REF})"
step "release notes: $RELEASE_NOTES" step "release notes: $RELEASE_NOTES"
# create draft release # create draft release
curl --data "{\"tag_name\": \"${MAPNIK_VERSION}\",\"target_commitish\": \"master\",\"name\": \"${MAPNIK_VERSION}\",\"body\": \"${RELEASE_NOTES}\",\"draft\": ${IS_DRAFT},\"prerelease\": ${IS_PRERELEASE}}" \ curl --data "{\"tag_name\": \"${MAPNIK_VERSION}\",\"target_commitish\": \"master\",\"name\": \"Mapnik ${MAPNIK_VERSION}\",\"body\": \"${RELEASE_NOTES}\",\"draft\": ${IS_DRAFT},\"prerelease\": ${IS_PRERELEASE}}" \
https://api.github.com/repos/mapnik/mapnik/releases?access_token=${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO} \ https://api.github.com/repos/mapnik/mapnik/releases \
> create_response.json -H "Authorization: bearer ${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO}" \
> create_response.json
cat create_response.json cat create_response.json
# parse out upload url and form it up to post tarball # parse out upload url and form it up to post tarball
UPLOAD_URL=$(python -c "import json;print json.load(open('create_response.json'))['upload_url'].replace('{?name,label}','?name=${TARBALL_COMPRESSED}')") UPLOAD_URL=$(python3 -c "import json;print(json.load(open('create_response.json'))['upload_url'].replace('{?name,label}','?name=${TARBALL_COMPRESSED}'))")
HTML_URL=$(python -c "import json;print json.load(open('create_response.json'))['html_url']") HTML_URL=$(python3 -c "import json;print(json.load(open('create_response.json'))['html_url'])")
step "upload url: $UPLOAD_URL" step "upload url: $UPLOAD_URL"
# upload source tarball # upload source tarball
curl ${UPLOAD_URL} \ curl -L \
-X POST \ -X POST \
-H "Authorization: token ${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO}" \ -H "Accept: application/vnd.github+json" \
-H "Content-Type:application/octet-stream" \ -H "Authorization: bearer ${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO}" \
--data-binary @${TARBALL_COMPRESSED} -H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type:application/octet-stream" \
${UPLOAD_URL} \
--data-binary "@${TARBALL_COMPRESSED}"
echo echo
step "Success: view your new draft release at ${HTML_URL}" step "Success: view your new draft release at ${HTML_URL}"