Skip to content

Commit

Permalink
use simpler action
Browse files Browse the repository at this point in the history
  • Loading branch information
xuan-cao-swi committed Dec 4, 2023
1 parent 3e34711 commit 718acc8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
30 changes: 3 additions & 27 deletions .github/workflows/push-package-solarwinds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,9 @@ name: Ruby Gem to Github Package
on:
workflow_dispatch:
inputs:
rubygem-path:
gem_name:
required: true
description: 'The path that package you want to publish (should include /)'
# metrics_sdk/
# metrics_api/
# exporter/otlp/

rubygem-name:
required: true
description: 'The gem to publish, e.g. opentelemetry-instrumentation-<???>'
# opentelemetry-metrics-sdk
# opentelemetry-metrics-api
# opentelemetry-exporter-otlp

version:
required: true
description: 'The gem version to publish'
description: 'The name of gem you want to publish (without opentelemetry-instrumentation e.g. aws_sdk)'

jobs:
build:
Expand All @@ -37,12 +23,6 @@ jobs:
with:
ruby-version: 3.1

- name: Install gems
run: |
cd ${{ github.event.inputs.rubygem-path }}
echo 'gem: --no-document' >> ~/.gemrc
bundle install
- name: Setup secrets
run: |
mkdir ~/.gem
Expand All @@ -54,8 +34,4 @@ jobs:
- name: Build gem and publish to github package
id: gemstep
run: |
gem_name=${{ github.event.inputs.rubygem-name }}
gem_version=${{ github.event.inputs.version }}
cd ${{ github.event.inputs.rubygem-path }}
gem build "${gem_name}.gemspec"
gem push --key github --host https://rubygems.pkg.github.com/solarwinds "${gem_name}-${gem_version}.gem"
./script/sw_build_and_push_gem.sh ${{ github.event.inputs.gem_name }}
19 changes: 19 additions & 0 deletions .github/workflows/script/sw_build_and_push_gem.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

GEM_NAME="$1"

cd "instrumentation/$GEM_NAME"

bundle install

# get gem version using bash
file_to_find="version.rb"
found_file=$(find "." -type f -name "$file_to_find")
gem_version=$(grep -E "VERSION\s*=\s*'[^']+'" "$found_file" | awk -F "'" '{print $2}')

# build and push gem
gem build "opentelemetry-instrumentation-$GEM_NAME.gemspec"
gem push --key github --host https://rubygems.pkg.github.com/solarwinds "opentelemetry-instrumentation-$GEM_NAME-$gem_version.gem"

# finished
echo "Finished"

0 comments on commit 718acc8

Please sign in to comment.