Update code so now it can detect if there are certificates then it is… #55
This file contains hidden or 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: Auto CalVer Tag on Master Push | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| calver-tag: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set CalVer date | |
| id: calver | |
| run: | | |
| # Get current date in YYYY.MM.DD format | |
| date_tag=$(date +'%Y.%m.%d') | |
| echo "base_tag=$date_tag" >> $GITHUB_OUTPUT | |
| - name: Fetch all tags | |
| run: | | |
| git fetch --tags | |
| - name: Determine next CalVer tag | |
| id: next_tag | |
| run: | | |
| base=${{ steps.calver.outputs.base_tag }} | |
| # List all existing tags that match today's date | |
| existing=$(git tag --list "${base}*") | |
| if ! echo "$existing" | grep -q "^$base$"; then | |
| # No base tag exists yet, use the base tag (no suffix) | |
| new_tag="$base" | |
| else | |
| # Base tag exists, find the highest numbered suffix | |
| max=1 # because base tag is already used | |
| for tag in $existing; do | |
| suffix=$(echo $tag | sed -n "s/^$base\.//p") | |
| if [[ "$suffix" =~ ^[0-9]+$ && "$suffix" -gt "$max" ]]; then | |
| max=$suffix | |
| fi | |
| done | |
| new_tag="$base.$((max + 1))" | |
| fi | |
| echo "New tag: $new_tag" | |
| echo "new_tag=$new_tag" >> $GITHUB_OUTPUT | |
| - name: Create and push new tag | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git tag ${{ steps.next_tag.outputs.new_tag }} | |
| git push origin ${{ steps.next_tag.outputs.new_tag }} |