Sha256: eff90228f17e5b3b37977c039686040b68d513245d44d786dbba813014a134a1

Contents?: true

Size: 1.9 KB

Versions: 5

Compression:

Stored size: 1.9 KB

Contents

#!/usr/bin/env bash

if readlink -f . >/dev/null 2>&1 # {{{ makes readlink work on mac
then
    readlink=readlink
else
    if greadlink -f . >/dev/null 2>&1
    then
        readlink=greadlink
    else
        printf "You must install greadlink to use this (brew install coreutils)\n" >&2
    fi
fi # }}}

# Set here to the full path to this script
me=${BASH_SOURCE[0]}
[ -L "$me" ] && me=$($readlink -f "$me")
here=$(cd "$(dirname "$me")" && pwd)
just_me=$(basename "$me")

: "${GEM_NAME:=dapr}"
: "${GIT_ORG:=rubyists}"

GEM_HOST=$1
: "${GEM_HOST:=rubygems}"

case "$GEM_HOST" in
    rubygems)
        gem_key='rubygems'
        gem_host='https://rubygems.org'
        ;;
    github)
        gem_key='github'
        gem_host="https://rubygems.pkg.github.com/$GIT_ORG"
        sed --in-place=.bak -e "s|https://rubygems.org|https://rubygems.pkg.github.com/$GIT_ORG|" "$here/../$GEM_NAME".gemspec
        trap 'mv -v "$here/../$GEM_NAME".gemspec.bak "$here/../$GEM_NAME".gemspec' EXIT
        ;;
    *)
        printf 'Unknown GEM_HOST: %s\n' "$GEM_HOST" >&2
        exit 1
        ;;
esac

# Only want this part  running in CI, with no ~/.gem dir
if [ ! -d ~/.gem ]
then
    if [ -z "$GEM_TOKEN" ]
    then
        printf 'No GEM_TOKEN provided, cannot publish\n'
        exit 1
    fi
    mkdir -p ~/.gem
    printf '%s\n:%s: %s\n' '---' "$gem_key" "$GEM_TOKEN" > ~/.gem/credentials
    chmod 600 ~/.gem/credentials
fi

if [ -f "$here"/../.version.txt ]
then
    version=$(<"$here"/../.version.txt)
else
    version=$(git describe --tags --abbrev=0 | sed -e 's/^v//')
fi

gem="$(printf '%s-%s.gem' "$GEM_NAME" "$version")"
if [[ "${TRACE:-false}" == true || "${ACTIONS_STEP_DEBUG:-false}" == true ]]
then
    printf "DEBUG: [%s] Building And Publishing %s to %s\n" "$just_me" "$gem" "$gem_host" >&2
fi

bundle exec gem build
bundle exec gem push -k "$gem_key" --host "$gem_host" "$gem"

# vim: set foldmethod=marker et ts=4 sts=4 sw=4 ft=bash :

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dapr-0.2.11 ci/publish-gem.sh
dapr-0.2.9 ci/publish-gem.sh
dapr-0.2.8 ci/publish-gem.sh
dapr-0.2.7 ci/publish-gem.sh
dapr-0.2.6 ci/publish-gem.sh