Ruby Gem to RubyGems #11
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
# Copyright (c) 2023 SolarWinds, LLC. | |
# All rights reserved. | |
name: Ruby Gem to RubyGems | |
# This workflow relies on the following secrets | |
# - TRACE_BUILD_RUBY_ACTIONS_API_TOKEN (from the trace-build user in github) | |
# - RUBYGEMS_TOKEN (from the solarwinds-apm user on rubygems.org) | |
# - APM_RUBY_INSTALL_TESTING_SWO_KEY | |
# - CI_GITHUB_TOKEN | |
# | |
# The correct oboe version has to be in the file ext/oboe_metal/src/VERSION | |
on: | |
workflow_dispatch: | |
jobs: | |
# act -j publish_to_ruby_gem --container-architecture linux/arm64 --secret-file act.secrets | |
publish_to_ruby_gem: | |
name: Build + Release Gem to RubyGems | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Ruby 3.1.0 and bundle | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.1' | |
- name: Install gems | |
run: | | |
echo 'gem: --no-document' >> ~/.gemrc | |
bundle install --without development --without test | |
- name: Install swig 4.0.2 | |
run: | | |
sudo apt-get update && sudo apt-get install -y --no-install-recommends bison swig | |
- name: Download files from cloud.solarwinds.com and create swig wrapper | |
env: | |
TRACE_BUILD_TOKEN: ${{ secrets.TRACE_BUILD_RUBY_ACTIONS_API_TOKEN }} | |
run: | | |
bundle exec rake fetch_oboe_file["prod"] | |
bundle exec rake oboe_verify | |
- name: Build Gem and upload to Rubygems | |
id: build | |
env: | |
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_TOKEN }} | |
run: | | |
bundle exec rake build_and_publish_gem | |
checksum=`shasum -a256 *.gem | awk '{print $1;}'` | |
echo "checksum: $checksum" | |
echo "checksum=$checksum" >> $GITHUB_OUTPUT | |
echo "gem_version=`ruby -e 'require "./lib/solarwinds_apm/version"; puts SolarWindsAPM::Version::STRING'`" >> $GITHUB_OUTPUT | |
- name: Get checksum from Rubygems | |
id: checksum | |
run: | | |
gem_version=${{ steps.build.outputs.gem_version }} | |
echo "geminfo=`curl https://rubygems.org/api/v2/rubygems/solarwinds_apm/versions/$gem_version.json`" >> $GITHUB_OUTPUT | |
- name: Print checksums (in case some debugging is needed) | |
run: | | |
echo "local checksum: ${{ steps.build.outputs.checksum }}" | |
echo "Rubygems checksum: ${{ fromJson(steps.checksum.outputs.geminfo).sha }}" | |
echo "Gem version: ${{ steps.build.outputs.gem_version }}" | |
- name: Fail if local and rubygems checksums don't match | |
if: fromJson(steps.checksum.outputs.geminfo).sha != steps.build.outputs.checksum | |
run: | | |
echo "local and rubygems checksum not matching, gem needs to be yanked from rubygems.org" | |
exit 1 | |
- name: Create release draft that includes the checksum | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{secrets.CI_GITHUB_TOKEN}} | |
script: | | |
github.repos.createRelease({ | |
owner: "solarwindscloud", | |
repo: "swotel-ruby", | |
body: "SHA256 checksum: ${{ steps.build.outputs.checksum }}", | |
tag_name: "${{ steps.build.outputs.gem_version }}", | |
name: "${{ steps.build.outputs.gem_version }}", | |
draft: true | |
}) | |
# may need a bit of time for the gem to become available (-> sleep 1) | |
- name: Download new Rubygem from rubygems.org and test | |
working-directory: .github/workflows/ | |
env: | |
SW_APM_SERVICE_KEY: ${{ secrets.APM_RUBY_INSTALL_TESTING_SWO_KEY }} | |
run: | | |
sleep 20 | |
apt update && apt install -y ruby-dev g++ make | |
gem install solarwinds_apm --version ${{ steps.build.outputs.gem_version }} | |
ruby ./scripts/test_install.rb |