Increments Flipcash versioning on the 1st of the month #9
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: Increments Flipcash versioning on the 1st of the month | |
on: | |
schedule: | |
- cron: '0 0 1 * *' | |
workflow_dispatch: | |
jobs: | |
sync-branch: | |
name: Update development branch | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@master | |
with: | |
ref: code/cash | |
- uses: connor-baer/action-sync-branch@main | |
with: | |
branch: code/cash | |
token: ${{ secrets.GITHUB_TOKEN }} | |
force: false | |
- name: Generate year and month | |
id: date | |
run: | | |
YEAR=$(date +"%Y") | |
MONTH=$(date +"%m") | |
echo "YEAR=$YEAR" >> $GITHUB_OUTPUT | |
echo "MONTH=$MONTH" >> $GITHUB_OUTPUT | |
- name: Verify Packaging.kt exists | |
run: | | |
if [ ! -f buildSrc/src/main/java/Packaging.kt ]; then | |
echo "Error: Packaging.kt not found" | |
exit 1 | |
fi | |
- name: Update majorVersion and minorVersion in Flipcash object | |
run: | | |
# Update majorVersion within Flipcash object | |
sed -i '/object Flipcash : Packaging(/,/)/ s/majorVersion = [0-9]\{4\}/majorVersion = ${{ steps.date.outputs.YEAR }}/' buildSrc/src/main/java/Packaging.kt | |
# Update minorVersion within Flipcash object | |
sed -i '/object Flipcash : Packaging(/,/)/ s/minorVersion = [0-9]\{1,2\}/minorVersion = ${{ steps.date.outputs.MONTH }}/' buildSrc/src/main/java/Packaging.kt | |
- name: Validate updated fields | |
run: | | |
if ! grep -A 10 'object Flipcash : Packaging(' buildSrc/src/main/java/Packaging.kt | grep -q "majorVersion = ${{ steps.date.outputs.YEAR }}"; then | |
echo "Error: Failed to update majorVersion to ${{ steps.date.outputs.YEAR }}" | |
exit 1 | |
fi | |
if ! grep -A 10 'object Flipcash : Packaging(' buildSrc/src/main/java/Packaging.kt | grep -q "minorVersion = ${{ steps.date.outputs.MONTH }}"; then | |
echo "Error: Failed to update minorVersion to ${{ steps.date.outputs.MONTH }}" | |
exit 1 | |
fi | |
- name: Check for changes | |
id: check-changes | |
run: | | |
if git diff --quiet buildSrc/src/main/java/Packaging.kt; then | |
echo "No changes to commit" | |
echo "changed=false" >> $GITHUB_OUTPUT | |
else | |
echo "Changes detected" | |
echo "changed=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit & Push changes | |
if: steps.check-changes.outputs.changed == 'true' | |
uses: actions-js/push@master | |
with: | |
message: "build: update Flipcash versioning to ${{ steps.date.outputs.YEAR }}.${{ steps.date.outputs.MONTH }}" | |
branch: "code/cash" | |
github_token: ${{ secrets.BOT_GITHUB_TOKEN }} |