From 820cd878cb4b364f6bff6b8536ea186c71691320 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 30 Nov 2023 13:07:27 -0500 Subject: [PATCH 1/8] upload workflow --- .github/workflows/push-package-solarwinds.yml | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/push-package-solarwinds.yml diff --git a/.github/workflows/push-package-solarwinds.yml b/.github/workflows/push-package-solarwinds.yml new file mode 100644 index 000000000..673864ad5 --- /dev/null +++ b/.github/workflows/push-package-solarwinds.yml @@ -0,0 +1,61 @@ +# Copyright (c) 2023 SolarWinds, LLC. +# All rights reserved. + +name: Ruby Gem to Github Package + +on: + workflow_dispatch: + inputs: + rubygem-path: + 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 name that package you want to publish' + # opentelemetry-metrics-sdk + # opentelemetry-metrics-api + # opentelemetry-exporter-otlp + + version: + required: true + description: 'The package version that you wish to publish' + +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: Install gems + run: | + cd ${{ github.event.inputs.rubygem-path }} + echo 'gem: --no-document' >> ~/.gemrc + bundle install + + - 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.GH_PACKAGE_TOKEN }} + + - 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/xuan-cao-swi "${gem_name}-${gem_version}.gem" From f01e83083d833d0cb51e4d7d248b7b687011b782 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 30 Nov 2023 13:08:51 -0500 Subject: [PATCH 2/8] update org --- .github/workflows/push-package-solarwinds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-package-solarwinds.yml b/.github/workflows/push-package-solarwinds.yml index 673864ad5..43d8cbb56 100644 --- a/.github/workflows/push-package-solarwinds.yml +++ b/.github/workflows/push-package-solarwinds.yml @@ -58,4 +58,4 @@ jobs: 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/xuan-cao-swi "${gem_name}-${gem_version}.gem" + gem push --key github --host https://rubygems.pkg.github.com/solarwinds "${gem_name}-${gem_version}.gem" From 78978446d3b6884a8162bf9a626f914c095ff278 Mon Sep 17 00:00:00 2001 From: Xuan <112967240+xuan-cao-swi@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:47:40 -0500 Subject: [PATCH 3/8] Update .github/workflows/push-package-solarwinds.yml Co-authored-by: Lin Lin --- .github/workflows/push-package-solarwinds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-package-solarwinds.yml b/.github/workflows/push-package-solarwinds.yml index 43d8cbb56..cec63af1c 100644 --- a/.github/workflows/push-package-solarwinds.yml +++ b/.github/workflows/push-package-solarwinds.yml @@ -15,7 +15,7 @@ on: rubygem-name: required: true - description: 'The name that package you want to publish' + description: 'The gem to publish, e.g. opentelemetry-instrumentation-' # opentelemetry-metrics-sdk # opentelemetry-metrics-api # opentelemetry-exporter-otlp From ab924a7bf1c3d1dcf78ea8b9c3c0cc8ae69eb31f Mon Sep 17 00:00:00 2001 From: Xuan <112967240+xuan-cao-swi@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:49:05 -0500 Subject: [PATCH 4/8] Update .github/workflows/push-package-solarwinds.yml Co-authored-by: Lin Lin --- .github/workflows/push-package-solarwinds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-package-solarwinds.yml b/.github/workflows/push-package-solarwinds.yml index cec63af1c..c704d4c1b 100644 --- a/.github/workflows/push-package-solarwinds.yml +++ b/.github/workflows/push-package-solarwinds.yml @@ -22,7 +22,7 @@ on: version: required: true - description: 'The package version that you wish to publish' + description: 'The gem version to publish' jobs: build: From 3e347111ae34827e9b9e7930d81077d3a500a2f7 Mon Sep 17 00:00:00 2001 From: Xuan <112967240+xuan-cao-swi@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:49:40 -0500 Subject: [PATCH 5/8] Update push-package-solarwinds.yml --- .github/workflows/push-package-solarwinds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-package-solarwinds.yml b/.github/workflows/push-package-solarwinds.yml index c704d4c1b..049b67546 100644 --- a/.github/workflows/push-package-solarwinds.yml +++ b/.github/workflows/push-package-solarwinds.yml @@ -49,7 +49,7 @@ jobs: echo -e "---\n:github: Bearer $GITHUB_SECRET_TOKEN" >> ~/.gem/credentials chmod 0600 ~/.gem/credentials env: - GITHUB_SECRET_TOKEN: ${{ secrets.GH_PACKAGE_TOKEN }} + GITHUB_SECRET_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Build gem and publish to github package id: gemstep From 718acc86a0697121124be8ee9e65350d4beff065 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Mon, 4 Dec 2023 16:43:24 -0500 Subject: [PATCH 6/8] use simpler action --- .github/workflows/push-package-solarwinds.yml | 30 ++----------------- .../workflows/script/sw_build_and_push_gem.sh | 19 ++++++++++++ 2 files changed, 22 insertions(+), 27 deletions(-) create mode 100755 .github/workflows/script/sw_build_and_push_gem.sh diff --git a/.github/workflows/push-package-solarwinds.yml b/.github/workflows/push-package-solarwinds.yml index 049b67546..6f5d639f7 100644 --- a/.github/workflows/push-package-solarwinds.yml +++ b/.github/workflows/push-package-solarwinds.yml @@ -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: @@ -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 @@ -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 }} diff --git a/.github/workflows/script/sw_build_and_push_gem.sh b/.github/workflows/script/sw_build_and_push_gem.sh new file mode 100755 index 000000000..e15ef6a1c --- /dev/null +++ b/.github/workflows/script/sw_build_and_push_gem.sh @@ -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" From 4c732a8b9e906f6cc3f64c86d32e590062c00086 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Tue, 5 Dec 2023 10:41:40 -0500 Subject: [PATCH 7/8] revision --- .github/workflows/push-package-solarwinds.yml | 5 +---- .github/workflows/script/sw_build_and_push_gem.sh | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/push-package-solarwinds.yml b/.github/workflows/push-package-solarwinds.yml index 6f5d639f7..b8a18ec5b 100644 --- a/.github/workflows/push-package-solarwinds.yml +++ b/.github/workflows/push-package-solarwinds.yml @@ -1,7 +1,4 @@ -# Copyright (c) 2023 SolarWinds, LLC. -# All rights reserved. - -name: Ruby Gem to Github Package +name: Ruby Gem to SolarWinds Github Package on: workflow_dispatch: diff --git a/.github/workflows/script/sw_build_and_push_gem.sh b/.github/workflows/script/sw_build_and_push_gem.sh index e15ef6a1c..1f508a387 100755 --- a/.github/workflows/script/sw_build_and_push_gem.sh +++ b/.github/workflows/script/sw_build_and_push_gem.sh @@ -2,7 +2,7 @@ GEM_NAME="$1" -cd "instrumentation/$GEM_NAME" +cd "instrumentation/$GEM_NAME" || exit bundle install From c144c23a112ded6dbf60c42385aa8a3c3221255c Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Tue, 5 Dec 2023 14:01:31 -0500 Subject: [PATCH 8/8] exit on 1 --- .github/workflows/script/sw_build_and_push_gem.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/script/sw_build_and_push_gem.sh b/.github/workflows/script/sw_build_and_push_gem.sh index 1f508a387..48b287ab4 100755 --- a/.github/workflows/script/sw_build_and_push_gem.sh +++ b/.github/workflows/script/sw_build_and_push_gem.sh @@ -2,7 +2,7 @@ GEM_NAME="$1" -cd "instrumentation/$GEM_NAME" || exit +cd "instrumentation/$GEM_NAME" || exit 1 bundle install