Skip to content

Update create_version.yml #3

Update create_version.yml

Update create_version.yml #3

Workflow file for this run

name: Daily Versioning
on:
schedule:
- cron: '0 0 * * *' # Runs at midnight UTC every day
push:
branches:
- master # Make sure this matches your main development branch
jobs:
version-update:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Calculate new version
id: new-version
run: |
VERSION_PREFIX="3.0.0"
DATE=$(date +'%Y%m%d')
echo "NEW_VERSION=${VERSION_PREFIX}.${DATE}" >> $GITHUB_ENV
- name: Update version in project
run: |
# Update version in a properties file or specific project files
# Replace with your project's version file path and mechanism
echo "Version=${{ env.NEW_VERSION }}" > version.txt
- name: Update README with version number
run: |
sed -i "s/Current Version: .*/Current Version: ${{ env.NEW_VERSION }}/" README.md
git add README.md
git commit -m "Update README with new version ${{ env.NEW_VERSION }}"
git push
- name: Commit and push if there are changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Update version to ${{ env.NEW_VERSION }}" || exit 0 # Exit gracefully if no changes
git push
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.NEW_VERSION }}
release_name: Release ${{ env.NEW_VERSION }}
draft: false
prerelease: false
body: "Description of changes for version ${{ env.NEW_VERSION }}"