Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto create release on PR closure to deployment branch #146

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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