2
0

Compare commits

..

1 Commits

Author SHA1 Message Date
Stephan
43287ec9cf exp 2021-12-10 18:56:12 +01:00
3 changed files with 13 additions and 39 deletions

View File

@@ -5,41 +5,25 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/release/') if: startsWith(github.ref, 'refs/heads/release/')
steps: steps:
- name: Validate the release - name: Validate the release
uses: actions/github-script@v4 uses: actions/github-script@v4
with: with:
# token needed to see draft releases when getting all releases
github-token: ${{ secrets.MY_GITHUB_TOKEN_TESTREPO }}
script: | script: |
const ver = "${{ github.ref }}".substring(19) const ver = "${{ github.ref }}".substring(19)
const tag = "v" + ver const tag = "v" + ver
var rel = null
try { try {
// this does *not* return draft releases, so we have to list them const rel = await github.repos.getReleaseByTag({
//rel = await github.repos.getReleaseByTag({ ... })
const rels = await github.repos.listReleases({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo repo: context.repo.repo,
tag: tag
}) })
for (const r of rels.data) {
if (r.tag_name === tag) {
rel = r
break
}
}
} }
catch (error) { catch (error) {
core.setFailed(`Could not find a release for tag ${tag}.`) core.setFailed(`Could not find a release for tag '${tag}'.`)
return return
} }
if (rel === null) { if (rel.draft) {
core.setFailed(`Could not find a release for tag ${tag}.`) core.setFailed(`Release for tag '${tag}' is already published.`)
return
}
if (!rel.draft) {
core.setFailed(`Release for tag ${tag} is already published.`)
return return
} }
try { try {
@@ -48,14 +32,14 @@ jobs:
repo: context.repo.repo, repo: context.repo.repo,
ref: 'tags/' + tag ref: 'tags/' + tag
}) })
core.setFailed(`Tag ${tag} already exists.`) core.setFailed(`Tag '${tag}' already exists.`)
return return
} }
catch (error) { catch (error) {
// this is expected // this is expected
} }
// everything is OK // everything is OK
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@@ -83,19 +67,11 @@ jobs:
script: | script: |
const ver = "${{ github.ref }}".substring(19) const ver = "${{ github.ref }}".substring(19)
const tag = "v" + ver const tag = "v" + ver
var rel = null const rel = await github.repos.getReleaseByTag({
// no, see above owner: context.repo.owner,
//const rel = await github.repos.getReleaseByTag({ ... }) repo: context.repo.repo,
const rels = await github.repos.listReleases({ tag: tag
owner: context.repo.owner, })
repo: context.repo.repo
})
for (const r of rels.data) {
if (r.tag_name === tag) {
rel = r
break
}
}
await github.repos.updateRelease({ await github.repos.updateRelease({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,

View File

@@ -1,2 +1 @@
foo foo
foo

View File

@@ -1 +0,0 @@
pii