1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Release Draft
# Creates a draft GitHub release as soon as a ver.* tag is pushed, with the
# matching section of NEWS.md as the release notes. The other release
# workflows upload their assets to this draft (gh release upload resolves
# draft releases by tag name), so the release can be reviewed and published
# manually after all assets have landed. Publishing the release triggers
# release-npm. This workflow is the only place a release is created; asset
# upload steps in other workflows wait for it instead of creating their own,
# which would risk duplicate drafts for the same tag.
on:
push:
tags:
- "ver.*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
create-draft:
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- name: Create draft release if none exists
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="${{ github.ref_name }}"
if gh release view "$tag" --json isDraft > /dev/null 2>&1; then
echo "Release for $tag already exists; nothing to do."
exit 0
fi
version="${tag#ver.}"
awk -v header="## Version $version" '
$0 == header {flag=1; next}
/^## Version / {flag=0}
flag' NEWS.md | sed -e '/./,$!d' > notes.md
if ! [ -s notes.md ]; then
echo "OpenCC $version" > notes.md
fi
gh release create "$tag" --draft --verify-tag \
--title "$tag" --notes-file notes.md
echo "Created draft release for $tag."