Skip to content

Fix GitHub actions 3 (#87) #90

Fix GitHub actions 3 (#87)

Fix GitHub actions 3 (#87) #90

Workflow file for this run

name: Draft Release
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: release
cancel-in-progress: false
jobs:
draft-release:
name: Draft Github Release
runs-on: ubuntu-20.04
steps:
- name: Draft github release
uses: actions/github-script@v6
with:
script: |
const releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
})
const filtered = releases.data.filter(release => release.draft == true && release.tag_name === 'unreleased');
if (filtered.length === 0) {
console.log("Creating a new untagged release")
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
name: "Unreleased",
draft: true,
generate_release_notes: true,
})
} else {
console.log("Deleting old untagged release")
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: filtered[0].id
});
try {
console.log("Deleting old 'unreleased' tag");
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/unreleased'
});
console.log("Deleted old 'unreleased' tag");
} catch (error) {
console.log("Tag 'unreleased' does not exist or could not be deleted");
}
console.log("Creating a new untagged release")
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
name: "Unreleased",
draft: true,
generate_release_notes: true,
})
}