Skip to content

Commit

Permalink
Release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Feb 21, 2023
1 parent 17ec104 commit 4b648ee
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/lib-injection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
build-and-publish-test-image:
runs-on: ubuntu-latest
steps:
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -23,3 +23,4 @@ jobs:
platforms: 'linux/amd64,linux/arm64/v8'
build-args: DDTRACE_RUBY_SHA=${{ github.sha }}
context: ./lib-injection

33 changes: 33 additions & 0 deletions .github/workflows/release-lib-injection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

name: "Release Library Injection"
on:
push:
tags:
- 'v*.*.*'

jobs:
build-and-publish-release-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set version
id: version
run: echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Get version
run: echo "The selected version is ${{ steps.version.outputs.version }}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker
run: docker login -u publisher -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
- name: Docker Build
uses: docker/build-push-action@v3
with:
push: true
tags: ghcr.io/datadog/dd-trace-rb/dd-lib-ruby-init:${{ steps.version.outputs.version }}
platforms: 'linux/amd64,linux/arm64/v8'
build-args: DDTRACE_RUBY_VERSION=${{ steps.version.outputs.version }}
context: ./lib-injection

20 changes: 13 additions & 7 deletions lib-injection/auto_inject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@
version = "<DD_TRACE_VERSION_TO_BE_REPLACED>"
sha = "<DD_TRACE_SHA_TO_BE_REPLACED>"

condition = if !version.empty?
"--version '#{version}'"
elsif !sha.empty?
"--github 'datadog/dd-trace-rb' --ref '#{sha}'"
else
puts "NO VERSION"
end
condition =
if !version.empty?
# For public release
"--version '#{version.gsub(/^v/, '')}'"
elsif !sha.empty?
# For internal testing
"--github 'datadog/dd-trace-rb' --ref '#{sha}'"
else
puts "NO VERSION"
end

puts "ddtrace is not installed... Perform auto-injection... for dd-trace-rb"

# Copies for trial
system "cp Gemfile Gemfile-datadog"
system "cp Gemfile.lock Gemfile-datadog.lock"

if system "skip_autoinject=true BUNDLE_GEMFILE=Gemfile-datadog bundle add ddtrace #{condition} --require ddtrace/auto_instrument"
puts 'ddtrace added to bundle...'

# Trial success, replace the original
system "cp Gemfile-datadog Gemfile"
system "cp Gemfile-datadog.lock Gemfile.lock"
else
puts 'Something went wrong when adding ddtrace to bundle...'
end

# Remove the copies
system "rm Gemfile-datadog Gemfile-datadog.lock"
end

Expand Down

0 comments on commit 4b648ee

Please sign in to comment.