diff --git a/.github/workflows/homebrew.yml b/.github/workflows/homebrew.yml index fdceff50..9ef0c9a3 100644 --- a/.github/workflows/homebrew.yml +++ b/.github/workflows/homebrew.yml @@ -108,11 +108,6 @@ RUBY if: runner.os == 'Linux' run: | NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - echo '/home/linuxbrew/.linuxbrew/bin' >> "$GITHUB_PATH" - - - name: Set up brew shellenv (Linux only) - if: runner.os == 'Linux' - run: | eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" echo "HOMEBREW_PREFIX=$HOMEBREW_PREFIX" >> "$GITHUB_ENV" echo "HOMEBREW_CELLAR=$HOMEBREW_CELLAR" >> "$GITHUB_ENV" @@ -177,81 +172,19 @@ RUBY sleep 30 done - - name: Generate release formula with PyPI URL + - name: Generate release formula via build_brew.sh + run: ./bin/build_brew.sh + + - name: Test formula install run: | - VERSION="${{ steps.version.outputs.version }}" - python3 -m venv /tmp/poet-venv - source /tmp/poet-venv/bin/activate - - pip install --quiet "archivebox==${VERSION}" homebrew-pypi-poet - - echo "[+] Generating resource stanzas with homebrew-pypi-poet..." - RESOURCES="$(poet archivebox)" - - # Get sdist URL and SHA256 from PyPI JSON API - PYPI_JSON="$(curl -fsSL "https://pypi.org/pypi/archivebox/${VERSION}/json" 2>/dev/null || echo '')" - SDIST_URL="" - SDIST_SHA256="" - if [ -n "$PYPI_JSON" ]; then - SDIST_URL="$(echo "$PYPI_JSON" | python3 -c "import sys,json; d=json.load(sys.stdin); print(next((u['url'] for u in d['urls'] if u['packagetype']=='sdist'), ''))" 2>/dev/null || echo '')" - SDIST_SHA256="$(echo "$PYPI_JSON" | python3 -c "import sys,json; d=json.load(sys.stdin); print(next((u['digests']['sha256'] for u in d['urls'] if u['packagetype']=='sdist'), ''))" 2>/dev/null || echo '')" - fi - if [ -z "$SDIST_URL" ]; then - SDIST_URL="https://files.pythonhosted.org/packages/source/a/archivebox/archivebox-${VERSION}.tar.gz" - fi - if [ -z "$SDIST_SHA256" ]; then - pip download --no-binary :all: --no-deps -d /tmp/sdist "archivebox==${VERSION}" 2>/dev/null || true - SDIST_SHA256="$(shasum -a 256 /tmp/sdist/*.tar.gz 2>/dev/null | awk '{print $1}' || echo '')" - fi - - deactivate - - cat > /tmp/archivebox.rb << RUBY -# Auto-generated Homebrew formula for archivebox ${VERSION} -# Generated by GitHub Actions on release using homebrew-pypi-poet -# -# Users install with: -# brew tap archivebox/archivebox -# brew install archivebox - -class Archivebox < Formula - include Language::Python::Virtualenv - - desc "Self-hosted internet archiving solution" - homepage "https://github.com/ArchiveBox/ArchiveBox" - url "${SDIST_URL}" - sha256 "${SDIST_SHA256}" - license "MIT" - head "https://github.com/ArchiveBox/ArchiveBox.git", branch: "dev" - - depends_on "python@3.13" - -${RESOURCES} - - def install - virtualenv_install_with_resources - end - - test do - assert_match version.to_s, shell_output("#{bin}/archivebox version") - end -end -RUBY - - echo "[√] Generated release formula:" - ruby -c /tmp/archivebox.rb - cat /tmp/archivebox.rb + brew install --build-from-source brew_dist/archivebox.rb + archivebox version - name: Upload formula artifact uses: actions/upload-artifact@v4 with: name: archivebox.rb - path: /tmp/archivebox.rb - - - name: Test formula install - run: | - brew install --build-from-source /tmp/archivebox.rb - archivebox version + path: brew_dist/archivebox.rb - name: Push to homebrew-archivebox tap env: @@ -260,8 +193,8 @@ RUBY VERSION="${{ steps.version.outputs.version }}" git clone "https://x-access-token:${GH_TOKEN}@github.com/ArchiveBox/homebrew-archivebox.git" /tmp/tap - cp /tmp/archivebox.rb /tmp/tap/Formula/archivebox.rb 2>/dev/null || \ - cp /tmp/archivebox.rb /tmp/tap/archivebox.rb + cp brew_dist/archivebox.rb /tmp/tap/Formula/archivebox.rb 2>/dev/null || \ + cp brew_dist/archivebox.rb /tmp/tap/archivebox.rb cd /tmp/tap git config user.name "github-actions[bot]"