nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 53 lines 1.8 kB view raw
1#!/usr/bin/env nix-shell 2#!nix-shell -i bash -p common-updater-scripts curl jq nixfmt-tree 3 4set -euo pipefail 5 6# This script updates apache-airflow to the latest tag for a given major version. 7# It defaults to major version 3. 8# 9# Usage: ./update.sh [MAJOR_VERSION] 10# Example: ./update.sh 2 11 12MAJOR_VERSION="${1:-3}" 13PACKAGE_DIR=$(dirname "$0") 14PACKAGE_NAME="apache-airflow" 15 16# Fetches the latest git tag for the given major version from the GitHub API. 17# It filters for tags that look like version numbers and sorts them to find the latest. 18get_latest_tag() { 19 TEMP_FILE=$(mktemp) 20 curl -s "https://api.github.com/repos/apache/airflow/releases" > "$TEMP_FILE" 21 LATEST_TAG=$(jq -r --arg major_version "$MAJOR_VERSION" ' 22 .[] 23 | select(.tag_name | test("^" + $major_version + "\\.\\d+\\.\\d+$")) 24 | .tag_name 25 ' "$TEMP_FILE" | sort -V | tail -n 1) 26 rm "$TEMP_FILE" 27 echo "$LATEST_TAG" 28} 29 30echo "Looking for latest tag for major version $MAJOR_VERSION..." 31LATEST_TAG=$(get_latest_tag) 32 33if [[ -z "$LATEST_TAG" ]]; then 34 echo "No new tag found for major version $MAJOR_VERSION." 35 exit 0 36fi 37 38echo "Latest tag found: $LATEST_TAG" 39 40# Update the version and hash in the package definition 41# This uses the standard nixpkgs script `update-source-version`. 42echo "Updating source version for $PACKAGE_NAME to $LATEST_TAG..." 43update-source-version "$PACKAGE_NAME" "$LATEST_TAG" 44 45# After updating the main package, run the providers update script. 46# It will automatically pick up the new version from the nix file. 47echo "Updating provider dependencies..." 48"$PACKAGE_DIR/update-providers.py" 49echo "Formatting generated providers.nix" 50treefmt "$PACKAGE_DIR" 51 52echo "Update complete. Please check the git diff for changes." 53