Debian Codegraph @

.github/workflows/release-draft.yml

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