5858 default : true
5959
6060jobs :
61- Validate :
61+ validate-new-version :
62+ if : inputs.new-version
6263 runs-on : ubuntu-latest
6364 permissions :
6465 contents : read
@@ -67,22 +68,24 @@ jobs:
6768 uses : actions/checkout@v3
6869 with :
6970 fetch-depth : 0
71+ - name : Install Node.js
72+ uses : actions/setup-node@v4
73+ with :
74+ node-version : 20
7075 - name : Validate new version
71- if : inputs.new-version
7276 run : |
7377 CURRENT_VERSION=$(node -p "require('./package.json').version")
7478 NEW_VERSION="${{ inputs.new-version }}"
7579
7680 echo "Current version : $CURRENT_VERSION"
7781 echo "New version : $NEW_VERSION"
7882
79- npx semver -r ">=$CURRENT_VERSION" "$NEW_VERSION" > /dev/null
83+ npx semver -r ">=$CURRENT_VERSION" "$NEW_VERSION" > /dev/null || (echo "❌ New version must be greater than or equal to current version ($CURRENT_VERSION)" && exit 1)
8084
81- if [ $? -ne 0 ]; then
82- echo "❌ New version must be greater than or equal to current version ($CURRENT_VERSION)"
83- exit 1
84- fi
85- Build :
85+ echo "✅ New version is valid"
86+
87+ build :
88+ needs : validate-new-version
8689 runs-on : ${{ matrix.os }}
8790 permissions :
8891 contents : write
@@ -129,9 +132,21 @@ jobs:
129132 - name : Update version in package.json
130133 if : inputs.new-version
131134 run : |
135+ CURRENT_VERSION=$(node -p "require('./package.json').version")
136+ if [ "$CURRENT_VERSION" == "${{inputs.new-version}}" ]; then
137+ echo "Current version is already ${{ inputs.new-version }}, no need to update"
138+ exit 0
139+ fi
140+
132141 git config --global user.name "github-actions[bot]"
133142 git config --global user.email "github-actions[bot]@users.noreply.github.com"
134143 pnpm version ${{ inputs.new-version }} -m "chore: set app version to ${{ inputs.new-version }}"
144+
145+ - name : Setup latest version of Xcode
146+ uses : maxim-lobanov/setup-xcode@v1
147+ if : matrix.platform == 'ios'
148+ with :
149+ xcode-version : latest
135150
136151 # - name: ⚙️ Run Prebuild
137152 # run: pnpm prebuild:${{ inputs.environment }}
@@ -142,7 +157,6 @@ jobs:
142157 - name : 📦 Push changes to repository
143158 if : inputs.new-version
144159 run : |
145- # Return 0 if push fails and echo an error message
146160 git push || echo "Skipping push: version was already updated."
147161
148162 - name : Upload ${{ matrix.platform }} Build
0 commit comments