Publish #20
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
name: Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
version_type: | |
type: choice | |
description: Version type | |
default: minor | |
options: | |
- major | |
- minor | |
- patch | |
rubygems_api_key: | |
description: API Key | |
required: true | |
rubygems_otp: | |
description: OTP Code | |
required: true | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Hide the inputs values to keep them private in the logs when running this workflow | |
uses: levibostian/action-hide-sensitive-inputs@v1 | |
- uses: actions/checkout@v4 | |
- name: Setup git repo | |
run: | | |
git config user.name $GITHUB_ACTOR | |
git config user.email gh-actions-${GITHUB_ACTOR}@github.com | |
git remote add gh-origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.3.1 | |
- name: Upgrade RubyGems version | |
run: gem update --system | |
- name: Install gems | |
run: | | |
gem install bundler | |
bundle install --jobs 4 --retry 3 | |
- name: Bump Version | |
id: bump_version | |
run: | | |
NEW_VERSION=$(rake "bump_version_number[${{ inputs.version_type }}]") | |
echo "NEW_VERSION=$NEW_VERSION" | |
echo "new_version=$(echo $NEW_VERSION)" >> $GITHUB_OUTPUT | |
- name: Configure authentication to RubyGems | |
run: | | |
mkdir -p $HOME/.gem | |
touch $HOME/.gem/credentials | |
chmod 0600 $HOME/.gem/credentials | |
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | |
env: | |
GEM_HOST_API_KEY: "${{ inputs.rubygems_api_key }}" | |
- name: Publish to RubyGems | |
run: rake publish | |
env: | |
GEM_HOST_OTP_CODE: ${{ inputs.rubygems_otp }} | |
- name: Create a Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.bump_version.outputs.new_version }} | |
generate_release_notes: true |