Updated metadata to version metadata/9.0.17 (#873) #16
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: Release | |
| on: | |
| push: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| inputs: | |
| commit_hash: | |
| description: 'Commit hash to check for metadata changes' | |
| required: true | |
| type: string | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if metadata version changed | |
| id: check_metadata | |
| run: | | |
| # Determine which commit to check | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| commit_hash="${{ inputs.commit_hash }}" | |
| echo "Manual trigger: checking commit $commit_hash" | |
| compare_with="${commit_hash}^" | |
| compare_to="${commit_hash}" | |
| else | |
| echo "Push trigger: checking HEAD" | |
| compare_with="HEAD^" | |
| compare_to="HEAD" | |
| fi | |
| # Check if .metadata-version was modified | |
| if git diff $compare_with $compare_to --name-only | grep -q "PhoneNumberKit/Resources/.metadata-version"; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "No metadata version change detected, skipping release" | |
| fi | |
| - name: Extract and bump version | |
| if: steps.check_metadata.outputs.changed == 'true' | |
| id: bump_version | |
| run: | | |
| # Extract current version from podspec | |
| current_version=$(grep "s.version" PhoneNumberKit.podspec | sed -n "s/.*'\([0-9]*\.[0-9]*\.[0-9]*\)'.*/\1/p") | |
| echo "Current version: $current_version" | |
| # Validate version was extracted | |
| if [ -z "$current_version" ]; then | |
| echo "Error: Could not extract version from podspec" | |
| exit 1 | |
| fi | |
| # Parse version components | |
| major=$(echo $current_version | cut -d. -f1) | |
| minor=$(echo $current_version | cut -d. -f2) | |
| patch=$(echo $current_version | cut -d. -f3) | |
| # Bump patch version | |
| new_patch=$((patch + 1)) | |
| new_version="${major}.${minor}.${new_patch}" | |
| echo "New version: $new_version" | |
| # Save to output | |
| echo "version=$new_version" >> $GITHUB_OUTPUT | |
| - name: Update podspec | |
| if: steps.check_metadata.outputs.changed == 'true' | |
| run: | | |
| new_version="${{ steps.bump_version.outputs.version }}" | |
| # Update version in podspec | |
| sed -i "s/s.version.*=.*/s.version = '$new_version'/" PhoneNumberKit.podspec | |
| # Verify the change | |
| echo "Updated podspec:" | |
| grep "s.version" PhoneNumberKit.podspec | |
| - name: Commit and push | |
| if: steps.check_metadata.outputs.changed == 'true' | |
| run: | | |
| new_version="${{ steps.bump_version.outputs.version }}" | |
| # Configure git | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| # Commit and push | |
| git add PhoneNumberKit.podspec | |
| git commit -m "Release $new_version" | |
| git push origin master | |
| - name: Create and push tag | |
| if: steps.check_metadata.outputs.changed == 'true' | |
| run: | | |
| new_version="${{ steps.bump_version.outputs.version }}" | |
| # Create annotated tag | |
| git tag -a "$new_version" -m "Release $new_version" | |
| git push origin "$new_version" | |
| - name: Create GitHub release | |
| if: steps.check_metadata.outputs.changed == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| new_version="${{ steps.bump_version.outputs.version }}" | |
| # Create release with auto-generated notes | |
| gh release create "$new_version" \ | |
| --verify-tag \ | |
| --generate-notes |