-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from DataDog/streamline-release
Streamline release
- Loading branch information
Showing
4 changed files
with
57 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |