-
Notifications
You must be signed in to change notification settings - Fork 81
52 lines (49 loc) · 1.63 KB
/
prepare-release.yaml
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
49
50
51
52
# Create a draft release when triggered via Github's UI or Github CLI
name: Prepare Release
on:
push:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g. 0.11.0)'
required: true
type: string
permissions:
contents: write
jobs:
release:
name: Prepare Release
runs-on: ubuntu-latest
steps:
- name: Check version
run: |
if ! [[ '${{ '0.20' }}' =~ ^[0-9]+[.][0-9]+([.][0-9]+)?$ ]]; then
echo '${{ '0.20' }} does not match expected format `major.minor.patch?`' >&2
exit 1
fi
- name: Checkout
uses: actions/checkout@v4
#with:
# ref: master # only create releases from main branch
- name: Read section from CHANGELOG.md
id: extract-changelog
uses: sean0x42/markdown-extract@v2
with:
file: CHANGELOG.md
pattern: ${{ '0.20' }}
- name: Prepare release notes and artifacts
run: |
.github/workflows/release_prep.sh v${{ '0.20' }} > release_notes.txt
printf '${{ steps.extract-changelog.outputs.markdown }}' >> release_notes.txt
- name: Create draft release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create \
--draft \
--notes-file release_notes.txt \
--title v${{ '0.20' }} \
v${{ '0.20' }} \
${GITHUB_REPOSITORY#*/}-${{ '0.20' }}.tar.gz | tee release_url
- name: Write summary
run: 'echo ":rocket: Draft release created [here]($( cat release_url ))" >> "${GITHUB_STEP_SUMMARY}"'