build: New workflow to automatically create releases from PRs on main

This commit is contained in:
Karim shoair
2025-03-15 02:37:50 +02:00
parent e05ff06b92
commit 55802bac97
+49
View File
@@ -0,0 +1,49 @@
name: Create Release
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 information
id: pr_data
run: |
echo "title=${{ github.event.pull_request.title }}" >> $GITHUB_OUTPUT
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "${{ github.event.pull_request.body }}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Extract version
id: extract_version
run: |
PR_TITLE="${{ steps.pr_data.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 must start with 'v' to make a new 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: ${{ steps.pr_data.outputs.body }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}