Skip to content

Commit

Permalink
separate build and push for github action
Browse files Browse the repository at this point in the history
  • Loading branch information
xuan-cao-swi committed Dec 4, 2023
1 parent bb14494 commit f361a4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build_for_github_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
mkdir ~/.gem
echo -e "---\n:github: Bearer $GITHUB_SECRET_TOKEN" >> ~/.gem/credentials
chmod 0600 ~/.gem/credentials
bundle exec rake build_gem_push_to_github_package[${{ steps.version.outputs.gem_version }}]
bundle exec rake build_gem_for_github_package[${{ steps.version.outputs.gem_version }}]
bundle exec rake push_gem_to_github_package[${{ steps.version.outputs.gem_version }}]
env:
GITHUB_SECRET_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 8 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,17 @@ end
# need set the credentials under ~/.gem/credentials
# for download, easiest way is to set BUNDLE_RUBYGEMS__PKG__GITHUB__COM
# but there are other auth methods. see more on https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry
desc 'Build gem and push to github package. Run as bundle exec rake build_gem_push_to_github_package[<version>]'
task :build_gem_push_to_github_package, [:version] do |_, args|
gem_to_push = find_or_build_gem(args[:version])
gem_to_push.gsub!('builds/','')
exit 1 unless system('gem', 'push', '--key', 'github', '--host', 'https://rubygems.pkg.github.com/solarwinds', gem_to_push)
desc 'Push to github package. Run as bundle exec rake build_gem_push_to_github_package[<version>]'
task :push_gem_to_github_package, [:version] do |_, args|
exit 1 unless system('gem', 'push', '--key', 'github', '--host', 'https://rubygems.pkg.github.com/solarwinds', "builds/#{args[:version]}.gem")
puts "\n=== Finished ===\n"
end

desc 'Build gem for github package'
task :build_gem_for_github_package, [:version] do |_, args|
gem_to_push = find_or_build_gem(args[:version])
end

desc 'Run rubocop and generate result. Run as bundle exec rake rubocop
If want to safely autocorrect enabled, just use bundle exec rake rubocop auto-safe
If want to all autocorrect enabled, just use bundle exec rake rubocop auto-all
Expand Down

0 comments on commit f361a4e

Please sign in to comment.