mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
attempting to use new github upload tool
This commit is contained in:
parent
e00def0bb6
commit
b17931b4fc
@ -19,5 +19,6 @@ sudo apt-get $UNATTENDED install \
|
|||||||
g++ \
|
g++ \
|
||||||
gettext \
|
gettext \
|
||||||
openjdk-8-jre-headless \
|
openjdk-8-jre-headless \
|
||||||
|
jp \
|
||||||
tree
|
tree
|
||||||
|
|
||||||
|
@ -19,7 +19,13 @@ source ./buildScripts/reSourceVersionEnvs
|
|||||||
cd imageBuild
|
cd imageBuild
|
||||||
|
|
||||||
if [ -n "$GITHUB_TOKEN" ]; then
|
if [ -n "$GITHUB_TOKEN" ]; then
|
||||||
wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
|
|
||||||
|
echo "machine api.github.com" > $HOME/.netrc
|
||||||
|
echo " login $GITHUB_USERNAME" >> $HOME/.netrc
|
||||||
|
echo " password $GITHUB_TOKEN" >> $HOME/.netrc
|
||||||
|
echo "machine uploads.github.com" >> $HOME/.netrc
|
||||||
|
echo " login $GITHUB_USERNAME" >> $HOME/.netrc
|
||||||
|
echo " password $GITHUB_TOKEN" >> $HOME/.netrc
|
||||||
|
|
||||||
echo $BUILD_TIME > buildTime
|
echo $BUILD_TIME > buildTime
|
||||||
|
|
||||||
@ -27,23 +33,8 @@ if [ -n "$GITHUB_TOKEN" ]; then
|
|||||||
|
|
||||||
echo $DOCKER_NAME > dockerImageName
|
echo $DOCKER_NAME > dockerImageName
|
||||||
|
|
||||||
export UPLOADTOOL_BODY=<<RELEASE_MESSAGE
|
./buildScripts/uploadReleaseTool "$REPO_SLUG" "continuous" "Latest release" \
|
||||||
This is the development/testing release of the pdf2htmlEX AppImage.
|
-- $APPIMAGE_NAME appImageName dockerImageName buildTime
|
||||||
|
|
||||||
You can download the AppImage and 'just run it'.
|
|
||||||
|
|
||||||
See: https://appimage.org/ for details
|
|
||||||
RELEASE_MESSAGE
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "---------------------------------------------------------------"
|
|
||||||
echo "upload tool body:
|
|
||||||
echo "---------------------------------------------------------------"
|
|
||||||
echo $UPLOADTOOL_BODY
|
|
||||||
echo "---------------------------------------------------------------"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
bash upload.sh $APPIMAGE_NAME appImageName dockerImageName buildTime
|
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "GITHUB_TOKEN not set... so we can not upload release artefacts."
|
echo "GITHUB_TOKEN not set... so we can not upload release artefacts."
|
||||||
|
6
buildScripts/uploadReleaseMessage
Normal file
6
buildScripts/uploadReleaseMessage
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
This is the development/testing release of the pdf2htmlEX AppImage.
|
||||||
|
|
||||||
|
You can download the AppImage and 'just run it'.
|
||||||
|
|
||||||
|
See: https://appimage.org/ for details
|
||||||
|
|
191
buildScripts/uploadReleaseTool
Executable file
191
buildScripts/uploadReleaseTool
Executable file
@ -0,0 +1,191 @@
|
|||||||
|
#!/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"
|
||||||
|
shift
|
||||||
|
|
||||||
|
TAG="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
NAME="$(basename "$REPO") ${TAG}"
|
||||||
|
if [ -n "$1" -a "$1" != "--" ]; then
|
||||||
|
NAME="${NAME}: $1";
|
||||||
|
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
|
||||||
|
# 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