Skip to content

v0.2.0

v0.2.0 #24

Workflow file for this run

name: CI
permissions:
contents: write
on:
push:
pull_request:
branches:
- main
release:
types:
- published
workflow_dispatch:
inputs:
version:
description: 'Version to release'
required: true
publish:
description: 'Publish to RubyGems?'
type: boolean
default: false
jobs:
lint:
name: Lint 🚨
runs-on: ubuntu-latest
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/checkout@v4
- name: Install Ruby πŸ’Ž
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
- name: Install dependencies πŸ“¦
run: |
echo 'gem: --no-document' >> ~/.gemrc
gem install standardrb
- name: Run linter 🚨
run: standardrb
test:
name: Test πŸ§ͺ
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby:
- 3.4.0-preview1
- 3.3
- 3.0
env:
BUNDLE_GEMFILE: Gemfile
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/checkout@v4
- name: Install Ruby πŸ’Ž
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Install dependencies πŸ“¦
run: bundle install
- name: Run tests πŸ§ͺ
run: bundle exec ruby -Ilib test/*.rb
publish:
if: >
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true')
needs:
- lint
- test
name: Build and Publish Gem πŸš€
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
- name: Update version πŸ”„
if: github.event_name == 'workflow_dispatch'
run: |
sed -i "s/VERSION = .*/VERSION = \"${{ github.event.inputs.version }}\"/" lib/name_formatter/version.rb
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if [[ -n $(git status -s) ]]; then
echo "Changes detected. Committing and pushing..."
git add lib/name_formatter/version.rb
git commit -m "Bump version to ${{ github.event.inputs.version }}"
git push
else
echo "No changes detected. Version is already up-to-date."
fi
- name: Verify gem version 🀝
run: |
version=$(ruby -r ./lib/name_formatter/version.rb -e "puts NameFormatterModule::VERSION")
if [ "$version" != "${{ github.event.inputs.version }}" ]; then
echo "Version mismatch: $version != ${{ github.event.inputs.version }}"
exit 1
fi
- name: Install dependencies πŸ“¦
run: |
echo 'gem: --no-document' >> ~/.gemrc
gem install bundler
bundle install
- name: Build Gem πŸ“¦
run: gem build *.gemspec
- name: Publish Gem πŸš€
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}" > $HOME/.gem/credentials
gem push *.gem
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}