From 55802bac974da7528a29c62f805f8050e2bd9d31 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Sat, 15 Mar 2025 02:37:50 +0200 Subject: [PATCH] build: New workflow to automatically create releases from PRs on main --- .github/workflows/auto-release.yml | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/auto-release.yml diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 0000000..c6a6699 --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -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<> $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 }} \ No newline at end of file