Skip to content

Commit 0087484

Browse files
committed
Add trusted publishing action
1 parent 8818eb8 commit 0087484

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/publish.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish gem
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
# TODO: Prepare release notes
7+
8+
release-gem:
9+
name: Build and push gem to RubyGems.org
10+
runs-on: ubuntu-24.04
11+
environment: "rubygems" # see: https://github.com/DataDog/dd-trace-rb/settings/environments
12+
concurrency: "rubygems" # Only one publish job at a time
13+
14+
permissions:
15+
id-token: write
16+
contents: write
17+
18+
outputs:
19+
version: ${{ steps.version.outputs.version }}
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Ruby
24+
uses: ruby/setup-ruby@v1
25+
with:
26+
ruby-version: '3.3'
27+
- id: version
28+
run: |
29+
echo "version=$(ruby -e 'puts Gem::Specification::load(Dir.glob("*.gemspec").first).version')" >> $GITHUB_OUTPUT
30+
- uses: rubygems/release-gem@v1
31+
32+
github-release:
33+
name: Attach gem to GitHub release and publish
34+
needs: release-gem
35+
runs-on: ubuntu-24.04
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
GH_REPO: ${{ github.repository }}
39+
GEM_VERSION: ${{ needs.release-gem.outputs.version }}
40+
41+
permissions:
42+
contents: write
43+
44+
steps:
45+
- name: Download from RubyGems
46+
run: |
47+
gem fetch datadog --version ${GEM_VERSION} --verbose
48+
- name: Attach to existing release draft
49+
run: |
50+
gh release upload "v${GEM_VERSION}" *.gem --clobber
51+
gh release edit "v${GEM_VERSION}" --draft=false
52+
53+
# TODO: Close existing milestone and create next milestone

0 commit comments

Comments
 (0)