Mirrowel commited on
Commit
9fc445f
·
1 Parent(s): f76ad1b

ci: Update versioning logic to include daily build count for releases

Browse files
Files changed (1) hide show
  1. .github/workflows/build.yml +13 -6
.github/workflows/build.yml CHANGED
@@ -72,14 +72,21 @@ jobs:
72
  - name: Generate Build Version
73
  id: version
74
  shell: bash
 
 
75
  run: |
76
  BRANCH_NAME=${{ github.ref_name }}
77
- BASE_VERSION=$(date +'%Y.%m.%d')-${{ needs.build.outputs.sha }}
78
- if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
79
- VERSION="$BASE_VERSION-${{ github.run_attempt }}"
80
- else
81
- VERSION="$BASE_VERSION"
82
- fi
 
 
 
 
 
83
 
84
  # Define all naming components
85
  echo "release_title=Build ($BRANCH_NAME): $VERSION" >> $GITHUB_OUTPUT
 
72
  - name: Generate Build Version
73
  id: version
74
  shell: bash
75
+ env:
76
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77
  run: |
78
  BRANCH_NAME=${{ github.ref_name }}
79
+ DATE_STAMP=$(date +'%Y.%m.%d')
80
+
81
+ # Find the number of releases already created today for this branch
82
+ # We list releases and filter for tags matching "branch/build-YYYY.MM.DD"
83
+ BUILD_COUNT=$(gh release list --repo "${{ github.repository }}" --limit 100 | grep "^$BRANCH_NAME/build-$DATE_STAMP" | wc -l)
84
+
85
+ # Increment the build number for the new release
86
+ BUILD_NUMBER=$((BUILD_COUNT + 1))
87
+
88
+ # Create the new, sortable version string
89
+ VERSION="$DATE_STAMP.$BUILD_NUMBER-${{ needs.build.outputs.sha }}"
90
 
91
  # Define all naming components
92
  echo "release_title=Build ($BRANCH_NAME): $VERSION" >> $GITHUB_OUTPUT