Skip to content

Commit 844e8e0

Browse files
committed
test
1 parent 87c82df commit 844e8e0

3 files changed

Lines changed: 24 additions & 25 deletions

File tree

Dockerfile

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
FROM python:3.13-slim
2-
3-
RUN apt-get update && apt-get install -y --no-install-recommends \
4-
curl \
5-
git
6-
7-
RUN useradd -m -s /bin/bash linuxbrew
8-
USER linuxbrew
9-
WORKDIR /home/linuxbrew
10-
11-
RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
12-
13-
ENV PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${PATH}"
14-
15-
RUN mkdir -p /home/linuxbrew/app
16-
17-
WORKDIR /home/linuxbrew/app
1+
FROM homebrew/brew:4.5.6
182

193
COPY --chown=linuxbrew:linuxbrew homebrew_releaser homebrew_releaser
204
COPY --chown=linuxbrew:linuxbrew setup.py setup.py
215

22-
RUN pip install .
6+
RUN brew install python@3.13 \
7+
&& python3 -m venv venv \
8+
&& venv/bin/pip install .
239

24-
ENTRYPOINT ["python", "/home/linuxbrew/app/homebrew_releaser/app.py"]
10+
ENTRYPOINT [ "venv/bin/python3", "homebrew_releaser/app.py" ]

homebrew_releaser/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def run_github_action():
165165
)
166166

167167
formula_filename = f'{repository["name"]}.rb'
168-
formula_dir = os.path.join(HOMEBREW_TAP, FORMULA_FOLDER)
168+
formula_dir = os.path.join('/tmp', 'homebrew-releaser', HOMEBREW_TAP, FORMULA_FOLDER)
169169
formula_filepath = os.path.join(formula_dir, formula_filename)
170170
Utils.write_file(formula_filepath, template, 'w')
171171

homebrew_releaser/git.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import subprocess # nosec
23
from typing import Optional
34

@@ -22,15 +23,18 @@ def setup(commit_owner: str, commit_email: str, homebrew_owner: str, homebrew_ta
2223
"""
2324
logger = woodchips.get(LOGGER_NAME)
2425

26+
homebrew_tap_path = Git._get_homebrew_tap_path(homebrew_tap)
27+
2528
commands = [
2629
[
2730
'git',
2831
'clone',
2932
'--depth=1',
3033
f'https://x-access-token:{GITHUB_TOKEN}@github.com/{homebrew_owner}/{homebrew_tap}.git',
34+
homebrew_tap_path,
3135
],
32-
['git', '-C', homebrew_tap, 'config', 'user.name', f'"{commit_owner}"'],
33-
['git', '-C', homebrew_tap, 'config', 'user.email', commit_email],
36+
['git', '-C', homebrew_tap_path, 'config', 'user.name', f'"{commit_owner}"'],
37+
['git', '-C', homebrew_tap_path, 'config', 'user.email', commit_email],
3438
]
3539

3640
for command in commands:
@@ -41,22 +45,25 @@ def setup(commit_owner: str, commit_email: str, homebrew_owner: str, homebrew_ta
4145
@staticmethod
4246
def add(homebrew_tap: str):
4347
"""Adds assets to a git commit."""
44-
command = ['git', '-C', homebrew_tap, 'add', '.']
48+
homebrew_tap_path = Git._get_homebrew_tap_path(homebrew_tap)
49+
command = ['git', '-C', homebrew_tap_path, 'add', '.']
4550
Git._run_git_subprocess(command, 'Assets added to git commit successfully.')
4651

4752
@staticmethod
4853
def commit(homebrew_tap: str, repo_name: str, version: str):
4954
"""Commits assets to the Homebrew tap (repo)."""
55+
homebrew_tap_path = Git._get_homebrew_tap_path(homebrew_tap)
5056
# fmt: off
51-
command = ['git', '-C', homebrew_tap, 'commit', '-m', f'chore: brew formula update for {repo_name} {version}'] # noqa
57+
command = ['git', '-C', homebrew_tap_path, 'commit', '-m', f'chore: brew formula update for {repo_name} {version}'] # noqa
5258
# fmt: on
5359
Git._run_git_subprocess(command, 'Assets committed successfully.')
5460

5561
@staticmethod
5662
def push(homebrew_tap: str, homebrew_owner: str):
5763
"""Pushes assets to the remote Homebrew tap (repo)."""
64+
homebrew_tap_path = Git._get_homebrew_tap_path(homebrew_tap)
5865
# fmt: off
59-
command = ['git', '-C', homebrew_tap, 'push', f'https://x-access-token:{GITHUB_TOKEN}@github.com/{homebrew_owner}/{homebrew_tap}.git'] # noqa
66+
command = ['git', '-C', homebrew_tap_path, 'push', f'https://x-access-token:{GITHUB_TOKEN}@github.com/{homebrew_owner}/{homebrew_tap}.git'] # noqa
6067
# fmt: on
6168
Git._run_git_subprocess(command, f'Assets pushed successfully to {homebrew_tap}.')
6269

@@ -80,3 +87,9 @@ def _run_git_subprocess(command: list[str], debug_message: Optional[str] = None)
8087
except Exception as error:
8188
logger.critical(error)
8289
raise
90+
91+
@staticmethod
92+
def _get_homebrew_tap_path(homebrew_tap: str) -> str:
93+
"""Returns the path to the Homebrew tap."""
94+
os.makedirs('/tmp/homebrew-releaser', exist_ok=True)
95+
return os.path.join('/tmp', 'homebrew-releaser', homebrew_tap)

0 commit comments

Comments
 (0)