5858 default : true
5959
6060jobs :
61- Validate :
61+ validate-new-version :
6262 runs-on : ubuntu-latest
6363 permissions :
6464 contents : read
6565 steps :
6666 - name : Checkout
67+ if : inputs.new-version
6768 uses : actions/checkout@v3
6869 with :
6970 fetch-depth : 0
71+ - name : Install Node.js
72+ if : inputs.new-version
73+ uses : actions/setup-node@v4
74+ with :
75+ node-version : 20
7076 - name : Validate new version
7177 if : inputs.new-version
7278 run : |
@@ -76,13 +82,12 @@ jobs:
7682 echo "Current version : $CURRENT_VERSION"
7783 echo "New version : $NEW_VERSION"
7884
79- npx semver -r ">=$CURRENT_VERSION" "$NEW_VERSION" > /dev/null
85+ 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)
8086
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 :
87+ echo "✅ New version is valid"
88+
89+ build :
90+ needs : validate-new-version
8691 runs-on : ${{ matrix.os }}
8792 permissions :
8893 contents : write
@@ -129,20 +134,31 @@ jobs:
129134 - name : Update version in package.json
130135 if : inputs.new-version
131136 run : |
137+ CURRENT_VERSION=$(node -p "require('./package.json').version")
138+ if [ "$CURRENT_VERSION" == "${{inputs.new-version}}" ]; then
139+ echo "Current version is already ${{ inputs.new-version }}, no need to update"
140+ exit 0
141+ fi
142+
132143 git config --global user.name "github-actions[bot]"
133144 git config --global user.email "github-actions[bot]@users.noreply.github.com"
134145 pnpm version ${{ inputs.new-version }} -m "chore: set app version to ${{ inputs.new-version }}"
146+
147+ - name : Setup latest version of Xcode
148+ uses : maxim-lobanov/setup-xcode@v1
149+ if : matrix.platform == 'ios'
150+ with :
151+ xcode-version : latest
135152
136- # - name: ⚙️ Run Prebuild
137- # run: pnpm prebuild:${{ inputs.environment }}
153+ - name : ⚙️ Run Prebuild
154+ run : pnpm prebuild:${{ inputs.environment }}
138155
139- # - name: 📱 Run Build for ${{ matrix.platform }}
140- # run: pnpm build:${{ inputs.environment }}:${{ matrix.platform }} --non-interactive --no-wait --message "Build ${{ inputs.environment }} for ${{ matrix.platform }}" --local
156+ - name : 📱 Run Build for ${{ matrix.platform }}
157+ run : pnpm build:${{ inputs.environment }}:${{ matrix.platform }} --non-interactive --no-wait --message "Build ${{ inputs.environment }} for ${{ matrix.platform }}" --local
141158
142159 - name : 📦 Push changes to repository
143160 if : inputs.new-version
144161 run : |
145- # Return 0 if push fails and echo an error message
146162 git push || echo "Skipping push: version was already updated."
147163
148164 - name : Upload ${{ matrix.platform }} Build
0 commit comments