Skip to content

Commit

Permalink
Initial implementaion of the action
Browse files Browse the repository at this point in the history
  • Loading branch information
jstastny committed Dec 11, 2019
0 parents commit ae09066
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ruby:2.6-alpine

RUN apk add --no-cache git

RUN set -x \
&& gem install bundler keycutter

COPY LICENSE README.md /

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Jan Stastny

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Release Ruby Gem to GitHub Packages
This action builds the gems for all `.gemspec` files in the projects root.

## Example
Example minimal workflow using this action:
```yaml
name: CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Build and publish gem
uses: jstastny/publish-gem-to-github@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: jstastny
```
See example project using this action at [https://github.com/jstastny/testgem](https://github.com/jstastny/testgem).
## Inputs
| Name | Description |
| -----| ------------|
| `token` | GitHub token that has write access to Packages. You can use `secrets.GITHUB_TOKEN` |
| `owner` | Name of the user or organization account that owns the repository containing your project |

## Versioning your gem
This action currently does not bump the gem's version when building it. It is up to you to do it (either manually or in a previous workflow step).
If you try to release gem in the same version that already exists, the step will fail.
16 changes: 16 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Release Gem to GitHub Packages'
description: 'Builds and publishes Ruby gems to GitHub Packages'
author: 'Jan Stastny'
inputs:
token:
description: 'GitHub token that has access to write to GitHub package registry. You can use GITHUB_TOKEN for this.'
required: true
owner:
description: 'Name of the user or organization account that owns the repository containing your project.'
required: true
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.token }}
- ${{ inputs.owner }}
18 changes: 18 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh -l

GITHUB_TOKEN=$1
OWNER=$2

[ -z "${GITHUB_TOKEN}" ] && { echo "Missing input.token!"; exit 2; }
[ -z "${OWNER}" ] && { echo "Missing input.owner!"; exit 2; }

echo "Setting up access to GitHub Package Registry"
mkdir -p ~/.gem
touch ~/.gem/credentials
chmod 600 ~/.gem/credentials
echo ":github: Bearer ${GITHUB_TOKEN}" >> ~/.gem/credentials

echo "Building the gem"
gem build *.gemspec
echo "Pushing the built gem to GitHub Package Registry"
gem push --key github --host "https://rubygems.pkg.github.com/${OWNER}" *.gem

0 comments on commit ae09066

Please sign in to comment.