50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
name: Create Release
|
|
# Creates a GitHub release when a PR is merged to main, using the PR title as the version (must start with 'v') and PR body as release notes.
|
|
|
|
on:
|
|
pull_request:
|
|
types: [closed]
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
create-release:
|
|
if: github.event.pull_request.merged == true
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get PR title
|
|
id: pr_title
|
|
run: echo "title=${{ github.event.pull_request.title }}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Save PR body to file
|
|
run: |
|
|
echo '${{ github.event.pull_request.body }}' > pr_body.txt
|
|
|
|
- name: Extract version
|
|
id: extract_version
|
|
run: |
|
|
PR_TITLE="${{ steps.pr_title.outputs.title }}"
|
|
if [[ $PR_TITLE =~ ^v ]]; then
|
|
echo "version=$PR_TITLE" >> $GITHUB_OUTPUT
|
|
echo "Valid version format found in PR title: $PR_TITLE"
|
|
else
|
|
echo "Error: PR title '$PR_TITLE' must start with 'v' (e.g., 'v1.0.0') to create a release."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
tag_name: ${{ steps.extract_version.outputs.version }}
|
|
name: Release ${{ steps.extract_version.outputs.version }}
|
|
body_path: pr_body.txt
|
|
draft: false
|
|
prerelease: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |