Uh oh!
There was an error while loading. Please reload this page.
Notify Homebrew tap #10
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: Notify Homebrew tap | |
| # Runs after Release succeeds (PyPI already uploaded), or manually. | |
| # Sends repository_dispatch to Create-Python-App/homebrew-tap so | |
| # update-formula can bump the formula once the sdist is on PyPI. | |
| on: | |
| workflow_run: | |
| workflows: ["Release"] | |
| types: [completed] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Package version (e.g. 0.1.0)" | |
| required: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| notify: | |
| name: Dispatch to homebrew-tap | |
| if: >- | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event.workflow_run.conclusion == 'success' && | |
| startsWith(github.event.workflow_run.head_branch, 'create-awesome-python-app@')) | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| steps: | |
| - name: Resolve version | |
| id: version | |
| env: | |
| INPUT_VERSION: ${{ github.event.inputs.version }} | |
| RUN_BRANCH: ${{ github.event.workflow_run.head_branch }} | |
| run: | | |
| set -euo pipefail | |
| if [ -n "${INPUT_VERSION:-}" ]; then | |
| VERSION="$INPUT_VERSION" | |
| else | |
| VERSION="${RUN_BRANCH#create-awesome-python-app@}" | |
| fi | |
| if ! echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([a-zA-Z0-9.-]+)?$'; then | |
| echo "::error::Invalid Homebrew notify version: $VERSION" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Wait for PyPI package | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| PACKAGE: create-awesome-python-app | |
| run: | | |
| set -euo pipefail | |
| attempts=24 | |
| delay=15 | |
| for attempt in $(seq 1 "$attempts"); do | |
| if curl -sfL "https://pypi.org/pypi/${PACKAGE}/${VERSION}/json" \ | |
| | jq -e '.urls[] | select(.packagetype=="sdist") | .digests.sha256' >/dev/null; then | |
| echo "PyPI has ${PACKAGE}==${VERSION}" | |
| exit 0 | |
| fi | |
| echo "::warning::PyPI not ready for ${PACKAGE}==${VERSION} (attempt ${attempt}/${attempts}); retrying in ${delay}s" | |
| sleep "$delay" | |
| done | |
| echo "::error::Timed out waiting for ${PACKAGE}==${VERSION} on PyPI" | |
| exit 1 | |
| - name: Dispatch repository event | |
| env: | |
| GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| if [ -z "$GH_TOKEN" ]; then | |
| echo "::error::HOMEBREW_TAP_TOKEN secret is not set" >&2 | |
| exit 1 | |
| fi | |
| gh api \ | |
| --method POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| /repos/Create-Python-App/homebrew-tap/dispatches \ | |
| -f "event_type=new-release" \ | |
| -f "client_payload[version]=$VERSION" |