- Update cmdline-tools from 11076708 to 14742923 (v20.0) - Update build-tools from 36.0.0 to 36.1.0 - Add Android SDK version checking to update-check workflow - Creates issues when Android SDK updates are available This reduces CVEs from 26 to 4 (all from protobuf-java 2.6.1 bundled by Google). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
145 lines
6.6 KiB
YAML
145 lines
6.6 KiB
YAML
name: Check for Flutter SDK and Android SDK Updates
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 8 * * *'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
check-update:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Get latest Flutter stable version
|
|
id: flutter
|
|
run: |
|
|
RESPONSE=$(curl -fsSL https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json)
|
|
LATEST=$(echo "$RESPONSE" | jq -r '.current_release.stable as $hash | .releases[] | select(.hash == $hash and .channel == "stable") | .version')
|
|
echo "version=${LATEST}" >> $GITHUB_OUTPUT
|
|
echo "Latest Flutter stable: ${LATEST}"
|
|
|
|
- name: Get latest Android SDK versions
|
|
id: android
|
|
run: |
|
|
REPO_XML=$(curl -fsSL "https://dl.google.com/android/repository/repository2-1.xml")
|
|
|
|
# Latest stable build-tools (exclude rc/alpha/beta)
|
|
BUILD_TOOLS=$(echo "$REPO_XML" | grep -o 'path="build-tools;[0-9]*\.[0-9]*\.[0-9]*"' | \
|
|
sed 's/path="build-tools;//;s/"//' | sort -V | tail -1)
|
|
|
|
# Latest stable platform
|
|
PLATFORM=$(echo "$REPO_XML" | grep -o 'path="platforms;android-[0-9]*"' | \
|
|
sed 's/path="platforms;android-//;s/"//' | sort -n | tail -1)
|
|
|
|
# Latest cmdline-tools download ID
|
|
CMDLINE_DOWNLOAD=$(echo "$REPO_XML" | grep -o 'commandlinetools-linux-[0-9]*_latest' | \
|
|
sed 's/commandlinetools-linux-//;s/_latest//' | sort -n | tail -1)
|
|
|
|
echo "build_tools=${BUILD_TOOLS}" >> $GITHUB_OUTPUT
|
|
echo "platform=${PLATFORM}" >> $GITHUB_OUTPUT
|
|
echo "cmdline_tools=${CMDLINE_DOWNLOAD}" >> $GITHUB_OUTPUT
|
|
|
|
echo "Latest Android build-tools: ${BUILD_TOOLS}"
|
|
echo "Latest Android platform: ${PLATFORM}"
|
|
echo "Latest cmdline-tools download: ${CMDLINE_DOWNLOAD}"
|
|
|
|
- name: Check current Android SDK versions in Dockerfile
|
|
id: current
|
|
run: |
|
|
CURRENT_CMDLINE=$(grep -o 'ANDROID_SDK_TOOLS_VERSION=[0-9]*' Dockerfile.android | cut -d= -f2)
|
|
CURRENT_BUILD_TOOLS=$(grep -o 'ANDROID_BUILD_TOOLS=[0-9.]*' Dockerfile.android | cut -d= -f2)
|
|
CURRENT_PLATFORM=$(grep -o 'ANDROID_COMPILE_SDK=[0-9]*' Dockerfile.android | cut -d= -f2)
|
|
|
|
echo "cmdline_tools=${CURRENT_CMDLINE}" >> $GITHUB_OUTPUT
|
|
echo "build_tools=${CURRENT_BUILD_TOOLS}" >> $GITHUB_OUTPUT
|
|
echo "platform=${CURRENT_PLATFORM}" >> $GITHUB_OUTPUT
|
|
|
|
echo "Current cmdline-tools: ${CURRENT_CMDLINE}"
|
|
echo "Current build-tools: ${CURRENT_BUILD_TOOLS}"
|
|
echo "Current platform: ${CURRENT_PLATFORM}"
|
|
|
|
- name: Check if Flutter release already exists
|
|
id: existing
|
|
run: |
|
|
VERSION="${{ steps.flutter.outputs.version }}"
|
|
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/${VERSION}")
|
|
if [ "$STATUS" = "200" ]; then
|
|
echo "exists=true" >> $GITHUB_OUTPUT
|
|
echo "Release ${VERSION} already exists, skipping"
|
|
else
|
|
echo "exists=false" >> $GITHUB_OUTPUT
|
|
echo "Release ${VERSION} not found, will create"
|
|
fi
|
|
|
|
- name: Determine if Android SDK update is needed
|
|
id: android_update
|
|
run: |
|
|
NEEDS_UPDATE=false
|
|
|
|
if [ "${{ steps.android.outputs.cmdline_tools }}" != "${{ steps.current.outputs.cmdline_tools }}" ]; then
|
|
echo "cmdline-tools update available: ${{ steps.current.outputs.cmdline_tools }} -> ${{ steps.android.outputs.cmdline_tools }}"
|
|
NEEDS_UPDATE=true
|
|
fi
|
|
|
|
if [ "${{ steps.android.outputs.build_tools }}" != "${{ steps.current.outputs.build_tools }}" ]; then
|
|
echo "build-tools update available: ${{ steps.current.outputs.build_tools }} -> ${{ steps.android.outputs.build_tools }}"
|
|
NEEDS_UPDATE=true
|
|
fi
|
|
|
|
if [ "${{ steps.android.outputs.platform }}" != "${{ steps.current.outputs.platform }}" ]; then
|
|
echo "platform update available: ${{ steps.current.outputs.platform }} -> ${{ steps.android.outputs.platform }}"
|
|
NEEDS_UPDATE=true
|
|
fi
|
|
|
|
echo "needs_update=${NEEDS_UPDATE}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create release for new Flutter version
|
|
if: steps.existing.outputs.exists == 'false' && steps.flutter.outputs.version != ''
|
|
run: |
|
|
VERSION="${{ steps.flutter.outputs.version }}"
|
|
echo "Creating release for Flutter ${VERSION}"
|
|
curl -fsSL -X POST \
|
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" \
|
|
-d "{
|
|
\"tag_name\": \"${VERSION}\",
|
|
\"name\": \"Flutter SDK ${VERSION}\",
|
|
\"body\": \"Automated release for Flutter stable ${VERSION}\",
|
|
\"draft\": false,
|
|
\"prerelease\": false
|
|
}"
|
|
|
|
- name: Create issue for Android SDK updates
|
|
if: steps.android_update.outputs.needs_update == 'true'
|
|
run: |
|
|
BODY="Android SDK updates are available:\n\n"
|
|
BODY+="| Component | Current | Latest |\n"
|
|
BODY+="|-----------|---------|--------|\n"
|
|
BODY+="| cmdline-tools | ${{ steps.current.outputs.cmdline_tools }} | ${{ steps.android.outputs.cmdline_tools }} |\n"
|
|
BODY+="| build-tools | ${{ steps.current.outputs.build_tools }} | ${{ steps.android.outputs.build_tools }} |\n"
|
|
BODY+="| platform | ${{ steps.current.outputs.platform }} | ${{ steps.android.outputs.platform }} |\n"
|
|
BODY+="\nUpdate \`Dockerfile.android\` to use the latest versions."
|
|
|
|
# Check if issue already exists
|
|
EXISTING=$(curl -s -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/issues?state=open&labels=android-sdk-update" | jq length)
|
|
|
|
if [ "$EXISTING" = "0" ]; then
|
|
curl -fsSL -X POST \
|
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/issues" \
|
|
-d "{
|
|
\"title\": \"Android SDK updates available\",
|
|
\"body\": \"$(echo -e "$BODY")\",
|
|
\"labels\": [\"android-sdk-update\"]
|
|
}"
|
|
echo "Created issue for Android SDK updates"
|
|
else
|
|
echo "Issue for Android SDK updates already exists"
|
|
fi
|