Compare commits
36 Commits
master
...
release/7.
Author | SHA1 | Date | |
---|---|---|---|
|
a7c8068c7c | ||
|
f7c5b3e956 | ||
|
4dc95bf252 | ||
|
dc7dd1e768 | ||
|
8add493c77 | ||
|
30bcef5c7f | ||
|
f9a41a087c | ||
|
35131167a6 | ||
|
d215b853f8 | ||
|
84a970f8a4 | ||
|
31cbe74bb2 | ||
|
108af45b25 | ||
|
100a1b61f4 | ||
|
d44e0c8512 | ||
|
8f36bf3ee6 | ||
|
890c988757 | ||
|
bedc122eda | ||
|
e87cd570d2 | ||
|
888cfb7f0c | ||
|
febd814501 | ||
|
91716319e5 | ||
|
95a34adfba | ||
|
0865ac62e2 | ||
|
fa26cc9ba1 | ||
|
06622d8529 | ||
|
6e884a3321 | ||
|
26f94b13a3 | ||
|
543d33a363 | ||
|
08c6b3a2e3 | ||
|
fe62eb455c | ||
|
139af4526d | ||
|
fdc6d95388 | ||
|
55e21143a9 | ||
|
4e2e9638b6 | ||
|
6a103e03a3 | ||
|
a2e2213ce4 |
158
.github/workflows/assign-milestones.js
vendored
158
.github/workflows/assign-milestones.js
vendored
|
@ -1,158 +0,0 @@
|
||||||
// assign a milestone to issues or PRs added to a project, with a name corresponding
|
|
||||||
// to the name of the project - create the milestone if it does not exist
|
|
||||||
//
|
|
||||||
// adding a *second* project to the issue will update the milestone accordingly
|
|
||||||
// removing that project will reset the milestone entirely (not use the other project)
|
|
||||||
// and, no idea what happens if one very quickly adds and removes an issue
|
|
||||||
//
|
|
||||||
// an issue or PR actually becomes a card (or, a card is actually created...) when
|
|
||||||
// it's move to a project column for the first time - being assigned to the project
|
|
||||||
// and showing in project's backlog is not enough.
|
|
||||||
|
|
||||||
module.exports = async ({github, context, core}) => {
|
|
||||||
|
|
||||||
const restapi = github.rest
|
|
||||||
|
|
||||||
function last1(s) {
|
|
||||||
const pos = s.lastIndexOf('/')
|
|
||||||
return s.substring(pos + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
function last2(s) {
|
|
||||||
const pos1 = s.lastIndexOf('/')
|
|
||||||
const pos2 = s.lastIndexOf('/', pos1-1)
|
|
||||||
return [ s.substring(pos2 + 1, pos1), s.substring(pos1 + 1) ]
|
|
||||||
}
|
|
||||||
|
|
||||||
function firstOrDefault(items, predicate) {
|
|
||||||
for (const item of items) {
|
|
||||||
if (predicate(item)) {
|
|
||||||
return item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
// insanely enough, due to the total lack of documentation, this
|
|
||||||
// is the best way one can figure out what exactly we are getting
|
|
||||||
console.log(github)
|
|
||||||
console.log(context)
|
|
||||||
console.log(context.payload)
|
|
||||||
|
|
||||||
//console.log(`event: ${github.event_name}/${github.event.action}`)
|
|
||||||
|
|
||||||
// get and validate the event name
|
|
||||||
const eventName = context.eventName
|
|
||||||
if (eventName != 'project_card') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// get and validate the event action
|
|
||||||
const eventAction = context.payload.action
|
|
||||||
if (eventAction != 'created' && eventAction != 'deleted') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`event: ${eventName}/${eventAction}`)
|
|
||||||
|
|
||||||
const columnId = context.payload.project_card.column_id
|
|
||||||
const columnResponse = await restapi.projects.getColumn({
|
|
||||||
column_id: columnId
|
|
||||||
})
|
|
||||||
const column = columnResponse.data
|
|
||||||
console.log(column)
|
|
||||||
|
|
||||||
const projectId = last1(column.project_url)
|
|
||||||
const projectResponse = await restapi.projects.get({
|
|
||||||
project_id: projectId
|
|
||||||
});
|
|
||||||
const project = projectResponse.data
|
|
||||||
console.log(project)
|
|
||||||
const projectName = project.name
|
|
||||||
|
|
||||||
// -- when a card is deleted it cannot be fetched!
|
|
||||||
//const cardId = context.payload.project_card.id
|
|
||||||
//const cardResponse = await restapi.projects.getCard({
|
|
||||||
// card_id: cardId
|
|
||||||
//})
|
|
||||||
//const card = cardResponse.data
|
|
||||||
//console.log(card)
|
|
||||||
|
|
||||||
//const [ itemType, itemNumber ] = last2(card.content_url)
|
|
||||||
const [ itemType, itemNumber ] = last2(context.payload.project_card.content_url)
|
|
||||||
const isIssue = itemType == 'issues'
|
|
||||||
const isPull = itemType == 'pulls'
|
|
||||||
if (!isIssue && !isPull) {
|
|
||||||
core.setFailed(`Unsupported item type ${itemType}`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const itemApi = isIssue ? restapi.issues : restapi.pulls
|
|
||||||
|
|
||||||
var request = {
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo
|
|
||||||
}
|
|
||||||
request[isIssue ? 'issue_number' : 'pull_number'] = itemNumber
|
|
||||||
console.log(request)
|
|
||||||
|
|
||||||
const itemResponse = await itemApi.get(request)
|
|
||||||
const item = itemResponse.data
|
|
||||||
console.log(item)
|
|
||||||
const itemId = item.id
|
|
||||||
const itemMilestone = item.milestone
|
|
||||||
console.log(`item: ${itemType}/${itemId} milestone: ${itemMilestone == null ? '<none>' : itemMilestone}`)
|
|
||||||
|
|
||||||
if (eventAction == 'created') {
|
|
||||||
console.log('add or update milestone of issue/pull of created card')
|
|
||||||
|
|
||||||
const milestonesResponse = await restapi.issues.listMilestones({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo
|
|
||||||
})
|
|
||||||
const milestones = milestonesResponse.data
|
|
||||||
console.log(milestones)
|
|
||||||
var milestone = firstOrDefault(milestones, (x) => x.title == projectName)
|
|
||||||
|
|
||||||
if (!milestone) {
|
|
||||||
console.log(`create milestone '${projectName}'`)
|
|
||||||
const milestoneResponse = await restapi.issues.createMilestone({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
title: projectName
|
|
||||||
})
|
|
||||||
milestone = milestoneResponse.data
|
|
||||||
}
|
|
||||||
|
|
||||||
const milestoneNumber = milestone.number
|
|
||||||
|
|
||||||
if (!item.milestone || item.milestone.number != milestoneNumber)
|
|
||||||
{
|
|
||||||
request = {
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
milestone: milestoneNumber
|
|
||||||
}
|
|
||||||
request[isIssue ? 'issue_number' : 'pull_number'] = itemNumber
|
|
||||||
await itemApi.update(request)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (eventAction == 'deleted') {
|
|
||||||
if (itemMilestone) {
|
|
||||||
console.log('remove milestone from issue/pull of deleted card')
|
|
||||||
request = {
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo
|
|
||||||
}
|
|
||||||
request[isIssue ? 'issue_number' : 'pull_number'] = itemNumber
|
|
||||||
request.milestone = null
|
|
||||||
await itemApi.update(request)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log('deleted card had no milestone')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(`nothing to do for evet action ${eventAction}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
46
.github/workflows/assign-milestones.yml
vendored
46
.github/workflows/assign-milestones.yml
vendored
|
@ -1,46 +0,0 @@
|
||||||
name: Assign Milestones
|
|
||||||
on:
|
|
||||||
project_card:
|
|
||||||
# ignore: moved, converted, edited
|
|
||||||
types: [ created, deleted, moved ] # FIXME temp
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
assign:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Assign
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Assign
|
|
||||||
uses: actions/github-script@v5
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.MY_GITHUB_TOKEN_TESTREPO }}
|
|
||||||
script: |
|
|
||||||
|
|
||||||
// see https://github.com/actions/github-script
|
|
||||||
//
|
|
||||||
// note: 'github' below is not the same as the yml-level 'github' context
|
|
||||||
// see https://docs.github.com/en/actions/learn-github-actions/contexts
|
|
||||||
// for yml contexts
|
|
||||||
//
|
|
||||||
// github A pre-authenticated octokit/rest.js client with pagination plugins
|
|
||||||
// .rest The REST API (e.g. github.rest.issues.get(...) gets an issue)
|
|
||||||
// .request
|
|
||||||
// .paginate
|
|
||||||
// .graphql
|
|
||||||
// context An object containing the context of the workflow run
|
|
||||||
// see https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts
|
|
||||||
// core A reference to the @actions/core package
|
|
||||||
// glob A reference to the @actions/glob package
|
|
||||||
// io A reference to the @actions/io package
|
|
||||||
// exec A reference to the @actions/exec package
|
|
||||||
// require A proxy wrapper around the normal Node.js require to enable requiring relative paths
|
|
||||||
// (relative to the current working directory) + requiring npm packages installed in the
|
|
||||||
// current working directory.
|
|
||||||
|
|
||||||
const script = require('./.github/workflows/assign-milestones.js')
|
|
||||||
await script({github, context, core})
|
|
137
.github/workflows/assign-to-project.yml
vendored
137
.github/workflows/assign-to-project.yml
vendored
|
@ -1,137 +0,0 @@
|
||||||
name: Assign PRs to Project
|
|
||||||
on:
|
|
||||||
#issues:
|
|
||||||
# types: [ opened ]
|
|
||||||
|
|
||||||
#pull_request:
|
|
||||||
# types: [ opened ]
|
|
||||||
|
|
||||||
# important to use pull_request_target here to run code from 'main' not the PR,
|
|
||||||
# with access to PAT - and safe permission to make changes to the project
|
|
||||||
pull_request_target:
|
|
||||||
types: [ opened, labeled ]
|
|
||||||
|
|
||||||
# github-script: https://github.com/actions/github-script
|
|
||||||
# -> points to github rest (octokit) reference doc
|
|
||||||
|
|
||||||
# github PAT: https://github.com/settings/tokens
|
|
||||||
# must have full repo access
|
|
||||||
|
|
||||||
# FIXME how can I prevent a user from creating a PR and stealing my token?
|
|
||||||
# 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
|
|
||||||
# curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ghp_..." https://api.github.com/projects/1/columns?owner=zpqrtbnk&repo=test-repo
|
|
||||||
# curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ghp_..." https://api.github.com/projects/1/columns?owner=zpqrtbnk-alt&repo=test-repo-alt
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
assign:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Assign
|
|
||||||
steps:
|
|
||||||
- name: Assign
|
|
||||||
uses: actions/github-script@v4
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.MY_GITHUB_TOKEN_TESTREPO }}
|
|
||||||
script: |
|
|
||||||
//const project_name = 'The API Team Board'
|
|
||||||
//const column_name = 'Drafting'
|
|
||||||
|
|
||||||
const project_name = 'test-project'
|
|
||||||
const column_name = 'To do'
|
|
||||||
|
|
||||||
function firstOrDefault(items, predicate) {
|
|
||||||
for (const item of items) {
|
|
||||||
if (predicate(item)) {
|
|
||||||
return item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the project
|
|
||||||
console.log('find project...')
|
|
||||||
const projects = await github.projects.listForRepo({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo
|
|
||||||
})
|
|
||||||
console.log(`retrieved ${projects.data.length} projects.`)
|
|
||||||
const project = firstOrDefault(projects.data, (x) => x.name === project_name)
|
|
||||||
if (!project) {
|
|
||||||
core.setFailed(`Failed to find project "${project_name}".`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(`project '${project_name}' id: ${project.id}.`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the column
|
|
||||||
console.log('find column...')
|
|
||||||
const columns = await github.projects.listColumns({
|
|
||||||
project_id: project.id
|
|
||||||
})
|
|
||||||
console.log(`retrieved ${columns.data.length} columns.`)
|
|
||||||
const column = firstOrDefault(columns.data, (x) => x.name === column_name)
|
|
||||||
if (!column) {
|
|
||||||
core.setFailed(`Failed to find column "${column_name}" in project ${project.name}.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(`column '${column_name}' id: ${column.id}.`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// determine content type
|
|
||||||
console.log('determine content type...')
|
|
||||||
const event_name = context.eventName
|
|
||||||
var content_type = null
|
|
||||||
var item_number = null
|
|
||||||
var item_id = null
|
|
||||||
if (event_name === 'issues') {
|
|
||||||
content_type = 'Issue'
|
|
||||||
// temp!
|
|
||||||
core.setFailed(`Unsupported: issue.`)
|
|
||||||
return
|
|
||||||
item_number = context.issue.number
|
|
||||||
item_id = context.issue.id
|
|
||||||
}
|
|
||||||
if (event_name === 'pull_request' || event_name === 'pull_request_target') {
|
|
||||||
content_type = 'PullRequest'
|
|
||||||
item_number = context.payload.pull_request.number
|
|
||||||
item_id = context.payload.pull_request.id
|
|
||||||
}
|
|
||||||
if (!content_type) {
|
|
||||||
core.setFailed(`Unexpected event name "${event_name}".`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(`content type: ${content_type}.`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the item
|
|
||||||
console.log('get the item...')
|
|
||||||
const item = await github.issues.get({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
issue_number: item_number
|
|
||||||
})
|
|
||||||
if (!item) {
|
|
||||||
core.setFailed(`Failed to get item ${item_number}.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(`${content_type} #${context.issue.number} id: ${item.data.id}.`)
|
|
||||||
if (item_id === item.data.id) {
|
|
||||||
console.log(`item_id: ${item_id}`)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(`but 'context.payload' provides item_id: ${item_id} and meh?`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('create the card...')
|
|
||||||
console.log(`in column ${column.id} for item ${item_id} of type ${content_type}`)
|
|
||||||
await github.projects.createCard({
|
|
||||||
column_id: column.id,
|
|
||||||
//note:,
|
|
||||||
content_id: item_id,
|
|
||||||
content_type: content_type
|
|
||||||
})
|
|
||||||
console.log('created')
|
|
40
.github/workflows/hz.js
vendored
Normal file
40
.github/workflows/hz.js
vendored
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
|
||||||
|
// see https://github.com/actions/github-script
|
||||||
|
// , core, glob, io, exec, require
|
||||||
|
module.exports = function (github, context) {
|
||||||
|
|
||||||
|
var module = {}
|
||||||
|
|
||||||
|
// this is *not* exported
|
||||||
|
function noop ( ) { }
|
||||||
|
|
||||||
|
// this *is* exported
|
||||||
|
module.getReleaseByTag = async function (tag_name) {
|
||||||
|
var rel = null
|
||||||
|
try {
|
||||||
|
// this does *not* return draft releases, so we have to list them
|
||||||
|
//rel = await github.repos.getReleaseByTag({ ... })
|
||||||
|
const rels = await github.repos.listReleases({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo
|
||||||
|
})
|
||||||
|
for (const r of rels.data) {
|
||||||
|
if (r.tag_name === tag_name) {
|
||||||
|
rel = r
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return rel
|
||||||
|
}
|
||||||
|
|
||||||
|
module.getRefReleaseTag = function (ref) {
|
||||||
|
// test, must start with 'refs/heads/release/' 19 chars
|
||||||
|
return "v" + ref.substring(19)
|
||||||
|
}
|
||||||
|
|
||||||
|
return module;
|
||||||
|
}
|
137
.github/workflows/publish-release.js
vendored
137
.github/workflows/publish-release.js
vendored
|
@ -1,137 +0,0 @@
|
||||||
module.exports = /*async*/ ({github, context, core}) => {
|
|
||||||
|
|
||||||
const restapi = github.rest
|
|
||||||
var dryrun = context.payload.inputs.dryrun
|
|
||||||
|
|
||||||
function firstOrDefault(items, predicate) {
|
|
||||||
for (const item of items) {
|
|
||||||
if (predicate(item)) {
|
|
||||||
return item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
async function validateRelease() {
|
|
||||||
|
|
||||||
const version = context.payload.inputs.version
|
|
||||||
const tag = "v" + version
|
|
||||||
console.log(`Validate version '${version}'.`)
|
|
||||||
|
|
||||||
// git branch must exist
|
|
||||||
const branchRefs = await restapi.git.listMatchingRefs({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
ref: `heads/release/${version}`
|
|
||||||
})
|
|
||||||
if (firstOrDefault(branchRefs.data, (x) => x.ref == `refs/heads/release/${version}`) == null) {
|
|
||||||
core.setFailed(`Could not find branch 'release/${version}'.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log(`Found branch 'release/${version}'.`)
|
|
||||||
|
|
||||||
// github milestone must exist and be open
|
|
||||||
const milestone = await getMilestone()
|
|
||||||
if (milestone == null) {
|
|
||||||
core.setFailed(`Could not find milestone '${version}'.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (milestone.state != "open") {
|
|
||||||
core.setFailed(`Milestone '${version}' is already closed.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log(`Found open milestone '${version}'.`)
|
|
||||||
|
|
||||||
// github release must exist and not be published yet
|
|
||||||
const release = await getRelease()
|
|
||||||
if (release === null) {
|
|
||||||
core.setFailed(`Could not find a GitHub release for tag '${tag}'.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!release.draft) {
|
|
||||||
core.setFailed(`GitHub release for tag '${tag}' is already published.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log(`Found yet-unpublished GitHub release for tag '${tag}'.`)
|
|
||||||
|
|
||||||
// tag must not exist
|
|
||||||
const tagRefs = await restapi.git.listMatchingRefs({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
ref: `tags/${tag}`
|
|
||||||
})
|
|
||||||
if (firstOrDefault(tagRefs.data, (x) => x.ref == `tags/${tag}`) != null) {
|
|
||||||
core.setFailed(`Tag '${tag}' already exists.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log(`Verified that tag '${tag}' does not exist yet.`)
|
|
||||||
|
|
||||||
console.log('Release is valid.')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function publishRelease() {
|
|
||||||
|
|
||||||
const version = context.payload.inputs.version
|
|
||||||
const tag = "v" + version
|
|
||||||
console.log(`Publish GitHub release '${version}'.`)
|
|
||||||
|
|
||||||
const release = await getRelease()
|
|
||||||
|
|
||||||
await restapi.repos.updateRelease({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
release_id: release.id,
|
|
||||||
draft: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function closeMilestone() {
|
|
||||||
|
|
||||||
const version = context.payload.inputs.version
|
|
||||||
const tag = "v" + version
|
|
||||||
console.log(`Close milestone '${version}'.`)
|
|
||||||
|
|
||||||
const milestone = await getMilestone()
|
|
||||||
await restapi.issues.updateMilestone({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
milestone_number: milestone.number,
|
|
||||||
state: "closed"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getRelease() {
|
|
||||||
|
|
||||||
// note: getReleaseByTag only returns published releases
|
|
||||||
|
|
||||||
// note: we may eventually need to paginate
|
|
||||||
// and then releases.headers should contain what we need?
|
|
||||||
// https://octokit.github.io/rest.js/v18#pagination
|
|
||||||
|
|
||||||
const version = context.payload.inputs.version
|
|
||||||
const tag = `v${version}`
|
|
||||||
const releases = await restapi.repos.listReleases({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo
|
|
||||||
})
|
|
||||||
const release = firstOrDefault(releases.data, (x) => x.tag_name == tag)
|
|
||||||
return release
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getMilestone() {
|
|
||||||
|
|
||||||
const version = context.payload.inputs.version
|
|
||||||
const milestonesResponse = await restapi.issues.listMilestones({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo
|
|
||||||
})
|
|
||||||
const milestones = milestonesResponse.data
|
|
||||||
return firstOrDefault(milestones, (x) => x.title == version)
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
validateRelease: validateRelease,
|
|
||||||
publishRelease: publishRelease,
|
|
||||||
closeMilestone: closeMilestone
|
|
||||||
}
|
|
||||||
}
|
|
99
.github/workflows/publish-release.yml
vendored
99
.github/workflows/publish-release.yml
vendored
|
@ -1,46 +1,101 @@
|
||||||
name: Publish Release
|
name: Publish
|
||||||
|
|
||||||
|
#meh
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
confirm:
|
||||||
description: 'Version'
|
description: "This is really going to release. Enter \'yolo\' to confirm that you really want to do it."
|
||||||
required: true
|
required: true
|
||||||
dryrun:
|
default: ""
|
||||||
description: 'DryRun'
|
|
||||||
required: true
|
|
||||||
type: boolean
|
|
||||||
default: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
job:
|
job:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: startsWith(github.ref, 'refs/heads/release/')
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
|
- name: Confirm
|
||||||
|
uses: actions/github-script@v4
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
if ("${{ github.event.inputs.confirm }}" != "yolo") {
|
||||||
|
core.setFailed(`Not confirmed (confirm = '${{ github.event.inputs.confirm }}').`)
|
||||||
|
}
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Validate the release
|
||||||
|
uses: actions/github-script@v4
|
||||||
|
with:
|
||||||
|
|
||||||
|
# token needed to see draft releases when getting all releases
|
||||||
|
github-token: ${{ secrets.MY_GITHUB_TOKEN_TESTREPO }}
|
||||||
|
script: |
|
||||||
|
const hz = require("./.github/workflows/hz.js")(github, context)
|
||||||
|
const ref = "${{ github.ref }}"
|
||||||
|
const tag = hz.getRefReleaseTag(ref)
|
||||||
|
if (tag === null) {
|
||||||
|
core.setFailed(`Invalid reference ${ref} is not release/<version>.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var rel = await hz.getReleaseByTag(tag)
|
||||||
|
if (rel === null) {
|
||||||
|
core.setFailed(`Could not find a release for tag ${tag}.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!rel.draft) {
|
||||||
|
core.setFailed(`Release for tag ${tag} is already published.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const ref = await github.git.getRef({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
ref: 'tags/' + tag
|
||||||
|
})
|
||||||
|
core.setFailed(`Tag ${tag} already exists.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
// this is expected
|
||||||
|
}
|
||||||
|
// everything is OK
|
||||||
|
|
||||||
- name: Configure repository
|
- name: Configure repository
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
git config user.email "github-actions@hazelcast.com"
|
git config user.email "github-actions@hazelcast.com"
|
||||||
git config user.name "GitHub Actions (Build Release)"
|
git config user.name "GitHub Actions (Build Release)"
|
||||||
|
|
||||||
- name: Validate the release
|
- name: Finalize the release
|
||||||
uses: actions/github-script@v5
|
run: |
|
||||||
with:
|
ref="${{ github.ref }}"
|
||||||
script: |
|
branch="${ref:11}" # trim starting 'refs/heads/' (11 chars)
|
||||||
const scriptf = require('./.github/workflows/publish-release.js')
|
version="${ref:19}" # trim starting 'refs/heads/release/' (19 chars)
|
||||||
const script = scriptf({github, context, core})
|
echo "Tag branch $branch as v$version"
|
||||||
await script.validateRelease()
|
git tag v$version
|
||||||
|
git push --tags
|
||||||
|
#git push :$branch
|
||||||
|
|
||||||
- name: Finalize GitHub release and milestone
|
- name: Publish the release
|
||||||
if: ${{ github.event.inputs.dryrun == 'false' }}
|
uses: actions/github-script@v4
|
||||||
uses: actions/github-script@v5
|
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const scriptf = require('./.github/workflows/publish-release.js')
|
const hz = require("./.github/workflows/hz.js")(github, context)
|
||||||
const script = scriptf({github, context, core})
|
const ref = "${{ github.ref }}"
|
||||||
await script.publishRelease()
|
const tag = hz.getRefReleaseTag(ref)
|
||||||
await script.closeMilestone()
|
if (tag === null) {
|
||||||
|
core.setFailed(`Invalid reference ${ref} is not release/<version>.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var rel = await hz.getReleaseByTag(tag)
|
||||||
|
await github.repos.updateRelease({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
release_id: rel.id,
|
||||||
|
draft: false
|
||||||
|
})
|
|
@ -19,7 +19,7 @@ Clone the repository with: `git clone https://github.com/zpqrtbnk/test-repo.git
|
||||||
We have test GitHUb pages (from the `gh-pages` branch) at: http://zpqrtbnk.github.io/test-repo/
|
We have test GitHUb pages (from the `gh-pages` branch) at: http://zpqrtbnk.github.io/test-repo/
|
||||||
|
|
||||||
We have an image in the README (markdown)
|
We have an image in the README (markdown)
|
||||||
![Image](wtf.jpg)
|
![Image](https://raw.github.com/zpqrtbnk/test-repo/master/wtf.jpg)
|
||||||
|
|
||||||
We have an image in the README (html)
|
We have an image in the README (html)
|
||||||
<img src="./wtf.jpg" />
|
<img src="./wtf.jpg" />
|
||||||
|
|
3
dan.txt
Normal file
3
dan.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
this is a new file only in my branch
|
||||||
|
|
||||||
|
changing something that won't conflict in master
|
Loading…
Reference in New Issue
Block a user