1+ name : Release Containers resolver Go module new version
2+
3+ on :
4+ pull_request :
5+ types :
6+ - closed
7+ branches :
8+ - main
9+
10+ jobs :
11+ tag-and-release :
12+ if : github.event.pull_request.merged == true
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Checkout the repository
16+ uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
17+
18+ - name : Get and Format the PR Title
19+ id : get_pr_title
20+ run : |
21+ pr_title="${{ github.event.pull_request.title }}"
22+ # Use grep with regex to extract the format (AST-000) from the title
23+ formatted_title=$(echo "$pr_title" | grep -oE "\(AST-[0-9]+\)")
24+ # If formatted_title is empty, set a default value or handle the error
25+ if [ -z "$formatted_title" ]; then
26+ echo "No valid format found in PR title."
27+ exit 1
28+ fi
29+ echo "formatted_title=$formatted_title" >> $GITHUB_ENV
30+
31+ - name : Fetch All Tags
32+ run : git fetch --tags
33+
34+ - name : Get Latest Tag
35+ id : get_tag
36+ run : |
37+ latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
38+ echo "tag=${latest_tag}" >> $GITHUB_ENV
39+
40+ - name : Bump Patch Version
41+ id : bump
42+ 43+ with :
44+ current-version : ${{ env.tag }}
45+ bump-level : patch
46+
47+ - name : Create a new tag
48+ run : |
49+ new_tag=${{ steps.bump.outputs.new_version }}
50+ git tag $new_tag -m "${{ env.formatted_title }}"
51+ git push origin $new_tag
52+
53+ - name : Create release from tag
54+ uses : actions/create-release@v1
55+ with :
56+ tag_name : ${{ steps.bump.outputs.new_version }}
57+ release_name : Release ${{ steps.bump.outputs.new_version }}
58+ body : ${{ steps.get_pr_title.outputs.pr_title }}
59+ draft : false
60+ prerelease : false
0 commit comments