Skip to content

Commit

Permalink
Initial create
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Nordman committed Jan 15, 2019
0 parents commit 76f2c53
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ruby:2.6.0

ENV LC_ALL C.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

ADD entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# GitHub Action - Publish Gem to Rubygems

This is a GitHub Action written to streamline the Ruby gem publication process. The action sets the Gem Credentials from `GITHUB_TOKEN` and `RUBYGEMS_API_KEY`secrets, and then runs `rake release` in your project root. You can override this command by setting `RELEASE_COMMAND` environment variable to the script that creates and publishes (this is usually only the case when a repository hosts multiple gems together).

# Secrets Needed

`GITHUB_TOKEN` - Bundler needs this to create tags on your repo for the release
`RUBYGEMS_API_KEY` - The Rubygems API Key for an Owner of the Gem you wish to publish. You can find your API Key by looking in `~/.gem/credentials` or using the [Rubygems API](https://guides.rubygems.org/rubygems-org-api/#misc-methods)

# Env Options

`RELEASE_COMMAND` - By default, this will invoke `rake release` to build and publish the gem to Rubygems. Set this environment variable if you have a custom release command to be invoked

# Example

```hcl
workflow "Publish Gem" {
on = "release"
resolves = ["Release Gem"]
}
action "Install Dependencies" {
uses = "docker://ruby:2.6.0"
args = "bundle install"
}
action "Release Gem" {
uses = "cadwallion/publish-rubygems-action@master"
secrets = ["GITHUB_TOKEN", "RUBYGEMS_API_KEY"]
env = {
"RELEASE_COMMAND" = "rake dotenv:release"
}
needs = ["Install Dependencies"]
}
```
15 changes: 15 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

echo "Setting up gem credentials..."
set +x
mkdir -p ~/.gem
cat << EOF > ~/.gem/credentials
---
:github: Bearer ${GITHUB_TOKEN}
:rubygems_api_key: ${RUBYGEMS_API_KEY}
EOF
set -x

echo "Running gem release task..."
release_command="${RELEASE_COMMAND:-rake release}"
exec $release_command

0 comments on commit 76f2c53

Please sign in to comment.