-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aaa8f8b
commit 853e103
Showing
4 changed files
with
503 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Release | ||
on: | ||
milestone: | ||
types: [closed] | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- name: Release | ||
working-directory: releaser | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
MILESTONE_NUMBER: "${{ github.event.milestone.number }}" | ||
run: | | ||
npm install | ||
npm run exec | ||
- name: Set Git config | ||
run: | | ||
git config user.name 'github-actions[bot]' | ||
git config user.email 'github-actions[bot]@users.noreply.github.com' | ||
- name: Update stable branch | ||
run: | | ||
git fetch --unshallow | ||
git checkout stable | ||
git pull | ||
git merge --no-ff main -m "Publish to stable" | ||
git push |
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,108 @@ | ||
import { Octokit } from "@octokit/rest"; | ||
|
||
let repository = process.env.GITHUB_REPOSITORY | ||
let sha = process.env.GITHUB_SHA | ||
let milestoneNumber = process.env.MILESTONE_NUMBER | ||
|
||
let auth = process.env.GITHUB_TOKEN | ||
|
||
let repositoryParts = repository.split('/'); | ||
let owner = repositoryParts[0]; | ||
let repo = repositoryParts[1]; | ||
|
||
let tagName = `release-${Math.floor(Date.now() / 1000)}` | ||
|
||
const octokit = new Octokit({ | ||
auth | ||
}); | ||
|
||
const categories = [{ | ||
title: "## 🚀 New labs", | ||
label: 'new' | ||
}, { | ||
title: "## ✨ Updated labs", | ||
label: 'update' | ||
}, { | ||
title: "## 🐛 Fixes", | ||
label: 'fix' | ||
}, { | ||
title: "## 🧪 Features", | ||
label: 'feat' | ||
}] | ||
|
||
let entries = {}; | ||
|
||
let milestone = await octokit.rest.issues.getMilestone({ | ||
owner, | ||
repo, | ||
milestone_number: milestoneNumber, | ||
}); | ||
|
||
for await (const response of octokit.paginate.iterator( | ||
octokit.rest.pulls.list, | ||
{ | ||
owner, | ||
repo, | ||
state: 'closed' | ||
}, | ||
)) { | ||
response.data.forEach((e) => { | ||
if(e.milestone) { | ||
if(e.milestone.number == milestoneNumber) { | ||
categories.forEach((c) => { | ||
let targetPrefix = `${c.label}:`; | ||
|
||
if(e.title.indexOf(targetPrefix) == 0) { | ||
if(!entries[c.title]) { | ||
entries[c.title] = []; | ||
} | ||
|
||
entries[c.title].push({ | ||
number: e.number, | ||
title: e.title.substring(targetPrefix.length + 1), | ||
url: e.html_url, | ||
author: { | ||
login: e.user.login, | ||
url: e.user.html_url, | ||
} | ||
}); | ||
} | ||
}) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
let output = ''; | ||
|
||
categories.forEach((c) => { | ||
let categoryOutput = `${c.title} | ||
`; | ||
if(entries[c.title]) { | ||
let categoryEntries = entries[c.title]; | ||
|
||
if(categoryEntries.length > 0) { | ||
categoryEntries.forEach((e) => { | ||
categoryOutput += `- ${e.title} by [@${e.author.login}](${e.author.url}) ([#${e.number}](${e.url}))\n` | ||
}); | ||
|
||
output += `${categoryOutput} \n`; | ||
} | ||
} | ||
}); | ||
|
||
await octokit.rest.git.createRef({ | ||
owner, | ||
repo, | ||
ref: `refs/tags/${tagName}`, | ||
sha, | ||
}); | ||
|
||
await octokit.rest.repos.createRelease({ | ||
owner, | ||
repo, | ||
tag_name: tagName, | ||
name: milestone.data.title, | ||
body: output | ||
}); |
Oops, something went wrong.