|
61 | 61 | # --title="${GITHUB_REPOSITORY#*/} ${tag#v}" \ |
62 | 62 | # --generate-notes |
63 | 63 |
|
64 | | -name: Auto Tag and Create Release notes |
| 64 | +name: Release on Tag |
65 | 65 |
|
66 | 66 | on: |
67 | 67 | push: |
68 | | - branches: |
69 | | - - main |
| 68 | + tags: |
| 69 | + - 'v*' # Trigger only on version tags like v1.0.0 |
70 | 70 |
|
71 | 71 | permissions: |
72 | | - contents: write |
| 72 | + contents: write # Required to create a release |
73 | 73 |
|
74 | 74 | jobs: |
75 | | - tag-and-release: |
| 75 | + release: |
76 | 76 | runs-on: ubuntu-latest |
77 | 77 | steps: |
78 | 78 | - name: Checkout code |
79 | 79 | uses: actions/checkout@v3 |
80 | 80 |
|
81 | | - - name: Fetch all tags |
82 | | - run: git fetch --tags |
83 | | - |
84 | | - - name: Get latest tag |
85 | | - id: get_tag |
86 | | - run: | |
87 | | - latest=$(git tag --sort=-v:refname | head -n 1) |
88 | | - echo "Latest tag: $latest" |
89 | | - if [ -z "$latest" ]; then |
90 | | - echo "tag=v0.0.0" >> $GITHUB_OUTPUT |
91 | | - else |
92 | | - echo "tag=$latest" >> $GITHUB_OUTPUT |
93 | | - fi |
94 | | -
|
95 | | - - name: Bump patch version |
96 | | - id: bump |
97 | | - run: | |
98 | | - version=${{ steps.get_tag.outputs.tag }} |
99 | | - echo "Current version: $version" |
100 | | - parts=(${version//./ }) |
101 | | - major="${parts[0]#v}" |
102 | | - minor="${parts[1]}" |
103 | | - patch="${parts[2]}" |
104 | | - next_patch=$((patch + 1)) |
105 | | - new_tag="v$major.$minor.$next_patch" |
106 | | - echo "New tag: $new_tag" |
107 | | - echo "new_tag=$new_tag" >> $GITHUB_OUTPUT |
108 | | -
|
109 | | - - name: Create new tag |
110 | | - run: | |
111 | | - git config user.name "github-actions[bot]" |
112 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
113 | | - git tag ${{ steps.bump.outputs.new_tag }} |
114 | | - git push origin ${{ steps.bump.outputs.new_tag }} |
115 | | -
|
116 | | - - name: Create GitHub Release with Notes |
| 81 | + - name: Create GitHub Release |
117 | 82 | uses: softprops/action-gh-release@v1 |
118 | 83 | with: |
119 | | - tag_name: ${{ steps.bump.outputs.new_tag }} |
120 | 84 | generate_release_notes: true |
0 commit comments