This commit is contained in:
Stephan 2021-12-10 19:45:07 +01:00
parent 06622d8529
commit fa26cc9ba1

View File

@ -6,11 +6,12 @@ jobs:
if: startsWith(github.ref, 'refs/heads/release/') if: startsWith(github.ref, 'refs/heads/release/')
steps: steps:
# this *does* show the v7.7.10 release in the list
- name: Somebody Kill Me - name: Somebody Kill Me
run: | run: |
# this *does* show the v7.7.10 release in the list
echo "ALL RELEASES" echo "ALL RELEASES"
curl -H "Accept: application/vnd.github.v3+json" -u "zpqrtbnk:${{secrets.MY_GITHUB_TOKEN_TESTREPO}}" https://api.github.com/repos/zpqrtbnk/test-repo/releases curl -H "Accept: application/vnd.github.v3+json" -u "zpqrtbnk:${{secrets.MY_GITHUB_TOKEN_TESTREPO}}" https://api.github.com/repos/zpqrtbnk/test-repo/releases
# this ... fails
echo "TAG RELEASE" echo "TAG RELEASE"
curl -H "Accept: application/vnd.github.v3+json" -u "zpqrtbnk:${{secrets.MY_GITHUB_TOKEN_TESTREPO}}" https://api.github.com/repos/zpqrtbnk/test-repo/releases/tags/v7.7.10 curl -H "Accept: application/vnd.github.v3+json" -u "zpqrtbnk:${{secrets.MY_GITHUB_TOKEN_TESTREPO}}" https://api.github.com/repos/zpqrtbnk/test-repo/releases/tags/v7.7.10
@ -18,30 +19,40 @@ jobs:
uses: actions/github-script@v4 uses: actions/github-script@v4
with: with:
# fuck! not seeing the draft release # needed to see draft releases when getting all releases?
# curl -i -u zpqrtbnk https://api.github.com/users/zpqrtbnk
# with my test-repo-curl token
# raises the x-ratelimit-limit to 5000/hr ok
# and, I can see the draft release
# so, I need a special token?
#github-token: ${{ secrets.GITHUB_TOKEN }} # needed to see draft releases
github-token: ${{ secrets.MY_GITHUB_TOKEN_TESTREPO }} 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 var rel
var rels
try { try {
rel = await github.repos.getReleaseByTag({ rels = await github.repos.listReleases({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo
tag: tag
}) })
//rel = await github.repos.getReleaseByTag({
// owner: context.repo.owner,
// repo: context.repo.repo,
// tag: tag
//})
} }
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
} }
rel = null
for (var r in rels) {
console.log(r)
if (r.tagName === tag) {
rel = r
break
}
}
if (rel === null) {
core.setFailed(`Could not find a release for tag ${tag}.`)
return
}
if (!rel.draft) { if (!rel.draft) {
core.setFailed(`Release for tag ${tag} is already published.`) core.setFailed(`Release for tag ${tag} is already published.`)
return return