-
Notifications
You must be signed in to change notification settings - Fork 42
146 lines (116 loc) · 4.55 KB
/
publish_package.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Publish and Update Formula
on:
release:
types: [ created ]
jobs:
build-n-publish-pypi:
name: Build and publish Python distributions to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install build and tomlkit dependencies
run: python -m pip install --upgrade pip build tomlkit
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Update version in pyproject.toml
run: |
sed -i "s/version = \".*\"/version = \"${{ env.VERSION }}\"/" pyproject.toml
- name: Build distribution
run: python -m build --sdist --wheel --outdir dist/
# - name: Publish distribution to TestPyPI for Validation
# uses: pypa/[email protected]
# with:
# repository_url: https://test.pypi.org/legacy/
# - name: Clear pip cache
# run: pip cache purge
# - name: Install Comfy CLI from Test Pypi and Test
# run: |
# for i in {1..3}; do
# pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple comfy-cli==${{env.VERSION}} && break || sleep 5
# done
# comfy --help
- name: Publish distribution to Official PyPI
uses: pypa/[email protected]
test-pip-installation:
name: Test Comfy CLI Installation via pip
needs: build-n-publish-pypi # This job runs after build-n-publish completes successfully
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Install Comfy CLI via pip and Test
run: pip install comfy-cli==${{env.VERSION}}
- name: Test Comfy CLI Help
run: comfy --help
publish-homebrew-tap:
runs-on: macos-latest # Use macOS runner where Homebrew is pre-installed
needs: build-n-publish-pypi
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
repository: 'Comfy-Org/homebrew-comfy-cli'
token: ${{ secrets.COMMITTER_TOKEN }}
path: 'homebrew-repo'
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Set up Python environment
run: |
python3 -m venv venv
source venv/bin/activate
pip install homebrew-pypi-poet
for i in {1..3}; do
pip install comfy-cli==${{env.VERSION}} && break || sleep 5
done
- name: Generate Homebrew Formula
run: |
source venv/bin/activate
poet -f comfy-cli==$VERSION > comfy-cli.rb
- name: Move Formulas to Tap Directory
run: |
mv comfy-cli.rb homebrew-repo/Formula/
- name: Install Comfy CLI using Homebrew Formula
run: |
brew install --build-from-source --verbose ./homebrew-repo/Formula/comfy-cli.rb
comfy --help
brew uninstall comfy-cli
- name: Commit and Push Formula
run: |
cd homebrew-repo
git config user.name github-actions
git config user.email [email protected]
git add Formula/comfy-cli.rb
git commit -m "Update comfy-cli to latest and version ${VERSION}"
git push
env:
GIT_COMMITTER_NAME: github-actions
GIT_COMMITTER_EMAIL: [email protected]
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: [email protected]
GITHUB_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
test-homebrew-installation:
name: Test Comfy CLI Installation via Homebrew
needs: publish-homebrew-tap # This job runs after publish-homebrew-tap completes successfully
runs-on: macos-latest
steps:
- name: Tap Comfy CLI Homebrew tap repository
run: brew tap Comfy-Org/comfy-cli
- name: Install comfy-cli latest via Homebrew
run: brew install comfy-org/comfy-cli/comfy-cli
- name: Test comfy-cli latest Help
run: comfy --help
- name: Uninstall comfy-cli latest
run: brew uninstall comfy-cli