Skip to content

Commit

Permalink
Add trusted publishing action
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Jan 23, 2025
1 parent 100ed0c commit 7d6b305
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish gem

on: workflow_dispatch

jobs:
# TODO: Prepare release notes

release-gem:
name: Build and push gem to RubyGems.org
runs-on: ubuntu-24.04
environment: "rubygems" # see: https://github.com/DataDog/dd-trace-rb/settings/environments
concurrency: "rubygems" # Only one publish job at a time

permissions:
id-token: write
contents: write

outputs:
version: ${{ steps.version.outputs.version }}

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- id: version
run: |
echo "version=$(ruby -e 'puts Gem::Specification::load(Dir.glob("*.gemspec").first).version')" >> $GITHUB_OUTPUT
- uses: rubygems/release-gem@v1

github-release:
name: Attach gem to GitHub release and publish
needs: release-gem
runs-on: ubuntu-24.04
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
GEM_VERSION: ${{ needs.release-gem.outputs.version }}

permissions:
contents: write

steps:
- name: Download from RubyGems
run: |
gem fetch datadog --version ${GEM_VERSION} --verbose
- name: Attach to existing release draft
run: |
gh release upload "v${GEM_VERSION}" *.gem --clobber
gh release edit "v${GEM_VERSION}" --draft=false
# TODO: Close existing milestone and create next milestone

0 comments on commit 7d6b305

Please sign in to comment.