Skip to content

new-release

new-release #14

name: Update formula
on:
repository_dispatch:
types: [new-release]
workflow_dispatch:
inputs:
version:
description: "Version to update to (e.g. 0.1.0)"
required: true
permissions:
contents: write
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Resolve version and checksum from PyPI
id: meta
env:
INPUT_VERSION: ${{ github.event.inputs.version }}
PAYLOAD_VERSION: ${{ github.event.client_payload.version }}
run: |
set -euo pipefail
VERSION="${INPUT_VERSION:-$PAYLOAD_VERSION}"
if [ -z "$VERSION" ]; then
VERSION=$(curl -sfL https://pypi.org/pypi/create-awesome-python-app/json | jq -r '.info.version')
fi
META=""
for attempt in $(seq 1 24); do
if META=$(curl -sfL "https://pypi.org/pypi/create-awesome-python-app/${VERSION}/json"); then
URL=$(echo "$META" | jq -r '.urls[] | select(.packagetype=="sdist") | .url')
SHA=$(echo "$META" | jq -r '.urls[] | select(.packagetype=="sdist") | .digests.sha256')
if [ -n "$URL" ] && [ "$URL" != "null" ] && [ -n "$SHA" ] && [ "$SHA" != "null" ]; then
break
fi
fi
echo "::warning::PyPI not ready for create-awesome-python-app==${VERSION} (attempt ${attempt}/24); retrying in 15s"
sleep 15
META=""
done
URL=$(echo "$META" | jq -r '.urls[] | select(.packagetype=="sdist") | .url')
SHA=$(echo "$META" | jq -r '.urls[] | select(.packagetype=="sdist") | .digests.sha256')
if [ -z "$URL" ] || [ "$URL" = "null" ] || [ -z "$SHA" ] || [ "$SHA" = "null" ]; then
echo "::error::Could not resolve sdist for create-awesome-python-app==${VERSION}" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "sha256=$SHA" >> "$GITHUB_OUTPUT"
echo "url=$URL" >> "$GITHUB_OUTPUT"
echo "Resolved v${VERSION}"
echo " url=$URL"
echo " sha256=$SHA"
- name: Patch formula
env:
FORMULA_URL: ${{ steps.meta.outputs.url }}
FORMULA_SHA: ${{ steps.meta.outputs.sha256 }}
run: |
sed -i "s|url \".*\"|url \"${FORMULA_URL}\"|" Formula/create-awesome-python-app.rb
sed -i "s|sha256 \".*\"|sha256 \"${FORMULA_SHA}\"|" Formula/create-awesome-python-app.rb
echo "----- Updated formula -----"
cat Formula/create-awesome-python-app.rb
- name: Commit and push
uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0
with:
commit_message: "feat: update formula to ${{ steps.meta.outputs.version }}"
commit_user_name: "Create Python App Bot"
commit_user_email: "ulisescf.24@gmail.com"