-
Notifications
You must be signed in to change notification settings - Fork 6
103 lines (86 loc) · 3.69 KB
/
build_and_release_gem.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Copyright (c) 2021 SolarWinds, LLC.
# All rights reserved.
name: BUILD, VERIFY, and RELEASE 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)
# - SW_APM_SERVICE_KEY
# - SW_APM_COLLECTOR
#
# The correct oboe version has to be in the file ext/oboe_metal/src/VERSION
on:
workflow_dispatch:
jobs:
build:
name: Build + Release Gem to RubyGems
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.7 and bundle
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Install gems
run: |
echo 'gem: --no-document' >> ~/.gemrc
bundle install --without development --without test
- name: Install swig 4.0.2
run: |
apt udate && apt install -y --no-install-recommends bison
curl -SL https://github.com/swig/swig/archive/refs/tags/v4.0.2.tar.gz | tar xzC /tmp
cd /tmp/swig-4.0.2
./autogen.sh && ./configure && make && sudo make install
cd -
- name: Download files from files.appoptics.com and create swig wrapper
env:
TRACE_BUILD_TOKEN: ${{ secrets.TRACE_BUILD_RUBY_ACTIONS_API_TOKEN }}
run: |
bundle exec rake oboe_files_sw_apm_fetch
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 ::set-output name=checksum::$checksum
echo ::set-output name=gem_version::`ruby -e 'require "./lib/solarwinds_apm/version"; puts SolarWindsAPM::Version::STRING'`
- name: Get checksum from Rubygems
id: checksum
run: |
gem_version=${{ steps.build.outputs.gem_version }}
echo ::set-output name=geminfo::`curl https://rubygems.org/api/v2/rubygems/solarwinds_apm/versions/$gem_version.json`
- 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 }}"
- 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.GITHUB_TOKEN}}
script: |
github.repos.createRelease({
owner: "solarwinds-apm",
repo: "appoptics-apm-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.APPOPTICS_SERVICE_KEY }}
SW_APM_COLLECTOR: ${{ secrets.APPOPTICS_COLLECTOR}}
run: |
sleep 1
gem install solarwinds_apm --version ${{ steps.build.outputs.gem_version }}
ruby ./scripts/test_install.rb