mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-06 07:47:53 +10:00
Deduplicate homebrew.yml release job by reusing build_brew.sh
The release job was duplicating ~70 lines of PyPI fetching + formula generation that build_brew.sh already handles. Now it just calls ./bin/build_brew.sh. Also merged the two Linux-only brew setup steps. https://claude.ai/code/session_01Vx1EsNrNySgsc8Y67dGzCn
This commit is contained in:
85
.github/workflows/homebrew.yml
vendored
85
.github/workflows/homebrew.yml
vendored
@@ -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]"
|
||||
|
||||
Reference in New Issue
Block a user