| 1 |
name: Release Draft |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 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." |