Skip to content

Update all packages #223

Update all packages

Update all packages #223

name: Update all packages
on:
schedule:
# Run daily
- cron: '0 12 * * *'
workflow_dispatch:
inputs:
dry-run:
description: "Dry run"
required: false
default: true
type: boolean
jobs:
build-matrix:
name: "Build update matrix"
runs-on: ubuntu-latest
outputs:
include: ${{ steps.generate-matrix.outputs.include }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: generate-matrix
run: |
# Use JQ to reformat sourceMaintainers as a comma delimited list
MATRIX="$(jq -n 'reduce inputs as $in ([]; . + [$in | .sourceMaintainers = (.sourceMaintainers | join(","))])' packages/*.json -c)"
echo "include=$MATRIX" >> "$GITHUB_OUTPUT"
integrate-package:
name: Integrate "${{ matrix.recipeName }}"
runs-on: ubuntu-latest
needs: build-matrix
strategy:
matrix:
include: ${{ fromJson(needs.build-matrix.outputs.include) }}
env:
CI_COMMIT_AUTHOR: "pyodide-pr-bot (workflow)"
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Git
run: |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "username@users.noreply.github.com"
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: python3 -m pip install -r requirements.txt
# Check if we've already processed this package SHA!
- name: Determine latest SHA256
id: marker
run: |
latest_sha=$(curl "https://pypi.org/pypi/${{ matrix.recipeName }}/json" -s | jq '.urls[] | select (.packagetype == "sdist").digests.sha256' --raw-output)
echo "sha256=${latest_sha}" >> "$GITHUB_OUTPUT"
test -f ".hashes/${{ matrix.recipeName }}-${latest_sha}" && echo "marker-exists=1" >> "$GITHUB_OUTPUT" || true
- name: Create marker
if: ${{ !steps.marker.outputs.marker-exists }}
run: |
marker=".hashes/${{ matrix.recipeName }}-${{ steps.marker.outputs.sha256 }}"
touch "${marker}"
git add "${marker}"
git commit -m "Add marker for ${{ matrix.recipeName }} (SHA256 ${{ steps.marker.outputs.sha256 }})"
- name: Push marker
if: ${{ !steps.marker.outputs.marker-exists && !(github.event_name == 'workflow_dispatch' && inputs.dry-run)}}
run: git push
# Now issue PR
- name: Create PR
if: ${{ !steps.marker.outputs.marker-exists || (github.event_name == 'workflow_dispatch' && inputs.dry-run) }}
run: >-
python3 integrate-package
--repo "${{ matrix.sourceRepo }}"
--package "${{ matrix.packageName }}"
--recipe "${{ matrix.recipeName }}"
${{ matrix.prAsReady && '--ready-for-review' || '--not-ready-for-review' }}
--maintainers "${{ matrix.sourceMaintainers }}"
--commit 'Update {recipe} to {version}'
--title "${{ matrix.prTitlePattern || 'Upgrade {recipe} to {version}' }}"
--body "${{ matrix.prBodyPattern || 'This PR was created by a bot. Pinging {maintainers} to check this' }}"
--token "${{ secrets.GH_TOKEN_PYODIDE }}"
--downstream "pyodide-pr-bot/pyodide"
${{ github.event_name == 'workflow_dispatch' && inputs.dry-run && '--dry-run' || '--not-dry-run' }}