Feat/improve match creation ux #15
Workflow file for this run
This file contains 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: Bump versions of Mobile App | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- "mobile-app/**" | |
branches: | |
- staging | |
jobs: | |
bump-version: | |
name: Bump version of package.json and app.json | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PAT }} | |
fetch-depth: 2 | |
- name: Check recent commit messages | |
id: check_commits | |
shell: bash | |
run: | | |
# Fetch the PR base branch | |
git fetch origin ${{ github.base_ref }} | |
# Get the merge base between the PR head and base | |
MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }}) | |
# Check the commits between the merge base and HEAD | |
COMMIT_MESSAGES=$(git log $MERGE_BASE..HEAD --format='%s') | |
echo "Commit messages since merge base:" | |
echo "$COMMIT_MESSAGES" | |
if echo "$COMMIT_MESSAGES" | grep -q "chore: minor mobile app version bump"; then | |
echo "has_version_bump=true" >> $GITHUB_OUTPUT | |
echo "A recent commit contains the version bump message. Stopping the workflow." | |
exit 0 # This will stop the workflow without failing it | |
else | |
echo "has_version_bump=false" >> $GITHUB_OUTPUT | |
echo "No version bump commit found. Continuing the workflow." | |
fi | |
- name: Setup Node.js | |
if: steps.check_commits.outputs.has_version_bump != 'true' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Bump version | |
if: steps.check_commits.outputs.has_version_bump != 'true' | |
run: | | |
cd mobile-app | |
# Read current version from package.json | |
current_version=$(node -p "require('./package.json').version") | |
echo "Current version: $current_version" | |
# Increment patch version | |
new_version=$(node -e " | |
const [major, minor, patch] = '$current_version'.split('.'); | |
console.log(\`\${major}.\${minor}.\${parseInt(patch) + 1}\`); | |
") | |
echo "New version: $new_version" | |
# Update package.json | |
jq --arg version "$new_version" '.version = $version' package.json > package.json.tmp && mv package.json.tmp package.json | |
# Update app.json | |
jq --arg version "$new_version" '.expo.version = $version' app.json > app.json.tmp && mv app.json.tmp app.json | |
echo "Updated version in package.json and app.json to $new_version" | |
- run: npm ci && npm run format | |
if: steps.check_commits.outputs.has_version_bump != 'true' | |
working-directory: mobile-app | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
if: steps.check_commits.outputs.has_version_bump != 'true' | |
with: | |
commit_message: "chore: minor mobile app version bump" | |