Skip to content

Commit da4b14e

Browse files
authored
Add homebrew.yaml (#22)
1 parent 067c9eb commit da4b14e

File tree

6 files changed

+182
-106
lines changed

6 files changed

+182
-106
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ko_fi: cssnr

.github/workflows/homebrew.yaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: "Homebrew"
2+
3+
on:
4+
workflow_call:
5+
inputs: &inputs
6+
name:
7+
description: "Package Name"
8+
type: string
9+
default: "npmstat"
10+
version:
11+
description: "Build Version"
12+
type: string
13+
required: true
14+
workflow_dispatch:
15+
inputs: *inputs
16+
17+
jobs:
18+
homebrew:
19+
name: "Homebrew"
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 5
22+
23+
permissions:
24+
contents: read
25+
26+
steps:
27+
- name: "PyPi URL"
28+
id: url
29+
uses: cssnr/web-request-action@master
30+
with:
31+
method: "GET"
32+
url: "https://pypi.org/pypi/${{ inputs.name }}/${{ inputs.version }}/json"
33+
path: '$.urls[?(@.packagetype=="sdist")]'
34+
35+
- name: "Validate Outputs"
36+
uses: cssnr/validate-outputs-action@master
37+
with:
38+
outputs: ${{ toJSON(steps.url.outputs) }}
39+
data: |
40+
url:
41+
sha256:
42+
43+
#- name: "Verify URL"
44+
# env:
45+
# url: ${{ fromJSON(steps.url.outputs.result).url }}
46+
# sha256: ${{ fromJSON(steps.url.outputs.result).digests.sha256 }}
47+
# run: |
48+
# echo "download-url: ${url}"
49+
# echo "download-sha256: ${sha256}"
50+
# if [ -z "${url}" ];then
51+
# echo "Missing URL" && exit 1
52+
# fi
53+
# if [ -z "${sha256}" ];then
54+
# echo "Missing SHA256" && exit 1
55+
# fi
56+
57+
- name: "Homebrew Action"
58+
id: homebrew
59+
uses: cssnr/homebrew-action@master
60+
with:
61+
url: ${{ fromJSON(steps.url.outputs.result).url }}
62+
sha256: ${{ fromJSON(steps.url.outputs.result).digests.sha256 }}
63+
repo: cssnr/homebrew-tap
64+
formula: ${{ inputs.name }}
65+
message: Bump ${{ inputs.name }} to ${{ github.ref_name }}
66+
branch: master
67+
app_id: 146360
68+
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
69+
70+
#- name: "Homebrew Formula Action"
71+
# uses: mislav/bump-homebrew-formula-action@56a283fa15557e9abaa4bdb63b8212abc68e655c # v3.6
72+
# env:
73+
# COMMITTER_TOKEN: ${{ secrets.HOMEBREW_PAT }}
74+
# with:
75+
# formula-name: "${{ inputs.name }}"
76+
# tag-name: ${{ github.ref_name }}
77+
# download-url: ${{ fromJSON(steps.url.outputs.result).url }}
78+
# download-sha256: ${{ fromJSON(steps.url.outputs.result).digests.sha256 }}
79+
# homebrew-tap: "cssnr/homebrew-tap"
80+
# create-pullrequest: false
81+
# create-branch: false
82+
# commit-message: "Bump {{formulaName}} to {{version}}"

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
6767
- name: "astral-sh/ruff"
6868
if: ${{ !cancelled() }}
69-
uses: astral-sh/ruff-action@v3
69+
uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1
7070
with:
7171
version: latest
7272

.github/workflows/release.yaml

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
env:
88
name: "npmstat"
9-
download-url: "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/npmstat-${{ github.ref_name }}.tar.gz"
9+
#download-url: "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/npmstat-${{ github.ref_name }}.tar.gz"
1010

1111
jobs:
1212
pyinstaller:
@@ -74,8 +74,8 @@ jobs:
7474
results="$(ls -lAh "${path}"/* | awk '{print $9" - "$5}')"
7575
md="Artifacts:\n\`\`\`text\n${results}\n\`\`\`"
7676
echo -e "${md}" >> "$GITHUB_STEP_SUMMARY"
77-
echo "Verification String: '${name/-/_}-${tag}-'"
78-
find "${path}" -type f | grep -- "${name/-/_}-${tag}-" > /dev/null
77+
echo "Verification String: '${name//-/_}-${tag}-'"
78+
find "${path}" -type f | grep -- "${name//-/_}-${tag}-" > /dev/null
7979
8080
- name: "Publish to PyPI"
8181
id: publish
@@ -109,30 +109,14 @@ jobs:
109109
homebrew:
110110
name: "Homebrew"
111111
if: ${{ !github.event.release.prerelease }}
112-
runs-on: ubuntu-latest
113-
timeout-minutes: 5
114-
needs: [publish, pyinstaller]
115-
steps:
116-
#- name: "Homebrew Action"
117-
# uses: cssnr/homebrew-action@master
118-
# with:
119-
# version: ${{ github.ref_name }}
120-
# repo: cssnr/homebrew-tap
121-
# token: ${{ secrets.HOMEBREW_PAT }}
122-
123-
- name: "Homebrew Formula Action"
124-
uses: mislav/bump-homebrew-formula-action@v3
125-
env:
126-
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_PAT }}
127-
with:
128-
formula-name: npmstat.rb
129-
tag-name: ${{ github.ref_name }}
130-
download-url: ${{ env.download-url }}
131-
#download-sha256: 64be704a875d2a59753d80ee8a533c3fe183e3f06807ff7dc2232938ccb01549
132-
homebrew-tap: "cssnr/homebrew-tap"
133-
create-pullrequest: false
134-
create-branch: false
135-
commit-message: "Bump {{formulaName}} to {{version}}"
112+
uses: ./.github/workflows/homebrew.yaml
113+
needs: [publish]
114+
secrets: inherit
115+
with:
116+
name: "npmstat"
117+
version: ${{ github.ref_name }}
118+
permissions:
119+
contents: read
136120

137121
release:
138122
name: "Release"

pyproject.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,27 @@ select = ["E4", "E7", "E9", "F", "B", "Q"]
114114
win-version = "uv run pyivf-make_version --source-format yaml --metadata-source .github/files/win-version.yaml --outfile win-version.txt"
115115
pyinstaller = "uv run pyinstaller -F -n npmstat -i docs/favicon.ico src/app.py"
116116
test = ["uv run coverage run -m pytest", "uv run coverage report -m"]
117+
clean = "rm -rf dist"
117118
build = "uv run hatch build"
118119
predocs = "rm -rf .cache site"
119-
docs = "zensical serve --open"
120+
docs = "zensical serve --open --dev-addr 0.0.0.0:8000"
120121
docs-build = "zensical build --clean"
121-
format = ["uv run black .", "uv run tombi format .", "uv run ruff format ."]
122+
format = """
123+
uv run black .
124+
uv run isort -c .
125+
uv run ruff format
126+
uv run tombi format .
127+
which prettier && prettier --write . || echo missing prettier
128+
"""
122129
lint = """
123-
uv run black --check .
124130
run bandit
125131
run mypy
126132
run ruff
127133
run validate
128134
run yamllint
135+
which prettier && prettier --check . || echo missing prettier
136+
uv run black --check .
137+
uv run isort -c .
129138
uv run tombi lint .
130139
uv run ty check -v .
131140
uv lock --check

0 commit comments

Comments
 (0)