ci: move imgtool publishing to GH workflows

Disable imgtool publishing on Travis; update scripts to work on both
Travis and GH; add GH workflow for publishing.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
diff --git a/.github/workflows/imgtool.yaml b/.github/workflows/imgtool.yaml
new file mode 100644
index 0000000..119adbd
--- /dev/null
+++ b/.github/workflows/imgtool.yaml
@@ -0,0 +1,23 @@
+on:
+  push:
+    branches:
+      - master
+
+jobs:
+  environment:
+    name: Publish imgtool releases
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+      with:
+        fetch-depth: 0
+    - name: Install publishing packages
+      run: |
+        export PATH="$HOME/.local/bin:$PATH"
+        ./ci/imgtool_install.sh
+    - name: Publish imgtool
+      env:
+        TWINE_TOKEN: ${{ secrets.TWINE_TOKEN }}
+      run: |
+        export PATH="$HOME/.local/bin:$PATH"
+        ./ci/imgtool_run.sh
diff --git a/ci/imgtool_install.sh b/ci/imgtool_install.sh
index 94264f6..b8715a4 100755
--- a/ci/imgtool_install.sh
+++ b/ci/imgtool_install.sh
@@ -12,10 +12,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-if [[ $TRAVIS_PULL_REQUEST != "false" || $TRAVIS_BRANCH != "master" ]]; then
-    echo "Either a PR or not \"master\" branch, exiting"
-    exit 0
+if [[ $TRAVIS == "true" ]]; then
+    if [[ $TRAVIS_PULL_REQUEST != "false" || $TRAVIS_BRANCH != "master" ]]; then
+        echo "Either a PR or not \"master\" branch, exiting"
+        exit 0
+    fi
 fi
 
 pip3 install setuptools twine packaging
-pip3 install --pre imgtool
+pip3 install --pre imgtool --no-binary :all:
diff --git a/ci/imgtool_run.sh b/ci/imgtool_run.sh
index 1cf042d..62ea77e 100755
--- a/ci/imgtool_run.sh
+++ b/ci/imgtool_run.sh
@@ -12,9 +12,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-if [[ $TRAVIS_PULL_REQUEST != "false" || $TRAVIS_BRANCH != "master" ]]; then
-    echo "Either a PR or not \"master\" branch, exiting"
-    exit 0
+if [[ $TRAVIS == "true" ]]; then
+    if [[ $TRAVIS_PULL_REQUEST != "false" || $TRAVIS_BRANCH != "master" ]]; then
+        echo "Either a PR or not \"master\" branch, exiting"
+        exit 0
+    fi
 fi
 
 IMGTOOL_VER_PREFIX="\+imgtool_version = "
@@ -22,13 +24,13 @@
 DIST_DIR="dist"
 
 if [[ -z "$TWINE_TOKEN" ]]; then
-    echo "\$TWINE_TOKEN must be set in travis settings"
+    echo "\$TWINE_TOKEN must be set in Travis or GH settings"
     exit 0
 fi
 
 cd scripts/
 
-last_release=$(pip show imgtool | grep "Version: " | cut -d" " -f2)
+last_release=$(pip3 show imgtool | grep "Version: " | cut -d" " -f2)
 repo_version=$(grep "imgtool_version = " imgtool/__init__.py | sed 's/^.* = "\(.*\)"/\1/g')
 
 python3 ../ci/compare_versions.py --old $last_release --new $repo_version