Compare commits

..

44 Commits

Author SHA1 Message Date
1946eeb4dd
Removed test-repo-reduced from submodules
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
2022-07-28 23:37:19 +02:00
08b11b83d0
Removed test-repo-reduced
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
2022-07-28 23:36:54 +02:00
cc58d51434
Checkout different commit test-repo-base
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
2022-07-28 23:27:32 +02:00
22cd3b3c1a
Added test-repo-base + test-repo-reduced
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
2022-07-28 23:23:58 +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 179 additions and 77 deletions

View File

@ -156,22 +156,11 @@
}
},
"node_modules/node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/once": {
@ -182,11 +171,6 @@
"wrappy": "1"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
@ -200,20 +184,6 @@
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
@ -356,12 +326,9 @@
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q=="
},
"node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"requires": {
"whatwg-url": "^5.0.0"
}
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"once": {
"version": "1.4.0",
@ -371,11 +338,6 @@
"wrappy": "1"
}
},
"tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
},
"tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
@ -386,20 +348,6 @@
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
},
"webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"requires": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

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()

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "test-repo-base"]
path = test-repo-base
url = https://git.sw3.cz/kamikaze/test-repo-base.git

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
test-repo-base Submodule

@ -0,0 +1 @@
Subproject commit 3de11d7640ed17f93ce38d31c9dea0fd65774077