release process: move to github releases
This commit is contained in:
parent
4f008c6f2f
commit
c6c94e760e
2 changed files with 119 additions and 36 deletions
3
Makefile
3
Makefile
|
@ -19,6 +19,9 @@ install:
|
||||||
release:
|
release:
|
||||||
./scripts/publish_release.sh
|
./scripts/publish_release.sh
|
||||||
|
|
||||||
|
test-release:
|
||||||
|
./scripts/test_release.sh
|
||||||
|
|
||||||
python:
|
python:
|
||||||
if [ ! -d ./bindings/python ]; then git clone git@github.com:mapnik/python-mapnik.git --recursive ./bindings/python; else (cd bindings/python && git pull && git submodule update --init); fi;
|
if [ ! -d ./bindings/python ]; then git clone git@github.com:mapnik/python-mapnik.git --recursive ./bindings/python; else (cd bindings/python && git pull && git submodule update --init); fi;
|
||||||
make
|
make
|
||||||
|
|
|
@ -1,51 +1,131 @@
|
||||||
#!/usr/bin/env bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
# for normal release leave empty
|
: '
|
||||||
# for release candidate, add "-rcN"
|
|
||||||
export MAPNIK_VERSION=$(git describe)
|
Usage:
|
||||||
if [[ $(git tag -l) =~ $MAPNIK_VERSION ]]; then echo yes;
|
|
||||||
echo "Success: found $MAPNIK_VERSION (result of git describe) in tags, continuing"
|
git tag v3.0.12-rc7 -a -m "Tagging v3.0.12-rc7"
|
||||||
else
|
./scripts/publish_release.sh
|
||||||
echo "error: $MAPNIK_VERSION (result of git describe) not in "git tag -l" output, aborting"
|
|
||||||
echo "You must create a valid annotated tag first, before running this ./scripts/publish_release.sh"
|
Note: before running this script you need to tag a new release or release candidate.
|
||||||
|
|
||||||
|
This script:
|
||||||
|
|
||||||
|
- confirms that the current git checkout is a valid tag
|
||||||
|
- Downloads a fresh checkout to a /tmp directory
|
||||||
|
- Updates the submodules
|
||||||
|
- Confirms that the test-data and test-data-visual is also tagged, otherwise tags them
|
||||||
|
- Removes the test-data and test-data-visual since they are large and can be downloaded dynamically for released code
|
||||||
|
- Creates a tarball and uploads to a DRAFT "github release"
|
||||||
|
|
||||||
|
After using this script:
|
||||||
|
|
||||||
|
- Go to https://github.com/mapnik/mapnik/releases and confirm that the draft release looks good, then publish it.
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
|
function step { >&2 echo -e "\033[1m\033[36m* $1\033[0m"; }
|
||||||
|
function step_error { >&2 echo -e "\033[1m\033[31m$1\033[0m"; }
|
||||||
|
|
||||||
|
if [[ ${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO:-false} == false ]]; then
|
||||||
|
step_error "Please set GITHUB_TOKEN_MAPNIK_PUBLIC_REPO to a github token with 'public_repo' scope (create one at https://github.com/settings/tokens)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
export MAPNIK_VERSION=$(git describe)
|
||||||
|
if [[ $(git tag -l) =~ $MAPNIK_VERSION ]]; then
|
||||||
|
step "Success: found $MAPNIK_VERSION (result of git describe) in tags, continuing"
|
||||||
|
else
|
||||||
|
step_error "error: $MAPNIK_VERSION (result of git describe) not in "git tag -l" output, aborting"
|
||||||
|
step_error "You must create a valid annotated tag first, before running this ./scripts/publish_release.sh"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# alternatively set this to `git@github.com:mapnik/mapnik.git` to pull public tag
|
||||||
|
export ROOT_GIT_CLONE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../ && pwd )"
|
||||||
|
|
||||||
export TARBALL_NAME="mapnik-${MAPNIK_VERSION}"
|
export TARBALL_NAME="mapnik-${MAPNIK_VERSION}"
|
||||||
cd /tmp/
|
cd /tmp/
|
||||||
rm -rf ${TARBALL_NAME}
|
rm -rf ${TARBALL_NAME}
|
||||||
echo "Cloning ${MAPNIK_VERSION}"
|
step "Cloning ${MAPNIK_VERSION}"
|
||||||
git clone --depth 1 --branch ${MAPNIK_VERSION} git@github.com:mapnik/mapnik.git ${TARBALL_NAME}
|
git clone --depth 1 --branch ${MAPNIK_VERSION} ${ROOT_GIT_CLONE} ${TARBALL_NAME}
|
||||||
cd ${TARBALL_NAME}
|
cd ${TARBALL_NAME}
|
||||||
|
step "Checking out ${MAPNIK_VERSION}"
|
||||||
git checkout "tags/${MAPNIK_VERSION}"
|
git checkout "tags/${MAPNIK_VERSION}"
|
||||||
echo "updating submodules"
|
|
||||||
# TODO: skip initializing submodule if data is already tagged
|
step "checking submodules"
|
||||||
# Will require bundling variant as well
|
step "vendorizing and cleaning up mapbox variant"
|
||||||
git submodule update --depth 100 --init
|
git submodule update --init deps/mapbox/variant
|
||||||
rm -rf deps/mapbox/variant/.git
|
rm -rf deps/mapbox/variant/.git
|
||||||
cd test/data/
|
rm -f deps/mapbox/variant/*yml
|
||||||
git remote set-url origin git@github.com:mapnik/test-data
|
rm -f deps/mapbox/variant/Jamroot
|
||||||
echo "tagging test data"
|
|
||||||
git tag ${MAPNIK_VERSION} -a -m "tagging for ${MAPNIK_VERSION}"
|
function check_and_tag() {
|
||||||
git push --tags
|
REPO_DIR=$1
|
||||||
cd ../../
|
REPO_NAME=$2
|
||||||
echo "removing test data submodule"
|
if [[ $(curl --fail -I https://github.com/mapnik/${REPO_NAME}/archive/${MAPNIK_VERSION}.tar.gz) ]]; then
|
||||||
rm -rf test/data/
|
step "test data already tagged, no need to initialize submodule"
|
||||||
cd test/data-visual/
|
else
|
||||||
git remote set-url origin git@github.com:mapnik/test-data-visual
|
step "tagging test data"
|
||||||
echo "tagging visual data"
|
git submodule update --depth 100 --init ${REPO_DIR}
|
||||||
git tag ${MAPNIK_VERSION} -a -m "tagging for ${MAPNIK_VERSION}"
|
cd ${REPO_DIR}/
|
||||||
git push --tags
|
git remote set-url origin git@github.com:mapnik/${REPO_NAME}
|
||||||
cd ../../
|
git tag ${MAPNIK_VERSION} -a -m "tagging for ${MAPNIK_VERSION}"
|
||||||
echo "removing visual test data submodule"
|
git push --tags
|
||||||
rm -rf test/data-visual/
|
cd ../../
|
||||||
|
step "removing test data submodule"
|
||||||
|
rm -rf ${REPO_DIR}/
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# test data
|
||||||
|
check_and_tag test/data test-data
|
||||||
|
# test data visual
|
||||||
|
check_and_tag test/data-visual test-data-visual
|
||||||
|
|
||||||
|
step "removing .git and .gitignore"
|
||||||
rm -rf .git
|
rm -rf .git
|
||||||
rm -rf .gitignore
|
rm -rf .gitignore
|
||||||
|
export TARBALL_COMPRESSED=${TARBALL_NAME}.tar.bz2
|
||||||
|
step "creating tarball of ${TARBALL_COMPRESSED}"
|
||||||
cd ../
|
cd ../
|
||||||
echo "creating tarball of ${TARBALL_NAME}.tar.bz2"
|
tar cjf ${TARBALL_COMPRESSED} ${TARBALL_NAME}/
|
||||||
tar cjf ${TARBALL_NAME}.tar.bz2 ${TARBALL_NAME}/
|
step "uploading to github"
|
||||||
echo "uploading $(dirname ${TARBALL_NAME})/${TARBALL_NAME}.tar.bz2 to s3://mapnik/dist/${MAPNIK_VERSION}/"
|
# https://developer.github.com/v3/repos/releases/#create-a-release
|
||||||
# TODO: upload to github releases instead of s3
|
IS_PRERELEASE=false
|
||||||
aws s3 cp --acl public-read ${TARBALL_NAME}.tar.bz2 s3://mapnik/dist/${MAPNIK_VERSION}/
|
if [[ ${MAPNIK_VERSION} =~ 'rc' ]]; then
|
||||||
|
IS_PRERELEASE=true
|
||||||
|
fi
|
||||||
|
IS_DRAFT=true
|
||||||
|
step "creating a draft release"
|
||||||
|
|
||||||
|
export CHANGELOG_REF=$(python -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})"
|
||||||
|
step "release notes: $RELEASE_NOTES"
|
||||||
|
|
||||||
|
# create draft release
|
||||||
|
curl --data "{\"tag_name\": \"${MAPNIK_VERSION}\",\"target_commitish\": \"master\",\"name\": \"${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} \
|
||||||
|
> create_response.json
|
||||||
|
cat create_response.json
|
||||||
|
# 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}')")
|
||||||
|
step "upload url: $UPLOAD_URL"
|
||||||
|
|
||||||
|
# upload source tarball
|
||||||
|
curl ${UPLOAD_URL} \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN_MAPNIK_PUBLIC_REPO}" \
|
||||||
|
-H "Content-Type:application/octet-stream" \
|
||||||
|
--data-binary @${TARBALL_COMPRESSED}
|
||||||
|
|
||||||
|
echo
|
||||||
|
step "Success: view your new draft release as https://github.com/mapnik/mapnik/releases"
|
||||||
|
echo
|
||||||
|
|
||||||
|
#step "uploading $(realpath ${TARBALL_COMPRESSED}) to s3://mapnik/dist/${MAPNIK_VERSION}/"
|
||||||
|
#aws s3 cp --acl public-read ${TARBALL_COMPRESSED} s3://mapnik/dist/${MAPNIK_VERSION}/
|
||||||
|
|
Loading…
Reference in a new issue