| Marc Kupietz | 9de5155 | 2026-09-04 06:59:02 +0200 | [diff] [blame^] | 1 | name: Create Release |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | tags: |
| 6 | - 'v*.*.*' |
| 7 | - 'KorAP-Tokenizer-*' |
| 8 | |
| 9 | jobs: |
| 10 | release: |
| 11 | name: Create GitHub release from Changelog |
| 12 | runs-on: ubuntu-latest |
| 13 | permissions: |
| 14 | contents: write |
| 15 | steps: |
| 16 | - uses: actions/checkout@v5 |
| 17 | |
| 18 | - name: Determine version from tag |
| 19 | id: version |
| 20 | run: | |
| 21 | TAG="${GITHUB_REF_NAME}" |
| 22 | VERSION="${TAG#v}" |
| 23 | VERSION="${VERSION#KorAP-Tokenizer-}" |
| 24 | echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 25 | |
| 26 | - name: Extract release notes from CHANGELOG.md |
| 27 | id: changelog |
| 28 | run: | |
| 29 | VERSION="${{ steps.version.outputs.version }}" |
| 30 | ESCAPED_VERSION=$(printf '%s' "$VERSION" | sed 's/[.[\*^$()+?{|]/\\&/g') |
| 31 | awk -v ver="$ESCAPED_VERSION" ' |
| 32 | BEGIN { found = 0 } |
| 33 | /^## / { |
| 34 | if (found) exit |
| 35 | if ($0 ~ "^## " ver "([^0-9.]|$)") { found = 1 } |
| 36 | next |
| 37 | } |
| 38 | found { print } |
| 39 | ' CHANGELOG.md | sed -e '/./,$!d' -e ':a' -e '/^\n*$/{$d;N;ba' -e '}' > release_notes.md |
| 40 | |
| 41 | if [ ! -s release_notes.md ]; then |
| 42 | echo "::error::No CHANGELOG.md section found for version $VERSION (tag $GITHUB_REF_NAME)" |
| 43 | exit 1 |
| 44 | fi |
| 45 | |
| 46 | echo "Release notes for $VERSION:" |
| 47 | cat release_notes.md |
| 48 | |
| 49 | - name: Create GitHub release |
| 50 | uses: softprops/action-gh-release@v2 |
| 51 | with: |
| 52 | name: ${{ github.ref_name }} |
| 53 | body_path: release_notes.md |
| 54 | draft: false |
| 55 | prerelease: false |