Skip to content

Commit 845ee85

Browse files
committed
fix: Auto-increment version numbers for Motia Cloud deployments
1 parent 388003c commit 845ee85

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ on:
77
workflow_dispatch:
88
inputs:
99
versionName:
10-
description: 'Version Name to deploy'
11-
required: true
10+
description: 'Version Name to deploy (e.g., v1.2.0)'
11+
required: false
1212
versionDescription:
1313
description: 'Version Description to deploy'
14-
required: true
14+
required: false
1515

1616
env:
1717
# API Key stored as GitHub Secret (NEVER commit API keys to code)
1818
MOTIA_API_KEY: ${{ secrets.MOTIA_API_KEY }}
19-
# Environment ID from Motia Cloud dashboard
19+
# Environment ID from Motia Cloud dashboard (Settings tab)
2020
MOTIA_ENV_ID: ${{ secrets.MOTIA_ENV_ID }}
2121

2222
jobs:
@@ -28,18 +28,28 @@ jobs:
2828
- name: Checkout code
2929
uses: actions/checkout@v4
3030
with:
31-
ref: ${{ github.event.release.tag_name || github.ref }}
31+
fetch-depth: 0 # Fetch all history for commit count
3232

33-
- name: Set VERSION_NAME and DESCRIPTION
34-
id: meta
33+
- name: Generate Version Number
34+
id: version
3535
run: |
36-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
36+
# Get commit count for incremental versioning
37+
COMMIT_COUNT=$(git rev-list --count HEAD)
38+
# Calculate version: major.minor.patch based on commit count
39+
MAJOR=1
40+
MINOR=$((COMMIT_COUNT / 100))
41+
PATCH=$((COMMIT_COUNT % 100))
42+
AUTO_VERSION="v${MAJOR}.${MINOR}.${PATCH}"
43+
44+
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.versionName }}" ]; then
3745
echo "VERSION_NAME=${{ github.event.inputs.versionName }}" >> $GITHUB_ENV
38-
echo "VERSION_DESCRIPTION=${{ github.event.inputs.versionDescription }}" >> $GITHUB_ENV
46+
echo "VERSION_DESCRIPTION=${{ github.event.inputs.versionDescription || github.event.head_commit.message }}" >> $GITHUB_ENV
3947
else
40-
echo "VERSION_NAME=${GITHUB_SHA::7}" >> $GITHUB_ENV
48+
echo "VERSION_NAME=${AUTO_VERSION}" >> $GITHUB_ENV
4149
echo "VERSION_DESCRIPTION=${{ github.event.head_commit.message }}" >> $GITHUB_ENV
4250
fi
51+
52+
echo "Generated version: ${AUTO_VERSION}"
4353
4454
- name: Setup Node.js
4555
uses: actions/setup-node@v4

0 commit comments

Comments
 (0)