Skip to content

Commit

Permalink
automate release as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean DeLongchamp committed Dec 9, 2024
1 parent ef100c2 commit 8b97256
Showing 1 changed file with 43 additions and 26 deletions.
69 changes: 43 additions & 26 deletions .github/workflows/auto-versioning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,50 @@ on:
# - main # Replace with your default branch if different

jobs:
assign-version:
auto-version:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v3

- name: Determine Version Tag
id: versioning
run: |
DATE=$(date -u +"%Y.%m.%d")
BASE_TAG="$DATE"
EXISTING_TAGS=$(git tag -l "${BASE_TAG}.*" | sort -V)
if [ -z "$EXISTING_TAGS" ]; then
NEW_TAG="${BASE_TAG}.01"
else
LAST_TAG=$(echo "$EXISTING_TAGS" | tail -n 1)
LAST_INCREMENT=$(echo $LAST_TAG | awk -F. '{print $NF}')
NEW_INCREMENT=$(printf "%02d" $((10#$LAST_INCREMENT + 1)))
NEW_TAG="${BASE_TAG}.${NEW_INCREMENT}"
fi
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
echo "Generated version tag: $NEW_TAG"
- name: Determine Version Tag
id: versioning
run: |
DATE=$(date -u +"%Y.%m.%d")
BASE_TAG="$DATE"
EXISTING_TAGS=$(git tag -l "${BASE_TAG}.*" | sort -V)
if [ -z "$EXISTING_TAGS" ]; then
NEW_TAG="${BASE_TAG}.01"
else
LAST_TAG=$(echo "$EXISTING_TAGS" | tail -n 1)
LAST_INCREMENT=$(echo $LAST_TAG | awk -F. '{print $NF}')
NEW_INCREMENT=$(printf "%02d" $((10#$LAST_INCREMENT + 1)))
NEW_TAG="${BASE_TAG}.${NEW_INCREMENT}"
fi
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
- name: Create and Push Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag $NEW_TAG
git push origin $NEW_TAG
- name: Create and Push Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag $NEW_TAG
git push origin $NEW_TAG
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.NEW_TAG }}
release_name: "Release ${{ env.NEW_TAG }}"
body: |
## Release Notes
- Automatically generated release for version ${{ env.NEW_TAG }}.
- Commit: ${{ github.sha }}
- Created by GitHub Actions workflow.
draft: false
prerelease: false

0 comments on commit 8b97256

Please sign in to comment.