-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from actionshub/switch-to-token
feat: Use token input variable
- Loading branch information
Showing
3 changed files
with
36 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
--- | ||
name: 'publish-gem-to-rubygems' | ||
author: 'Dan Webb' | ||
description: 'Run publish Gems to Rubygems' | ||
name: "publish-gem-to-rubygems" | ||
author: "Dan Webb" | ||
description: "Run publish Gems to Rubygems" | ||
runs: | ||
using: 'docker' | ||
image: docker://ghcr.io/actionshub/publish-gem-to-rubygems:v1.0.3 | ||
using: "docker" | ||
image: docker://ghcr.io/actionshub/publish-gem-to-rubygems:v2.0.0 | ||
inputs: | ||
api_key: | ||
description: "A RubyGems API Token" | ||
token: | ||
description: "RubyGems API Key" | ||
branding: | ||
icon: 'edit-3' | ||
color: 'red' | ||
icon: "edit-3" | ||
color: "red" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
#!/bin/bash | ||
|
||
RUBYGEMS_API_KEY=${1} | ||
cd "${GITHUB_WORKSPACE}" || exit 1 | ||
git config --global --add safe.directory "${GITHUB_WORKSPACE}" | ||
|
||
[ -z "${RUBYGEMS_API_KEY}" ] && { echo "Missing input.rubygems_api_key!"; exit 2; } | ||
TOKEN="${1}" | ||
[ -z "${TOKEN}" ] && { echo "Missing input.token!"; exit 2; } | ||
|
||
echo "Setting up access to RubyGems" | ||
mkdir -p ~/.gem | ||
cat << EOF > ~/.gem/credentials | ||
--- | ||
:rubygems_api_key: ${RUBYGEMS_API_KEY} | ||
EOF | ||
function setup_credentials_file() { | ||
echo "Setting up access to RubyGems" | ||
mkdir -p ~/.gem | ||
touch ~/.gem/credentials | ||
chmod 600 ~/.gem/credentials | ||
} | ||
|
||
echo "Building the gem" | ||
gem build | ||
echo "Pushing the built gem to RubyGems.org" | ||
find . -name '*.gem' -maxdepth 1 -exec gem push {} \; | ||
function auth_rubygems() { | ||
echo "Logging in to RubyGems" | ||
echo ":rubygems_api_key: ${1}" > ~/.gem/credentials | ||
} | ||
|
||
function build() { | ||
echo "Building gem" | ||
find . -name '*.gemspec' -maxdepth 1 -exec gem build {} \; | ||
echo "Pushing gem to rubygems.org" | ||
find . -name '*.gem' -maxdepth 1 -exec gem push --key "${1}" {} \; | ||
} | ||
|
||
setup_credentials_file | ||
auth_rubygems "${TOKEN}" | ||
build_and_push "rubygems" |