Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 41 additions & 24 deletions .github/workflows/gem.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
name: Publish Ruby Gem
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
gem_version:
description: 'Gem version to release'
required: false
type: string
workflow_dispatch:
inputs:
gem_version:
Expand All @@ -23,38 +28,50 @@ jobs:
ruby-version: 3.3.1
bundler-cache: true
-
name: Publish to rubygems and github packages
name: Publish to rubygems
env:
FORCE_PUBLISH: ${{ github.event.inputs.force && 'true' || 'false' }}
GEM_NAME: dapr
GEM_VERSION: ${{ github.event.inputs.gem_version || '0.0.0' }}
GIT_NAME: Dapr Automation
GIT_EMAIL: dapr@rubyists.com
GIT_ORG: rubyists
RUBYGEMS_TOKEN: ${{ secrets.RUBYGEMS_TOKEN }}
# yamllint disable rule:line-length
run: |
which gum || true
release() {
local gem token
token=${{ secrets.GITHUB_TOKEN }}
gem=$1
git config --global user.email "$GIT_EMAIL"
git config --global user.name "$GIT_NAME"
bundle config https://rubygems.pkg.github.com/$GIT_ORG "${token}:${token}"
mkdir -p ~/.gem
printf '%s\n:github: Bearer %s\n' '---' "$token" > ~/.gem/credentials
printf '%s\n:rubygems: Bearer %s\n' '---' "$RUBYGEMS_TOKEN" >> ~/.gem/credentials
chmod 600 ~/.gem/credentials
printf 'Releasing gem %s\n' "$gem"
bundle exec gem build
bundle exec gem push -k github --host https://rubygems.pkg.github.com/$GIT_ORG "$gem"
bundle exec gem push -k rubygems --host https://rubygems.org "$gem"
}
ls -a
version=$(<.version.txt)
printf 'Version for *%s* gem is: %s\n' "$GEM_NAME" "$version"
gem_name="$(printf '%s-%s.gem' "$GEM_NAME" "$version")"
[ "$FORCE_PUBLISH" = "true" ] && printf 'Forcing release of %s\n' "$gem_name"
release "$gem_name"
# If the workflow does not provide a version, use the one in the .version.txt file
[ "$GEM_VERSION" = "0.0.0" ] && version=$(<.version.txt)
gem="$(printf '%s-%s.gem' "$GEM_NAME" "$version")"
git config --global user.email "$GIT_EMAIL"
git config --global user.name "$GIT_NAME"
mkdir -p ~/.gem
printf '%s\n:rubygems: Bearer %s\n' '---' "$RUBYGEMS_TOKEN" >> ~/.gem/credentials
chmod 600 ~/.gem/credentials
printf 'Publishing %s to rubygems\n' "$gem"
bundle exec gem build
bundle exec gem push -k rubygems --host https://rubygems.org "$gem"
rm "$gem"
# yamllint enable rule:line-length
shell: bash
-
name: Publish to github
env:
GEM_NAME: dapr
GEM_VERSION: ${{ github.event.inputs.gem_version || '0.0.0' }}
GIT_NAME: Dapr Automation
GIT_EMAIL: dapr@rubyists.com
GIT_ORG: rubyists
# yamllint disable rule:line-length
run: |
# If the workflos does not provide a version, use the one in the .version.txt file
[ "$GEM_VERSION" = "0.0.0" ] && version=$(<.version.txt)
token=${{ secrets.GITHUB_TOKEN }}
gem="$(printf '%s-%s.gem' "$GEM_NAME" "$version")"
bundle config https://rubygems.pkg.github.com/$GIT_ORG "${token}:${token}"
printf '%s\n:github: Bearer %s\n' '---' "$token" >> ~/.gem/credentials
printf 'Publishing %s to github\n' "$gem"
sed -e -i "s|https://rubygems.org|https://rubygems.pkg.github.com/$GIT_ORG|" $GEM_NAME.gemspec
bundle exec gem build
bundle exec gem push -k github --host https://rubygems.pkg.github.com/$GIT_ORG "$gem"
# yamllint enable rule:line-length
shell: bash