mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
refactored to provide build stage headers and improved the upload function
This commit is contained in:
parent
41e8218f65
commit
b207b8ea48
@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
source buildScripts/reSourceVersionEnvs
|
source buildScripts/reSourceVersionEnvs
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "BUILDING FontForge"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
# This is a work-around to fix TravisCI's declaration of PYTHON_CFLAGS
|
# This is a work-around to fix TravisCI's declaration of PYTHON_CFLAGS
|
||||||
# which is then honoured exactly as is by the fontforge bootstrap and
|
# which is then honoured exactly as is by the fontforge bootstrap and
|
||||||
# configure steps.
|
# configure steps.
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
# This bash script builds pdf2htmlEX
|
# This bash script builds pdf2htmlEX
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "BUILDING pdf2htmlEX (using gcc)"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
cd pdf2htmlEX
|
cd pdf2htmlEX
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
# This bash script builds pdf2htmlEX using Clang (if it is installed)
|
# This bash script builds pdf2htmlEX using Clang (if it is installed)
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "BUILDING pdf2htmlEX (using CLang)"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
cd pdf2htmlEX
|
cd pdf2htmlEX
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
# This bash script builds the latest poppler
|
# This bash script builds the latest poppler
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "BUILDING Poppler"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
cd poppler
|
cd poppler
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
|
@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
source ./buildScripts/reSourceVersionEnvs
|
source ./buildScripts/reSourceVersionEnvs
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "CREATING pdf2htmlEX AppImage"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
# For appimage output plugin
|
# For appimage output plugin
|
||||||
#
|
#
|
||||||
export VERSION="$PDF2HTMLEX_BRANCH-$BUILD_TIME"
|
export VERSION="$PDF2HTMLEX_BRANCH-$BUILD_TIME"
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
# This bash script creates a docker image from an existing pdf2htmlEX
|
# This bash script creates a docker image from an existing pdf2htmlEX
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "CREATING pdf2htmlEX Docker Image"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
if [ -x "$(which docker)" ]; then
|
if [ -x "$(which docker)" ]; then
|
||||||
|
|
||||||
source buildScripts/reSourceVersionEnvs
|
source buildScripts/reSourceVersionEnvs
|
||||||
|
@ -5,6 +5,13 @@
|
|||||||
# set the bash environment variable 'UNATTENDED' to '--assume-yes' for
|
# set the bash environment variable 'UNATTENDED' to '--assume-yes' for
|
||||||
# unattended use (for example in the .travis.yml script)
|
# unattended use (for example in the .travis.yml script)
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "INSTALLING Build Tools (using APT)"
|
||||||
|
echo " (UNATTENDED: [$UNATTENDED])"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get $UNATTENDED install \
|
sudo apt-get $UNATTENDED install \
|
||||||
aptitude \
|
aptitude \
|
||||||
|
@ -6,6 +6,13 @@
|
|||||||
# set the bash environment variable 'UNATTENDED' to '--assume-yes' for
|
# set the bash environment variable 'UNATTENDED' to '--assume-yes' for
|
||||||
# unattended use (for example in the .travis.yml script)
|
# unattended use (for example in the .travis.yml script)
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "INSTALLING development libraries (using APT)"
|
||||||
|
echo " (UNATTENDED: [$UNATTENDED])"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get $UNATTENDED install \
|
sudo apt-get $UNATTENDED install \
|
||||||
libcairo-dev \
|
libcairo-dev \
|
||||||
|
@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
# This bash script gets and unpacks the latest fontforge AppImage
|
# This bash script gets and unpacks the latest fontforge AppImage
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "GETTING FontForge sources (using wget)"
|
||||||
|
echo " (FONTFORGE_VERSION: [$FONTFORGE_VERSION])"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
source buildScripts/reSourceVersionEnvs
|
source buildScripts/reSourceVersionEnvs
|
||||||
|
|
||||||
FONTFORGE_SRC=$FONTFORGE_VERSION.tar.gz
|
FONTFORGE_SRC=$FONTFORGE_VERSION.tar.gz
|
||||||
|
@ -5,6 +5,14 @@
|
|||||||
|
|
||||||
PDF2HTMLEX_BRANCH=newBuildSystem
|
PDF2HTMLEX_BRANCH=newBuildSystem
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "GETTING pdf2htmlEX sources (using wget)"
|
||||||
|
echo " (PDF2HTMLEX_BRANCH: [$PDF2HTMLEX_BRANCH])"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
wget https://codeload.github.com/stephengaito/pdf2htmlEX/zip/$PDF2HTMLEX_BRANCH
|
wget https://codeload.github.com/stephengaito/pdf2htmlEX/zip/$PDF2HTMLEX_BRANCH
|
||||||
|
|
||||||
mv $PDF2HTMLEX_BRANCH $PDF2HTMLEX_BRANCH.zip
|
mv $PDF2HTMLEX_BRANCH $PDF2HTMLEX_BRANCH.zip
|
||||||
|
@ -4,6 +4,14 @@
|
|||||||
|
|
||||||
source buildScripts/reSourceVersionEnvs
|
source buildScripts/reSourceVersionEnvs
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "GETTING Poppler source code (using wget)"
|
||||||
|
echo " (POPPLER_VERSION: [$POPPLER_VERSION])"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
echo "Getting poppler version: $POPPLER_VERSION"
|
echo "Getting poppler version: $POPPLER_VERSION"
|
||||||
|
|
||||||
rm -rf $POPPLER_VERSION.tar.xz
|
rm -rf $POPPLER_VERSION.tar.xz
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "INSTALLING FontForge locally"
|
||||||
|
echo " (UNATTENDED: [$UNATTENDED])"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$UNATTENDED" ] ; then
|
if [ -z "$UNATTENDED" ] ; then
|
||||||
echo "WARNING: this may over-write any existing"
|
echo "WARNING: this may over-write any existing"
|
||||||
echo "FontForge version you have installed on your system."
|
echo "FontForge version you have installed on your system."
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "INSTALLING pdf2htmlEX locally"
|
||||||
|
echo " (UNATTENDED: [$UNATTENDED])"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$UNATTENDED" ] ; then
|
if [ -z "$UNATTENDED" ] ; then
|
||||||
|
|
||||||
echo "This installation assumes you have 'sudo' privileges"
|
echo "This installation assumes you have 'sudo' privileges"
|
||||||
|
@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
# This bash script installs Poppler into the local system
|
# This bash script installs Poppler into the local system
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "INSTALLING Poppler locally"
|
||||||
|
echo " (UNATTENDED: [$UNATTENDED])"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$UNATTENDED" ] ; then
|
if [ -z "$UNATTENDED" ] ; then
|
||||||
echo "WARNING: this may over-write any existing"
|
echo "WARNING: this may over-write any existing"
|
||||||
|
@ -11,6 +11,14 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
source ./buildScripts/reSourceVersionEnvs
|
source ./buildScripts/reSourceVersionEnvs
|
||||||
|
source ./buildScripts/uploadReleaseDSL
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo "UPLOADING pdf2htmlEX AppImage and Docker Images"
|
||||||
|
echo "-------------------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
# upload github release artefacts
|
# upload github release artefacts
|
||||||
@ -62,12 +70,15 @@ echo $BUILD_TIME > buildTime
|
|||||||
echo $APPIMAGE_NAME > appImageName
|
echo $APPIMAGE_NAME > appImageName
|
||||||
echo $DOCKER_NAME > dockerImageName
|
echo $DOCKER_NAME > dockerImageName
|
||||||
|
|
||||||
echo ../buildScripts/uploadReleaseTool "$TRAVIS_REPO_SLUG" "continuous" "Latest release" \
|
deleteReleaseByTag "$TRAVIS_REPO_SLUG" "continuous"
|
||||||
-- $APPIMAGE_NAME appImageName dockerImageName buildTime
|
|
||||||
|
|
||||||
../buildScripts/uploadReleaseTool "$TRAVIS_REPO_SLUG" "continuous" "Latest release" \
|
createNewRelease "$TRAVIS_REPO_SLUG" "continuous" "Latest release" \
|
||||||
-- $APPIMAGE_NAME appImageName dockerImageName buildTime
|
../buildScripts/uploadReleaseMessage
|
||||||
|
|
||||||
|
uploadAnAsset $upload_url appImageName "text/plain"
|
||||||
|
uploadAnAsset $upload_url buildTime "text/plain"
|
||||||
|
uploadAnAsset $upload_url dockerImageName "text/plain"
|
||||||
|
uploadAnAsset $upload_url $APPIMAGE_NAME "application/zip"
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
# push docker image
|
# push docker image
|
||||||
|
194
buildScripts/uploadReleaseDSL
Executable file
194
buildScripts/uploadReleaseDSL
Executable file
@ -0,0 +1,194 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This bash script is a collection of functions to interact with the GitHub
|
||||||
|
# release and git/tag APIs. It essentially provides a bash based DSL for
|
||||||
|
# uploading GitHub release artefacts.
|
||||||
|
|
||||||
|
# NOTE-1: These functions make use of your ".netrc" file to authenticate
|
||||||
|
# with GitHub. In order to use these functions, make sure you have **both**
|
||||||
|
# "api.github.com" and "upload.github.com" in this file. For example:
|
||||||
|
#
|
||||||
|
# machine api.github.com
|
||||||
|
# login foca
|
||||||
|
# password <an access token>
|
||||||
|
# machine uploads.github.com
|
||||||
|
# login foca
|
||||||
|
# password <an access token>
|
||||||
|
#
|
||||||
|
# You can generate the required access token at
|
||||||
|
# https://github.com/settings/tokens
|
||||||
|
# Make sure this access token has access to the "repo" scope.
|
||||||
|
#
|
||||||
|
# NOTE-2: These functions require the "jq" library to parse the JSON
|
||||||
|
# returned by the GitHub APIs.
|
||||||
|
|
||||||
|
#############################
|
||||||
|
function deleteReleaseByTag {
|
||||||
|
|
||||||
|
[ -n "$1" ] || (echo "deleteReleaseByTag: missing repository"; exit 1);
|
||||||
|
[ -n "$2" ] || (echo "deleteReleaseByTag: missing releaseTag"; exit 1);
|
||||||
|
|
||||||
|
REPO=$1
|
||||||
|
releaseTag=$2
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "deleting the release tagged $releaseTag"
|
||||||
|
echo " from the repository $REPO"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo "looking for an existing '$releaseTag' release in the repo $REPO"
|
||||||
|
|
||||||
|
response=$(
|
||||||
|
curl --fail \
|
||||||
|
--netrc \
|
||||||
|
--silent \
|
||||||
|
--location \
|
||||||
|
--request "GET" \
|
||||||
|
"https://api.github.com/repos/${REPO}/releases"
|
||||||
|
)
|
||||||
|
|
||||||
|
releaseID=$(echo $response | jq '.[] | select(.tag_name == "$releaseTag") | .id')
|
||||||
|
|
||||||
|
if [ -n "$releaseID" ] ; then
|
||||||
|
|
||||||
|
echo "deleting an existing '$releaseTag' release in the repo $REPO"
|
||||||
|
response=$(
|
||||||
|
curl --fail \
|
||||||
|
--netrc \
|
||||||
|
--silent \
|
||||||
|
--location \
|
||||||
|
--request "DELETE" \
|
||||||
|
"https://api.github.com/repos/${REPO}/releases/$releaseID"
|
||||||
|
)
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "looking for an existing '$releaseTag' git/tag in the repo $REPO"
|
||||||
|
|
||||||
|
response=$(
|
||||||
|
curl --fail \
|
||||||
|
--netrc \
|
||||||
|
--silent \
|
||||||
|
--location \
|
||||||
|
--request "GET" \
|
||||||
|
"https://api.github.com/repos/${REPO}/git/matching-refs/tags/$releaseTag"
|
||||||
|
)
|
||||||
|
|
||||||
|
tagURL=$(echo $response | jq '.[].url')
|
||||||
|
tagURL="${tagURL%\"}"
|
||||||
|
tagURL="${tagURL#\"}"
|
||||||
|
|
||||||
|
if [ -n "$tagURL" ]; then
|
||||||
|
echo "deleting an existing '$releaseTag' git/tag in the repo $REPO"
|
||||||
|
response=$(
|
||||||
|
curl --fail \
|
||||||
|
--netrc \
|
||||||
|
--silent \
|
||||||
|
--location \
|
||||||
|
--request "DELETE" \
|
||||||
|
$tagURL
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
###########################
|
||||||
|
function createNewRelease {
|
||||||
|
# returns: upload_url (envVar)
|
||||||
|
|
||||||
|
[ -n "$1" ] || (echo "createNewRelease: missing repository"; exit 1);
|
||||||
|
[ -n "$2" ] || (echo "createNewRelease: missing releaseTag"; exit 1);
|
||||||
|
[ -n "$3" ] || (echo "createNewRelease: missing release name"; exit 1);
|
||||||
|
[ -n "$4" ] || (echo "createNewRelease: missing release description filename"; exit 1);
|
||||||
|
|
||||||
|
REPO=$1
|
||||||
|
TAG=$2
|
||||||
|
NAME=$3
|
||||||
|
BODY=$(cat $4)
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Creating a new release in the repository $REPO"
|
||||||
|
echo " with tag $TAG"
|
||||||
|
echo " and name $NAME"
|
||||||
|
echo " using the message in the file $4"
|
||||||
|
echo "--------------------------------------------------------------"
|
||||||
|
echo $BODY
|
||||||
|
echo "--------------------------------------------------------------"
|
||||||
|
|
||||||
|
payload=$(
|
||||||
|
jq --null-input \
|
||||||
|
--arg tag "$TAG" \
|
||||||
|
--arg name "$NAME" \
|
||||||
|
--arg body "$BODY" \
|
||||||
|
'{ tag_name: $tag, name: $name, body: $body, draft: false, prerelease: true }'
|
||||||
|
)
|
||||||
|
|
||||||
|
response=$(
|
||||||
|
curl --fail \
|
||||||
|
--netrc \
|
||||||
|
--silent \
|
||||||
|
--location \
|
||||||
|
--data "$payload" \
|
||||||
|
"https://api.github.com/repos/${REPO}/releases"
|
||||||
|
)
|
||||||
|
|
||||||
|
upload_url="$(echo "$response" | jq -r .upload_url | sed -e "s/{?name,label}//")"
|
||||||
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
function uploadAnAsset {
|
||||||
|
|
||||||
|
[ -n "$1" ] || (echo "uploadAnAsset: missing upload url"; exit 1);
|
||||||
|
[ -n "$2" ] || (echo "uploadAnAsset: missing file name"; exit 1);
|
||||||
|
[ -n "$3" ] || (echo "uploadAnAsset: missing file type"; exit 1);
|
||||||
|
|
||||||
|
upload_url=$1
|
||||||
|
file=$2
|
||||||
|
fileType=$3
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "uploading the asset $file"
|
||||||
|
echo " of type $fileType"
|
||||||
|
|
||||||
|
curl --netrc \
|
||||||
|
--silent \
|
||||||
|
--header "Content-Type:$fileType" \
|
||||||
|
--data-binary "@$file" \
|
||||||
|
"$upload_url?name=$(basename "$file")"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# The above has been heavily modified into a collection of bash functions
|
||||||
|
# by Stephen Gaito working on the pdf2htmlEX project.
|
||||||
|
#
|
||||||
|
# It has been based upon the code in:
|
||||||
|
# https://gist.github.com/foca/38d82e93e32610f5241709f8d5720156
|
||||||
|
# on 2019-11-28
|
||||||
|
#
|
||||||
|
# The relevant GitHub API can be found at:
|
||||||
|
# https://developer.github.com/v3/git/refs/
|
||||||
|
# https://developer.github.com/v3/repos/releases/
|
||||||
|
#
|
||||||
|
# The original code has been used under the following (MIT-like) license:
|
||||||
|
|
||||||
|
# Copyright (c) 2016 Nicolas Sanguinetti <hi@nicolassanguinetti.info>
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person
|
||||||
|
# obtaining a copy of this software and associated documentation
|
||||||
|
# files (the "Software"), to deal in the Software without
|
||||||
|
# restriction, including without limitation the rights to use,
|
||||||
|
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the
|
||||||
|
# Software is furnished to do so, subject to the following
|
||||||
|
# conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be
|
||||||
|
# included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
@ -1,196 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
[ -z "$DEBUG" ] || set -x;
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo "$0 <repo> <tag> [<release name>] [-- <asset>...]" >&2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$1" = "-h" -o "$1" = "--help" ]; then
|
|
||||||
usage
|
|
||||||
cat >&2 <<EOS
|
|
||||||
|
|
||||||
Pass the following arguments:
|
|
||||||
|
|
||||||
* \`<repo>\`: ":user/:name" of the repository. For example, "foca/mpp".
|
|
||||||
* \`<tag>\`: Name of the tag for this release. For example, "v1.0.0".
|
|
||||||
* \`<release name>\`: Optional suffix for the release name.
|
|
||||||
|
|
||||||
You can pass a list of files to upload as release assets by giving them after a
|
|
||||||
\`--\` argument.
|
|
||||||
|
|
||||||
If you supply text on \`STDIN\` it will be used as the release notes.
|
|
||||||
|
|
||||||
EXAMPLES:
|
|
||||||
|
|
||||||
$ $0 foca/mpp v1.0.0 -- pkg/*.tar.gz
|
|
||||||
|
|
||||||
Creates a release named "mpp v1.0.0" and adds any tar.gz file in
|
|
||||||
\`./pkg\` as an asset.
|
|
||||||
|
|
||||||
$ $0 foca/mpp v1.0.1 "Bugfixes" -- pkg/*.tar.gz < notes.md
|
|
||||||
|
|
||||||
Creates a release named "mpp v1.0.1: Bugfixes", adds any tar.gz
|
|
||||||
file in \`./pkg\` as an asset, and uses the contents of \`notes.md\`
|
|
||||||
as the release notes.
|
|
||||||
|
|
||||||
NOTE:
|
|
||||||
|
|
||||||
This uses your \`.netrc\` file to authenticate with GitHub. In order to run the
|
|
||||||
script, make sure you have **both** \`api.github.com\` and \`upload.github.com\` in
|
|
||||||
this file. For example:
|
|
||||||
|
|
||||||
machine api.github.com
|
|
||||||
login foca
|
|
||||||
password <an access token>
|
|
||||||
machine uploads.github.com
|
|
||||||
login foca
|
|
||||||
password <an access token>
|
|
||||||
|
|
||||||
Generate this access token at https://github.com/settings/tokens and make sure
|
|
||||||
it has access to the \`"repo"\` scope.
|
|
||||||
EOS
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ -n "$2" ] || (usage; exit 1);
|
|
||||||
|
|
||||||
REPO="$1"
|
|
||||||
echo "Repository: [$REPO]"
|
|
||||||
shift
|
|
||||||
|
|
||||||
TAG="$1"
|
|
||||||
echo " Tag: [$TAG]"
|
|
||||||
shift
|
|
||||||
|
|
||||||
NAME="$(basename "$REPO") ${TAG}"
|
|
||||||
if [ -n "$1" -a "$1" != "--" ]; then
|
|
||||||
NAME="${NAME}: $1";
|
|
||||||
echo " Name: [$NAME]"
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
BODY="$(cat ../buildScripts/uploadReleaseMessage)"
|
|
||||||
|
|
||||||
if [ "$1" = "--" -a "$#" -ge "2" ]; then
|
|
||||||
shift
|
|
||||||
ASSETS="$@"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "looking for an existing 'continuous' release"
|
|
||||||
|
|
||||||
response=$(
|
|
||||||
curl --fail \
|
|
||||||
--netrc \
|
|
||||||
--silent \
|
|
||||||
--location \
|
|
||||||
--request "GET" \
|
|
||||||
"https://api.github.com/repos/${REPO}/releases"
|
|
||||||
)
|
|
||||||
|
|
||||||
releaseID=$(echo $response | jq '.[] | select(.tag_name == "continuous") | .id')
|
|
||||||
|
|
||||||
if [ -n "$releaseID" ] ; then
|
|
||||||
|
|
||||||
echo "deleting an existing 'continuous' release"
|
|
||||||
response=$(
|
|
||||||
curl --fail \
|
|
||||||
--netrc \
|
|
||||||
--silent \
|
|
||||||
--location \
|
|
||||||
--request "DELETE" \
|
|
||||||
"https://api.github.com/repos/${REPO}/releases/$releaseID"
|
|
||||||
)
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "looking for an existing 'continuous' tag"
|
|
||||||
|
|
||||||
response=$(
|
|
||||||
curl --fail \
|
|
||||||
--netrc \
|
|
||||||
--silent \
|
|
||||||
--location \
|
|
||||||
--request "GET" \
|
|
||||||
"https://api.github.com/repos/${REPO}/git/matching-refs/tags/continuous"
|
|
||||||
)
|
|
||||||
|
|
||||||
tagURL=$(echo $response | jq '.[].url')
|
|
||||||
tagURL="${tagURL%\"}"
|
|
||||||
tagURL="${tagURL#\"}"
|
|
||||||
|
|
||||||
if [ -n "$tagURL" ]; then
|
|
||||||
echo "deleting an existing 'continuous' tag"
|
|
||||||
response=$(
|
|
||||||
curl --fail \
|
|
||||||
--netrc \
|
|
||||||
--silent \
|
|
||||||
--location \
|
|
||||||
--request "DELETE" \
|
|
||||||
$tagURL
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
|
|
||||||
payload=$(
|
|
||||||
jq --null-input \
|
|
||||||
--arg tag "$TAG" \
|
|
||||||
--arg name "$NAME" \
|
|
||||||
--arg body "$BODY" \
|
|
||||||
'{ tag_name: $tag, name: $name, body: $body, draft: false, prerelease: true }'
|
|
||||||
)
|
|
||||||
|
|
||||||
response=$(
|
|
||||||
curl --fail \
|
|
||||||
--netrc \
|
|
||||||
--silent \
|
|
||||||
--location \
|
|
||||||
--data "$payload" \
|
|
||||||
"https://api.github.com/repos/${REPO}/releases"
|
|
||||||
)
|
|
||||||
|
|
||||||
upload_url="$(echo "$response" | jq -r .upload_url | sed -e "s/{?name,label}//")"
|
|
||||||
|
|
||||||
for file in $ASSETS; do
|
|
||||||
echo ""
|
|
||||||
echo "uploading $file"
|
|
||||||
curl --netrc \
|
|
||||||
--silent \
|
|
||||||
--header "Content-Type:application/gzip" \
|
|
||||||
--data-binary "@$file" \
|
|
||||||
"$upload_url?name=$(basename "$file")"
|
|
||||||
echo ""
|
|
||||||
done
|
|
||||||
|
|
||||||
# The above was taken from:
|
|
||||||
# https://gist.github.com/foca/38d82e93e32610f5241709f8d5720156
|
|
||||||
# on 2019-11-28
|
|
||||||
# and has been altered to delete the "continuous" tag/release
|
|
||||||
# using: https://developer.github.com/v3/git/refs/
|
|
||||||
# and: https://developer.github.com/v3/repos/releases/
|
|
||||||
# as well as using the ./buildScripts/uploadReleaseMessage
|
|
||||||
# by Stephen Gaito
|
|
||||||
# it has been used under the following (MIT-like) license:
|
|
||||||
|
|
||||||
# Copyright (c) 2016 Nicolas Sanguinetti <hi@nicolassanguinetti.info>
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person
|
|
||||||
# obtaining a copy of this software and associated documentation
|
|
||||||
# files (the "Software"), to deal in the Software without
|
|
||||||
# restriction, including without limitation the rights to use,
|
|
||||||
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the
|
|
||||||
# Software is furnished to do so, subject to the following
|
|
||||||
# conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be
|
|
||||||
# included in all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
# OTHER DEALINGS IN THE SOFTWARE.
|
|
Loading…
Reference in New Issue
Block a user