Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd62ea5560 |
40
.github/workflows/hz.js
vendored
40
.github/workflows/hz.js
vendored
@@ -1,40 +0,0 @@
|
|||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
20
.github/workflows/manual-thingy.yml
vendored
Normal file
20
.github/workflows/manual-thingy.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: Manually Do Something
|
||||||
|
on: workflow_dispatch
|
||||||
|
jobs:
|
||||||
|
job:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: startsWith(github.ref, 'refs/heads/release/')
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Do Something
|
||||||
|
run: |
|
||||||
|
version="${{ github.ref }}"
|
||||||
|
version="${version:19}" # trim starting 'refs/heads/release/' (19 chars)
|
||||||
|
echo "Tag ref ${{ github.ref }} as v$version"
|
||||||
|
git tag v$version
|
||||||
|
git config user.email "github-actions@zpqrtbnk.net"
|
||||||
|
git config user.name "GitHub Actions (Do Something)"
|
||||||
|
git push --tags
|
||||||
101
.github/workflows/publish-release.yml
vendored
101
.github/workflows/publish-release.yml
vendored
@@ -1,101 +0,0 @@
|
|||||||
name: Publish
|
|
||||||
|
|
||||||
#meh
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
confirm:
|
|
||||||
description: "This is really going to release. Enter \'yolo\' to confirm that you really want to do it."
|
|
||||||
required: true
|
|
||||||
default: ""
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
job:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: startsWith(github.ref, 'refs/heads/release/')
|
|
||||||
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
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
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
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
git config user.email "github-actions@hazelcast.com"
|
|
||||||
git config user.name "GitHub Actions (Build Release)"
|
|
||||||
|
|
||||||
- name: Finalize the release
|
|
||||||
run: |
|
|
||||||
ref="${{ github.ref }}"
|
|
||||||
branch="${ref:11}" # trim starting 'refs/heads/' (11 chars)
|
|
||||||
version="${ref:19}" # trim starting 'refs/heads/release/' (19 chars)
|
|
||||||
echo "Tag branch $branch as v$version"
|
|
||||||
git tag v$version
|
|
||||||
git push --tags
|
|
||||||
#git push :$branch
|
|
||||||
|
|
||||||
- name: Publish the release
|
|
||||||
uses: actions/github-script@v4
|
|
||||||
with:
|
|
||||||
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)
|
|
||||||
await github.repos.updateRelease({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
release_id: rel.id,
|
|
||||||
draft: false
|
|
||||||
})
|
|
||||||
Reference in New Issue
Block a user