✨ feat(environment): add type-safe environment variable API #817
Workflow file for this run
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: API Compatibility & Version Bump | |
| on: | |
| pull_request: | |
| types: [ opened, synchronize, reopened ] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| api-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout PR | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| fetch-depth: 0 # required to compare API changes | |
| persist-credentials: false | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'graalvm' | |
| java-version: '25' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v5 | |
| - name: Run Kotlin Binary Compatibility Check | |
| id: check_api | |
| run: | | |
| set +e | |
| ./gradlew checkKotlinAbi | |
| CHECK_EXIT=$? | |
| echo "check_exit=$CHECK_EXIT" >> $GITHUB_OUTPUT | |
| set -e | |
| - name: Detect API changes | |
| id: changes | |
| run: | | |
| if [ "${{ steps.check_api.outputs.check_exit }}" -eq 0 ]; then | |
| echo "api_changed=false" >> $GITHUB_OUTPUT | |
| echo "✅ No API changes detected." | |
| else | |
| echo "api_changed=true" >> $GITHUB_OUTPUT | |
| echo "❌ API changes detected! To update the reference, run './gradlew updateKotlinAbi' locally and commit the changes." >&2 | |
| fi | |
| - name: Comment on PR if API changed | |
| if: steps.changes.outputs.api_changed == 'true' | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: | | |
| ⚠️ **API/ABI changes detected!** | |
| This PR contains changes that modified the public API. To update the reference ABI dumps: | |
| ```bash | |
| ./gradlew updateKotlinAbi | |
| git add **/api/** | |
| git commit -m "Update ABI reference" | |
| git push | |
| ``` | |
| After updating, the CI will pass. Make sure the changes are backward compatible. | |
| - name: Detect manual version change | |
| id: ver | |
| run: | | |
| git fetch origin ${{ github.event.pull_request.base.ref }} | |
| if git diff origin/${{ github.event.pull_request.base.ref }} -- gradle.properties | grep -q '^+version='; then | |
| echo "manual=true" >>"$GITHUB_OUTPUT" | |
| else | |
| echo "manual=false" >>"$GITHUB_OUTPUT" | |
| fi | |
| - name: Bump version in gradle.properties | |
| if: steps.changes.outputs.api_changed == 'true' && steps.ver.outputs.manual == 'false' | |
| run: | | |
| version_file=gradle.properties | |
| current_version=$(grep -E '^version=' "$version_file" | cut -d= -f2) | |
| IFS='.-' read -r major minor patch lib_major lib_minor lib_patch <<<"$current_version" | |
| for value in "$major" "$minor" "$patch" "$lib_major" "$lib_minor" "$lib_patch"; do | |
| if ! [[ "$value" =~ ^[0-9]+$ ]]; then | |
| echo "Invalid numeric version component: $value" >&2 | |
| exit 1 | |
| fi | |
| done | |
| lib_minor=$((10#$lib_minor + 1)) | |
| lib_patch=0 | |
| new_version="$major.$minor.$patch-$lib_major.$lib_minor.$lib_patch" | |
| echo "Bumping version: $current_version → $new_version" | |
| sed -i "s/^version=.*/version=$new_version/" "$version_file" |