-
Notifications
You must be signed in to change notification settings - Fork 209
124 lines (100 loc) · 3.77 KB
/
deploy.yml
File metadata and controls
124 lines (100 loc) · 3.77 KB
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
name: Upload Python Package
on:
release:
types: [created]
jobs:
deploy-pypi:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: pip install build twine toml
- name: Build the package
run: python -m build
- name: Check version matches
run: |
import toml
import os
import sys
# Read pyproject.toml
with open('pyproject.toml', 'r') as f:
pyproject = toml.load(f)
# Get version from pyproject.toml
project_version = pyproject['project']['version']
# Get release tag (strip 'v' prefix if present)
github_ref = os.environ['GITHUB_REF']
tag_version = github_ref.split('/')[-1]
if tag_version.startswith('v'):
tag_version = tag_version[1:]
print(f"pyproject.toml version: {project_version}")
print(f"Release tag version: {tag_version}")
# Compare versions
if project_version != tag_version:
print("Version mismatch!")
print(f"pyproject.toml version ({project_version}) does not match")
print(f"release tag version ({tag_version})")
sys.exit(1)
print("Versions match!")
shell: python
- name: Upload to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*
deploy-homebrew:
needs: deploy-pypi
runs-on: ubuntu-latest
steps:
- name: Extract version
id: get_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "VERSION=${GITHUB_REF#refs/tags/}" | sed 's/^\///' >> $GITHUB_OUTPUT
fi
- name: Checkout homebrew-tap
uses: actions/checkout@v3
with:
repository: agentstack-ai/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Create Formula directory
run: mkdir -p Formula
- name: Update Formula
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
# Get SHA256 of PyPI package
PACKAGE_NAME="${{ github.event.repository.name }}"
curl -sL https://pypi.org/pypi/$PACKAGE_NAME/$VERSION/json
SHA256=$(curl -sL https://pypi.org/pypi/$PACKAGE_NAME/$VERSION/json | jq -r '.urls[0].digests.sha256')
# Update formula
cat > Formula/$PACKAGE_NAME.rb << EOF
class Agentstack < Formula
include Language::Python::Virtualenv
desc "$(gh repo view --json description -q .description)"
homepage "https://github.com/${{ github.repository }}"
url "https://files.pythonhosted.org/packages/source/${PACKAGE_NAME:0:1}/$PACKAGE_NAME/$PACKAGE_NAME-$VERSION.tar.gz"
sha256 "$SHA256"
depends_on "python@3.9"
def install
virtualenv_install_with_resources
end
test do
system bin/"$PACKAGE_NAME", "--version"
end
end
EOF
- name: Commit and push changes
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add Formula/*.rb
git commit -m "Update formula to version ${{ steps.get_version.outputs.VERSION }}" || true
git push