Skip to content

Commit

Permalink
auto create release on PR closure to deployment branch (#146)
Browse files Browse the repository at this point in the history
One should add `Version: vX.Y.Z` to the title of the PR for creating a tag.
  • Loading branch information
devilsaint99 authored Jun 10, 2024
1 parent eac4565 commit db27c86
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Create Release

on:
pull_request:
types: [closed]


jobs:
create-release-tags:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'deployment'
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Extract version tag
id: extract_version
run: |
output=$(python extract_tags.py "${{ github.event.pull_request.title }}")
echo "::set-output name=tag::$output"
- name: Create release
id: create_release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.extract_version.outputs.tag }}
name: Release v${{ steps.extract_version.outputs.tag }}
bodyFile: ./release.md
- name: Set outputs
run: echo "release_id=${{ steps.create_release.outputs.id }}" >> $GITHUB_ENV
15 changes: 15 additions & 0 deletions extract_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys
import re

def extract_version_from_title(title):
match = re.search(r'(?<=Version: v)\d+\.\d+\.\d+', title)
if match:
return match.group()
else:
return None

if __name__ == "__main__":
title = sys.argv[1]
version_tag = extract_version_from_title(title)
if version_tag:
print(version_tag)
1 change: 1 addition & 0 deletions release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Release description

0 comments on commit db27c86

Please sign in to comment.