-
Notifications
You must be signed in to change notification settings - Fork 3
142 lines (118 loc) · 4.37 KB
/
release.yml
File metadata and controls
142 lines (118 loc) · 4.37 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Auto Release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # Required for trusted publishing to PyPI
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get version from pyproject.toml
id: version
run: |
VERSION=$(grep -m1 'version = ' pyproject.toml | cut -d'"' -f2)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version from pyproject.toml: $VERSION"
- name: Check if version already released
id: check
run: |
VERSION="${{ steps.version.outputs.version }}"
if git tag | grep -q "^v$VERSION$"; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "Version v$VERSION already exists, skipping"
else
echo "skip=false" >> $GITHUB_OUTPUT
echo "Version v$VERSION not released yet"
fi
- name: Create tag and release
if: steps.check.outputs.skip == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
COMMIT_MSG=$(git log -1 --pretty=%B | head -1)
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin "v$VERSION"
cat <<EOF | gh release create "v$VERSION" --title "v$VERSION" --notes-file -
## Changes
$COMMIT_MSG
---
*Auto-generated release*
EOF
# Publish to PyPI
- name: Install uv
if: steps.check.outputs.skip == 'false'
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
if: steps.check.outputs.skip == 'false'
run: uv python install 3.11
- name: Build package
if: steps.check.outputs.skip == 'false'
run: uv build
- name: Publish to PyPI
if: steps.check.outputs.skip == 'false'
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
# Update Homebrew formula
- name: Get release info for Homebrew
if: steps.check.outputs.skip == 'false'
id: homebrew
run: |
VERSION="${{ steps.version.outputs.version }}"
URL="https://github.com/${{ github.repository }}/archive/refs/tags/v$VERSION.tar.gz"
SHA256=$(curl -sL "$URL" | shasum -a 256 | cut -d' ' -f1)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "url=$URL" >> $GITHUB_OUTPUT
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
echo "Homebrew URL: $URL"
echo "Homebrew SHA256: $SHA256"
- name: Checkout homebrew-aidocs
if: steps.check.outputs.skip == 'false'
uses: actions/checkout@v4
with:
repository: binarcode/homebrew-aidocs
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-aidocs
- name: Update Homebrew formula
if: steps.check.outputs.skip == 'false'
run: |
cat > homebrew-aidocs/Formula/aidocs.rb << EOF
class Aidocs < Formula
include Language::Python::Virtualenv
desc "AI-powered documentation generator CLI for Claude Code"
homepage "https://github.com/binarcode/aidocs-cli"
url "${{ steps.homebrew.outputs.url }}"
sha256 "${{ steps.homebrew.outputs.sha256 }}"
license "MIT"
depends_on "python@3.11"
def install
venv = virtualenv_create(libexec, "python3.11")
venv.pip_install "aidocs==${{ steps.homebrew.outputs.version }}"
bin.install_symlink libexec/"bin/aidocs"
end
test do
assert_match "aidocs", shell_output("#{bin}/aidocs version")
end
end
EOF
- name: Commit and push Homebrew formula
if: steps.check.outputs.skip == 'false'
run: |
cd homebrew-aidocs
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add Formula/aidocs.rb
git diff --staged --quiet || git commit -m "Update aidocs to ${{ steps.homebrew.outputs.version }}"
git push