tighten regexs and adjust search #145
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Releases | |
on: | |
push: | |
branches: | |
- main # Trigger on push to main or any other branch | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Get the current commit count | |
id: commit_count | |
run: | | |
git fetch --prune --unshallow | |
total_commits=$(git rev-list --count HEAD) | |
echo "Total commits: $total_commits" | |
echo "total_commits=$total_commits" >> $GITHUB_ENV | |
- name: Calculate version | |
id: calculate_version | |
run: | | |
major_version=1 # Start with major version 1 (manual increments needed) | |
# Calculate the minor version based on commit count | |
minor_version=$(( (total_commits / 10) % 10 )) # Every 10 commits, increment minor version | |
patch_version=$(( total_commits % 10 )) # Increment patch version for each commit | |
# If it's a major release (every 10 commits), reset patch version | |
if [ $((total_commits % 10)) -eq 0 ] && [ $total_commits -gt 0 ]; then | |
minor_version=$(( minor_version + 1 )) | |
patch_version=0 | |
fi | |
version="v${major_version}.${minor_version}.${patch_version}" | |
echo "Calculated version: $version" | |
echo "version=$version" >> $GITHUB_ENV | |
- name: Delete previous releases | |
id: delete_releases | |
run: | | |
echo "Deleting previous releases" | |
releases=$(gh release list --limit 100 --json tagName --jq '.[].tagName') | |
for release in $releases; do | |
gh release delete $release -y | |
done | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Delete previous tags | |
id: delete_tags | |
run: | | |
echo "Deleting previous tags" | |
tags=$(git tag) | |
for tag in $tags; do | |
git tag -d $tag | |
git push --delete origin $tag | |
done | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
id: create_release | |
run: | | |
echo "Creating release with version ${{ env.version }}" | |
# Create release using GitHub CLI or API | |
gh release create ${{ env.version }} --title "Release ${{ env.version }}" --notes "Automated release for commit ${{ env.total_commits }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |