Compare commits

...

43 Commits

Author SHA1 Message Date
f110a678f5
rm bang
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
2022-07-27 08:40:56 +02:00
bfcc41e678
New: test-2
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
2022-07-27 08:39:26 +02:00
917323e628
New test-1
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
2022-07-27 08:35:18 +02:00
e0c7e2a725
Singned commit + source modify
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
2022-06-20 01:49:32 +02:00
Stephan
7bc1195651 exp 2022-03-18 18:49:47 +01:00
Stephan
786c441206 exp 2022-03-18 18:48:12 +01:00
Stephan
558f12143c exp 2022-03-18 18:45:23 +01:00
Stephan
2cd8137eeb exp 2022-03-18 18:39:54 +01:00
Stephan
77f77c3e8b exp 2022-03-18 18:37:35 +01:00
Stephan
143637c4fc exp 2022-03-18 18:31:39 +01:00
Stephan
06bdaca2c1 exp 2022-03-18 18:30:07 +01:00
Stephan
10c0963c6d exp 2022-03-18 18:24:54 +01:00
Stephan
30c00bf385 exp 2022-03-18 18:23:20 +01:00
Stephan
d6b1a8d591 exp 2022-03-18 18:20:34 +01:00
Stephan
c090c23662 exp 2022-03-18 18:10:55 +01:00
Stephan
d8cd3257e0 exp 2022-03-18 18:08:47 +01:00
Stephan
93e9740904 exp 2022-03-18 18:03:53 +01:00
Stephan
95d31440db exp 2022-03-18 18:02:01 +01:00
Stephan
f916de4ff4 exp 2022-03-18 18:00:22 +01:00
Stephan
b3615798ac exp 2022-03-18 17:58:45 +01:00
Stephan
4f5e3068cc exp 2022-03-18 17:52:23 +01:00
Stephan
86dab14dfd exp 2022-03-18 17:50:11 +01:00
Stephan
fa0c7b9ac1 exp 2022-03-18 17:46:24 +01:00
Stephan
863aefcc9d exp 2022-03-18 17:42:21 +01:00
Stephan
d6ed51a6f0 exp 2022-03-18 17:02:19 +01:00
Stephan
efed3f3cc1 exp 2022-03-18 16:58:14 +01:00
Stephan
13a337a9b8 exp 2022-03-18 16:56:06 +01:00
Stephan
ac561c87a4 exp 2022-03-18 16:45:22 +01:00
Stephan
6f924bbb78 exp 2022-03-18 16:44:03 +01:00
Stephan
cb40378ce6 exp 2022-03-18 16:40:35 +01:00
Stephan
74f650bb33 exp 2022-03-18 16:35:35 +01:00
Stephan
b893475bf9 exp 2022-03-18 16:33:02 +01:00
Stephan
cfa76a1ae7 exp 2022-03-18 16:30:06 +01:00
Stephan
716be074d3 exp 2022-03-18 16:22:46 +01:00
Stephan
2249395b68 exp 2022-03-18 16:20:45 +01:00
Stephan
b7b967f078 exp 2022-03-18 16:11:14 +01:00
Stephan
df19db009c exp 2022-03-18 16:08:28 +01:00
Stephan
b789a373ac exp 2022-03-18 16:06:27 +01:00
Stephan
80ea5c8f2c exp 2022-03-18 16:02:03 +01:00
Stephan
aee24c13f3 exp 2022-03-18 16:00:10 +01:00
Stephan
d77c4fdfd4 exp 2022-03-18 15:58:28 +01:00
Stephan
21b99568fe exp 2022-03-18 15:53:55 +01:00
Stephan
0835da33bd exp 2022-03-18 15:53:27 +01:00
7 changed files with 169 additions and 20 deletions

View File

@ -1,14 +1,10 @@
// get the project
// check if the name matches a version x.y or x.y.z
// created
// check that there is a corresponding milestone
// else create that milestone
// and assign the issue to the milestone
// deleted
// get the issue
// if issue is not closed,
// remove issue from milestone, if any
// 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.

View File

@ -1,6 +1,7 @@
module.exports = async ({github, context, core}) => {
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) {
@ -10,6 +11,127 @@ module.exports = async ({github, context, core}) => {
}
return null
}
console.log("script")
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
}
}

View File

@ -1,14 +1,46 @@
name: Publish Release
on: workflow_dispatch
on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
dryrun:
description: 'DryRun'
required: true
type: boolean
default: true
jobs:
job:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/release/') # 19 leading chars
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure repository
shell: bash
run: |
git config user.email "github-actions@hazelcast.com"
git config user.name "GitHub Actions (Build Release)"
- name: Validate the release
uses: actions/github-script@v5
with:
script: |
const script = require('./.github/workflows/publish-release.js')
console.log(script)
const scriptf = require('./.github/workflows/publish-release.js')
const script = scriptf({github, context, core})
await script.validateRelease()
- name: Finalize GitHub release and milestone
if: ${{ github.event.inputs.dryrun == 'false' }}
uses: actions/github-script@v5
with:
script: |
const scriptf = require('./.github/workflows/publish-release.js')
const script = scriptf({github, context, core})
await script.publishRelease()
await script.closeMilestone()

View File

@ -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 an image in the README (markdown)
![Image](https://raw.github.com/zpqrtbnk/test-repo/master/wtf.jpg)
![Image](wtf.jpg)
We have an image in the README (html)
<img src="./wtf.jpg" />

1
bang
View File

@ -1 +0,0 @@
duh

0
test-1 Normal file
View File

0
test-2 Normal file
View File