Skip to content

Autoupdate

Autoupdate #1

Workflow file for this run

name: Auto update python packages
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
update_packages:
runs-on: ubuntu-latest
permissions:
contents: write
pull-request: write

Check failure on line 15 in .github/workflows/update.yml

View workflow run for this annotation

GitHub Actions / Auto update python packages

Invalid workflow file

The workflow is not valid. .github/workflows/update.yml (Line: 15, Col: 7): Unexpected value 'pull-request'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Setup vcpkg
uses: ./.github/actions/setup-vcpkg
- name: Format vcpkg.json
run: |
#!/bin/bash
# Base directory of the ports folder
PORTS_DIR="ports"
# Loop over all subfolders that match the pattern py-* and contain portfile.cmake
for dir in "$PORTS_DIR"/py-*; do
if [[ -d "$dir" && -f "$dir/portfile.cmake" ]]; then
# Check if portfile.cmake contains the string "vcpkg_from_pythonhosted"
if grep -q "vcpkg_from_pythonhosted" "$dir/portfile.cmake"; then
# Extract the package name by stripping the prefix "py-"
package_name=$(basename "$dir" | sed 's/^py-//')
# Query the PyPI API for the latest package info
pypi_url="https://pypi.org/pypi/${package_name}/json"
pypi_response=$(curl -s "$pypi_url")
if [[ $? -ne 0 ]]; then
echo "Failed to query PyPI for $package_name"
continue
fi
# Extract the latest version and source URL from the PyPI response
latest_version=$(echo "$pypi_response" | jq -r '.info.version')
source_url=$(echo "$pypi_response" | jq -r '.urls[] | select(.packagetype == "sdist") | .url')
if [[ "$latest_version" == "null" || -z "$latest_version" ]]; then
echo "Failed to get the latest version for $package_name"
continue
fi
if [[ "$source_url" == "null" || -z "$source_url" ]]; then
echo "Failed to get the source URL for $package_name"
continue
fi
echo "Updating $package_name to version $latest_version with source URL $source_url"
# Path to the vcpkg.json and portfile.cmake files
vcpkg_json="$dir/vcpkg.json"
portfile_cmake="$dir/portfile.cmake"
if [[ -f "$vcpkg_json" ]]; then
# Remove "port-version" if it exists and update version and source URL
jq 'del(.["port-version"])' "$vcpkg_json" | \
jq --arg new_version "$latest_version" '.version = $new_version' > "${vcpkg_json}.tmp" && mv "${vcpkg_json}.tmp" "$vcpkg_json"
echo "Updated $vcpkg_json to version $latest_version (removed port-version if present)"
else
echo "vcpkg.json not found in $dir"
fi
# Download the source file (to memory) and calculate the SHA512 checksum
temp_file=$(mktemp)
curl -sL "$source_url" -o "$temp_file"
sha512sum=$(sha512sum "$temp_file" | awk '{print $1}')
rm "$temp_file" # Clean up the downloaded file
echo "Calculated SHA512 checksum: $sha512sum"
# Update the SHA512 line in portfile.cmake
if [[ -f "$portfile_cmake" ]]; then
sed -i "s/SHA512\s\+[a-f0-9]\+/SHA512 $sha512sum/" "$portfile_cmake"
echo "Updated SHA512 checksum in $portfile_cmake"
else
echo "portfile.cmake not found in $dir"
fi
fi
fi
done
- name: Format vcpkg.json
run: |
vcpkg format-manifest --all $(find . -name "vcpkg.json")
git add ports
git commit -m "Autoupdating ports"
- name: Update versions
run: |
for dir in ports/* ; do
vcpkg x-add-version ${dir##ports/} --overlay-ports=./ports \
--x-builtin-registry-versions-dir=./versions/ \
--x-builtin-ports-root=./ports
done
git add versions
git commit --am --no-edit
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7