Skip to content

Commit 4e5af96

Browse files
Merge pull request #54 from rpancham/releasetag
Create Workflow for release and tag with Changelog
2 parents 1915159 + a43c5a9 commit 4e5af96

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Create Tag and Release changelog
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_name:
7+
description: "Tag name for the new release"
8+
required: true
9+
10+
permissions:
11+
contents: write
12+
packages: write
13+
pull-requests: write
14+
15+
jobs:
16+
fetch-tag:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
old_tag: ${{ steps.get_tag.outputs.old_tag_name }}
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
ref: ${{ github.ref }}
25+
fetch-depth: 0
26+
27+
- name: Get latest tag
28+
id: get_tag
29+
run: |
30+
echo "old_tag_name=$(git ls-remote --tags origin | awk -F'/' '{print $3}' | grep -v '{}' | sort -V | tail -n1)" >> $GITHUB_OUTPUT
31+
32+
- name: print tag
33+
id: print_tag
34+
run: |
35+
echo "Old Tag=${{ steps.get_tag.outputs.old_tag_name }}"
36+
echo "NEW_TAG=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
37+
echo "$(basename ${{ github.ref }})"
38+
39+
- name: Check if tag exists
40+
id: check_tag
41+
run: |
42+
import sys
43+
import subprocess
44+
tag_name = "${{ github.event.inputs.tag_name }}"
45+
command = ['git', 'tag', '-l', tag_name]
46+
output = subprocess.check_output(command, stderr=subprocess.STDOUT)
47+
if output.decode() != "":
48+
print(f"Error: Tag '{tag_name}' already exists.", file=sys.stderr)
49+
sys.exit(1)
50+
else:
51+
print(f"Tag '{tag_name}' does not exists.")
52+
shell: python
53+
continue-on-error: false
54+
55+
- name: Create Tag
56+
id: create_tag
57+
run: |
58+
git config --global user.email "[email protected]"
59+
git config --global user.name "GitHub Actions"
60+
git tag -a ${{ github.event.inputs.tag_name }} -m "Prepare for ODH release ${{ github.event.inputs.tag_name }}"
61+
git push origin ${{ github.event.inputs.tag_name }}
62+
63+
changelog:
64+
name: Changelog
65+
needs: fetch-tag
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@v4
70+
with:
71+
ref: ${{ github.ref }}
72+
73+
- name: Create Release
74+
uses: softprops/action-gh-release@v2
75+
with:
76+
token: ${{ github.token }}
77+
tag_name: ${{ github.event.inputs.tag_name }}
78+
prerelease: false
79+
draft: false
80+
files: bin/*
81+
generate_release_notes: true
82+
name: ${{ github.event.inputs.tag_name }}

0 commit comments

Comments
 (0)