forked from open-telemetry/opentelemetry-ruby
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from solarwinds/package-workflow
upload workflow
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) 2023 SolarWinds, LLC. | ||
# All rights reserved. | ||
|
||
name: Ruby Gem to Github Package | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
gem_name: | ||
required: true | ||
description: 'The name of gem you want to publish (without opentelemetry e.g. exporter-otlp)' | ||
|
||
jobs: | ||
build: | ||
name: Build + Publish to Github Package | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Ruby 3.1 and bundle | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.1 | ||
|
||
- name: Setup secrets | ||
run: | | ||
mkdir ~/.gem | ||
echo -e "---\n:github: Bearer $GITHUB_SECRET_TOKEN" >> ~/.gem/credentials | ||
chmod 0600 ~/.gem/credentials | ||
env: | ||
GITHUB_SECRET_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build gem and publish to github package | ||
id: gemstep | ||
run: | | ||
.github/workflows/script//sw_build_and_push_gem.sh ${{ github.event.inputs.gem_name }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/sh | ||
|
||
GEM_NAME="$1" | ||
|
||
case $GEM_NAME in | ||
*metrics-sdk) | ||
echo "metrics-sdk" | ||
GEM_PATH="metrics_sdk/" | ||
;; | ||
*metrics-api) | ||
echo "metrics-api" | ||
GEM_PATH="metrics_api/" | ||
;; | ||
*exporter-otlp) | ||
echo "exporter-otlp" | ||
GEM_PATH="exporter/otlp/" | ||
;; | ||
*) | ||
echo "Unknown gem name $GEM_NAME. Aborting publish" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
cd "$GEM_PATH" || exit 1 | ||
|
||
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-$GEM_NAME.gemspec" | ||
gem push --key github --host https://rubygems.pkg.github.com/solarwinds "opentelemetry-instrumentation-$GEM_NAME-$gem_version.gem" | ||
|
||
# finished | ||
echo "Finished" |