Check Upstream Releases #51
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: Check Upstream Releases | |
| on: | |
| schedule: | |
| # Run every Monday at 9am UTC | |
| - cron: '0 9 * * 1' | |
| workflow_dispatch: | |
| inputs: | |
| force_check: | |
| description: 'Force check even if version unchanged' | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| issues: write | |
| jobs: | |
| check-upstream: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check Python Globus SDK releases | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -e | |
| # Function to check a specific version line | |
| check_version_line() { | |
| local version_line="$1" | |
| local upstream_repo="globus/globus-sdk-python" | |
| local repo_label="Python Globus SDK $version_line" | |
| local version_key="$upstream_repo:$version_line" | |
| echo "Checking $repo_label..." | |
| # Get all releases and filter by version pattern | |
| if [ "$version_line" = "v3" ]; then | |
| version_pattern="^v3\." | |
| else | |
| version_pattern="^v4\." | |
| fi | |
| # Get latest release matching the version pattern | |
| latest_tag=$(gh release list --repo "$upstream_repo" --limit 100 --json tagName 2>/dev/null | \ | |
| jq -r ".[].tagName" | grep -E "$version_pattern" | head -n1) | |
| if [ -z "$latest_tag" ]; then | |
| echo " [WARNING] Could not find $version_line release for $upstream_repo" | |
| return 0 | |
| fi | |
| # Get full release details | |
| latest_release=$(gh release view --repo "$upstream_repo" "$latest_tag" --json tagName,name,body,url,publishedAt 2>/dev/null || echo "") | |
| if [ -z "$latest_release" ]; then | |
| echo " [WARNING] Could not fetch release details for $latest_tag" | |
| return 0 | |
| fi | |
| release_name=$(echo "$latest_release" | jq -r '.name') | |
| release_body=$(echo "$latest_release" | jq -r '.body') | |
| release_url=$(echo "$latest_release" | jq -r '.url') | |
| published_at=$(echo "$latest_release" | jq -r '.publishedAt') | |
| # Get stored version | |
| stored_version=$(jq -r --arg key "$version_key" '.[$key]' .github/upstream-versions.json) | |
| echo " Current tracked: $stored_version" | |
| echo " Latest upstream: $latest_tag" | |
| # Check if version changed or force check | |
| if [ "$stored_version" = "$latest_tag" ] && [ "${{ github.event.inputs.force_check }}" != "true" ]; then | |
| echo " [OK] Already up to date" | |
| return 0 | |
| fi | |
| # Check if issue already exists for this version | |
| existing_issue=$(gh issue list --repo ${{ github.repository }} \ | |
| --search "\"New $repo_label release: $latest_tag\" in:title" \ | |
| --json number --jq '.[0].number' 2>/dev/null || echo "") | |
| if [ -n "$existing_issue" ]; then | |
| echo " [INFO] Issue already exists: #$existing_issue" | |
| return 0 | |
| fi | |
| echo " [NEW] New release found: $latest_tag" | |
| # Build comparison URL | |
| comparison_url="https://github.com/$upstream_repo/compare/$stored_version...$latest_tag" | |
| # Create issue body (use printf to avoid un-indented lines breaking YAML block scalar) | |
| issue_body=$(printf \ | |
| '## New %s Release Available\n\n**New Version:** `%s`\n**Previous Version:** `%s`\n**Published:** %s\n**Version Line:** %s\n\n### Links\n- [Release Page](%s)\n- [Compare Changes](%s)\n- [Repository](https://github.com/%s)\n\n### Release Notes\n\n%s\n\n---\n\n### Action Items\n- [ ] Review release notes and changes\n- [ ] Check for breaking changes or deprecations\n- [ ] Port new features and improvements\n- [ ] Update tests for new functionality\n- [ ] Update documentation if needed\n- [ ] Update `.github/upstream-versions.json` after porting changes\n\n**Upstream Repository:** `%s` (%s)\n' \ | |
| "$repo_label" "$latest_tag" "$stored_version" "$published_at" "$version_line" \ | |
| "$release_url" "$comparison_url" "$upstream_repo" \ | |
| "$release_body" "$upstream_repo" "$version_line") | |
| # Create the issue | |
| issue_number=$(gh issue create \ | |
| --title "New $repo_label release: $latest_tag" \ | |
| --body "$issue_body" \ | |
| --label "upstream-update,needs-review,dependencies,$version_line" \ | |
| --json number --jq '.number') | |
| echo " [OK] Created issue #$issue_number" | |
| # Update the version tracking file | |
| jq --arg key "$version_key" --arg version "$latest_tag" \ | |
| '.[$key] = $version' .github/upstream-versions.json > .github/upstream-versions.json.tmp | |
| mv .github/upstream-versions.json.tmp .github/upstream-versions.json | |
| # Mark for commit | |
| echo "true" > /tmp/has_update | |
| echo "$version_line=$latest_tag" >> /tmp/updated_versions | |
| } | |
| # Check both v3 and v4 version lines | |
| check_version_line "v3" | |
| check_version_line "v4" | |
| echo "Upstream check complete!" | |
| - name: Commit version updates | |
| run: | | |
| if [ -f /tmp/has_update ]; then | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Check if there are changes to commit | |
| if git diff --quiet .github/upstream-versions.json; then | |
| echo "No version updates to commit" | |
| exit 0 | |
| fi | |
| # Build commit message | |
| commit_msg="chore: update upstream version tracking"$'\n\n' | |
| while IFS= read -r line; do | |
| commit_msg+="- Updated Python SDK $line"$'\n' | |
| done < /tmp/updated_versions | |
| git add .github/upstream-versions.json | |
| git commit -m "$commit_msg" | |
| git push | |
| echo "[OK] Committed version update" | |
| else | |
| echo "No updates found" | |
| fi | |
| - name: Summary | |
| if: always() | |
| run: | | |
| echo "## Upstream Release Check Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tracking:** Python Globus SDK (globus/globus-sdk-python)" >> $GITHUB_STEP_SUMMARY | |
| echo "- v3.x releases" >> $GITHUB_STEP_SUMMARY | |
| echo "- v4.x releases" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ -f /tmp/has_update ]; then | |
| echo "### [NEW] New Releases Found" >> $GITHUB_STEP_SUMMARY | |
| while IFS= read -r line; do | |
| echo "- $line" >> $GITHUB_STEP_SUMMARY | |
| done < /tmp/updated_versions | |
| else | |
| echo "[OK] Already up to date with upstream" >> $GITHUB_STEP_SUMMARY | |
| fi |