Skip to content

Commit

Permalink
Merge pull request #176 from DataDog/streamline-release
Browse files Browse the repository at this point in the history
Streamline release
  • Loading branch information
anmarchenko authored May 14, 2024
2 parents f2f9160 + a8fe457 commit b94ef15
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 139 deletions.
56 changes: 32 additions & 24 deletions .github/workflows/add-milestone-to-pull-requests.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
name: Add milestone to pull requests
on:
pull_request_target:
pull_request:
types: [closed]
branches:
- main

jobs:
add_milestone_to_merged:
permissions:
issues: write
pull-requests: write
if: github.event.pull_request.merged && github.event.pull_request.milestone == null
name: Add milestone to merged pull requests
add_milestone:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && github.event.pull_request.milestone == null
steps:
- name: Checkout code
# Checks out the branch that the pull request is merged into
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }}

- name: Get major version from gemspec
# Parse the gemspec and return the major version
id: version
run: |
echo "::set-output name=version::$(find . -name *.gemspec | ruby -ne 'puts Gem::Specification.load($_.chomp).version.to_s.split(".").first')"
- name: Get project milestones
id: milestones
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const list = await github.rest.issues.listMilestones({
const milestones = await github.rest.issues.listMilestones({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
})
// Need to manually sort because "sort by number" isn't part of the api
// highest number first
const milestones = list.data.sort((a,b) => (b.number - a.number))
return milestones.data
return milestones.length == 0 ? null : milestones[0].number
- name: Update Pull Request
if: steps.milestones.outputs.result != null
uses: actions/github-script@v6
# Update the merged pull request with the milestone starts with the major version
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
// Confusingly, the issues api is used because pull requests are issues
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.pull_request.number }},
milestone: ${{ steps.milestones.outputs.result }},
});
const milestones = ${{steps.milestones.outputs.result}}
const majorVersion = ${{steps.version.outputs.version}}
const milestone = milestones.find(m => m.title.startsWith(majorVersion))
if (milestone) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.pull_request.number }},
milestone: milestone.number
})
}
22 changes: 0 additions & 22 deletions .github/workflows/create-next-milestone.yml

This file was deleted.

93 changes: 0 additions & 93 deletions .github/workflows/draft-release.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish Gem

on:
push:
tags:
- 'v*'

jobs:
push:
runs-on: ubuntu-latest

permissions:
contents: write
id-token: write

environment: release

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '3.2.4'
- uses: rubygems/release-gem@v1

0 comments on commit b94ef15

Please sign in to comment.