File: twine.sh

package info (click to toggle)
cppad 2026.00.00.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,588 kB
  • sloc: cpp: 112,960; sh: 6,146; ansic: 179; python: 71; sed: 12; makefile: 10
file content (88 lines) | stat: -rwxr-xr-x 2,287 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#! /usr/bin/env bash
set -e -u
# !! EDITS TO THIS FILE ARE LOST DURING UPDATES BY xrst.git/bin/dev_tools.sh !!
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2020-25 Bradley M. Bell
# -----------------------------------------------------------------------------
# bin/twine.sh branch_or_tag
# 1. This program muse be executed from the main or master branch
# 2. branch_or_tag can be a branch or a tag. If it is a branch, it must be
#    main or master.
# 3. If branch_or_tag is a tag, the corresponding version is uploaded to pypi.
#    Otherwise it is uploaded to testpipi.
# -----------------------------------------------------------------------------
# bash function that echos and executes a command
echo_eval() {
   echo $*
   eval $*
}
# -----------------------------------------------------------------------------
if [ "$0" != "bin/twine.sh" ]
then
   echo "bin/twine.sh: must be executed from its parent directory"
   exit 1
fi
if [ ! -e .git ]
then
   echo 'bin/twine.sh: Cannot find .git in current working directory'
   exit 1
fi
#
# branch_or_tag
if [ $# != 1 ]
then
   echo 'usage: bin/twine.sh: branch_or_tag'
   echo 'where branch_or_tag is master, main, or a git tag'
   exit 1
fi
branch_or_tag="$1"
#
# branch
branch=$(git branch --show-current)
if [ "$branch" != 'master' ] && [ "$branch" != 'main' ]
then
   echo 'bin/twine.sh: must execute on the main or master branch'
   exit 1
fi
#
# repository
if [ "$branch_or_tag" == "$branch" ]
then
   repository='testpypi'
else
   repository='pypi'
fi
#
# TOKEN
if [ -z "${TOKEN+x}" ]
then
   echo echo "bin/twine.sh: must export TOKEN=<API token for $repository>"
   echo 'see https://pypi.org/help/#apitoken'
   exit 1
fi
#
# dist
if [ -e dist ]
then
   rm -r dist
fi
if [ "$branch_or_tag" == "$branch" ]
then
   echo_eval python -m build
else
   if ! git show-ref $branch_or_tag | grep '/tags/' > /dev/null
   then
      echo "bin/twine.sh: $branch_or_tag is not the current branch or a tag"
      exit 1
   fi
   git checkout --quiet $branch_or_tag
   echo_eval python -m build
   git checkout $branch
fi
#
# twind
echo_eval twine upload --repository $repository  dist/* -u __token__ -p $TOKEN
#
echo 'twine.sh: OK'
exit 0