Skip to content

Commit

Permalink
Add GitHub Actions workflow to release Ruby gem
Browse files Browse the repository at this point in the history
  • Loading branch information
boronine committed Dec 8, 2023
1 parent 80c8e4c commit d037b98
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 22 deletions.
9 changes: 8 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"name": "Ruby",
"image": "mcr.microsoft.com/devcontainers/ruby:1-3.0-bullseye"
"image": "mcr.microsoft.com/devcontainers/ruby:1-3.0-bullseye",
"customizations": {
"vscode": {
"extensions": [
"github.vscode-github-actions"
]
}
}
}
23 changes: 23 additions & 0 deletions .github/workflows/gem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Ruby Gem

on:
workflow_dispatch:

jobs:
build:
name: Build + Publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
- name: Publish to RubyGems
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${HSLUV_RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem
env:
HSLUV_RUBYGEMS_API_KEY: "${{ secrets.HSLUV_RUBYGEMS_API_KEY }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.bundle/
/.yardoc
/Gemfile.lock
/*.gem
/_yardoc/
/coverage/
/doc/
Expand Down
2 changes: 0 additions & 2 deletions .rspec

This file was deleted.

38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

A Ruby implementation of [HSLuv](https://www.hsluv.org).

## Demo

![Demo](http://i.imgur.com/GTsNT8u.gif)

## Installation

Add this line to your application's Gemfile:
Expand Down Expand Up @@ -35,28 +31,28 @@ Or install it yourself as:

#### Hsluv::hsluv_to_hex(hue, saturation, lightness) -> color as a hex string

```
```ruby
Hsluv.hsluv_to_hex(12.177, 100, 53.23)
=> #ff0000
```

#### Hsluv::hsluv_to_rgb(hue, saturation, lightness) -> color as rgb

```
```ruby
Hsluv.hsluv_to_rgb(12.177, 100, 53.23)
=> [0.9998643703868711, 6.849859221502719e-14, 8.791283550555612e-06]
```

#### Hsluv::hex_to_hsluv(hex) -> list of floats as defined above

```
```ruby
Hsluv.hex_to_hsluv("#ff0000")
=> [12.177050630061776, 100.0000000000022, 53.23711559542933]
```

#### Hsluv::rgb_to_hsluv(rgb) -> list of floats as defined above

```
```ruby
Hsluv.rgb_to_hsluv(0.99, 6.84e-14, 8.79e-16)
=> [12.17705063006216, 100.00000000000209, 52.711595266911985]
```
Expand All @@ -68,14 +64,24 @@ For HPLuv (the pastel variant), use:
- `hex_to_hpluv`
- `rgb_to_hpluv`

## Testing
## Local workflow

If you don't have Ruby installed already, I recommend using our [devcontainer.json](.devcontainer/devcontainer.json) configuration to launch your editor in a pre-built Ruby container. Also consider using GitHub "Codespaces" feature if you don't use Docker.

Initial setup:

Run `rspec spec/`.
```bash
bundle install
```

Test:

```bash
bundle exec rspec
```

## Contributing
## Releasing a new version

1. Fork it ( https://github.com/hsluv/hsluv-ruby/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
1. Log in to [rubygems.org](https://rubygems.org/) using our shared [hsluv](https://rubygems.org/profiles/hsluv) profile
2. Make a new API key if necessary, copy it to GitHub Actions `HSLUV_RUBYGEMS_API_KEY` secret
3. Run [gem.yml](./github/workflows/gem.yml)
5 changes: 2 additions & 3 deletions hsluv.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Gem::Specification.new do |spec|
spec.name = 'hsluv'
spec.version = '1.0.2'
spec.version = '1.0.2.rc1'
spec.authors = ['Radu-Bogdan Croitoru', 'HSLuv Contributors']
spec.email = ['[email protected]', '[email protected]']
spec.email = ['[email protected]', '[email protected]']

spec.summary = 'Human friendly alternative to HSL.'
spec.description = 'HSLuv is implemented as a set of functions to convert colors between RGB, HSLuv and HPLuv.'
Expand All @@ -15,7 +15,6 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_development_dependency 'bundler', '~> 2.0'
spec.add_development_dependency 'rake', '~> 12.3.3'
spec.add_development_dependency 'pry', '~> 0.10'
spec.add_development_dependency 'rspec', '~> 3.5'
end

0 comments on commit d037b98

Please sign in to comment.