-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (108 loc) · 4.11 KB
/
Copy pathrelease.yml
File metadata and controls
131 lines (108 loc) · 4.11 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
name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write # GitHub Release
id-token: write # PyPI Trusted Publishing (OIDC)
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build + runtime deps
run: |
python -m pip install --upgrade pip build
pip install -e ".[dev,neo4j]"
- name: Run tests
id: test
continue-on-error: true
run: pytest -q
- name: Delete tag on test failure
if: steps.test.conclusion == 'failure'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git push --delete origin "${GITHUB_REF#refs/tags/}"
exit 1
- name: Build wheel + sdist
run: python -m build
- name: Stage release assets (Neo4j schema contract)
run: |
mkdir -p release-assets
canclang --emit schema > release-assets/schema.json
ls -lh dist release-assets
- name: Get version from tag
id: ver
run: echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
- name: Compose release notes header
env:
VERSION: ${{ steps.ver.outputs.version }}
run: |
REPO="codellm-devkit/codeanalyzer-clang"
cat > "$RUNNER_TEMP/RELEASE_BODY.md" <<EOF
## Install codeanalyzer-clang v$VERSION
PyPI:
pip install codeanalyzer-clang==$VERSION
For the optional live Neo4j push (--emit neo4j --neo4j-uri ...):
pip install 'codeanalyzer-clang[neo4j]==$VERSION'
Homebrew:
brew tap codellm-devkit/tap
brew install codeanalyzer-clang
EOF
- name: Publish release on GitHub
uses: softprops/action-gh-release@v2
with:
files: |
dist/*
release-assets/*
body_path: ${{ runner.temp }}/RELEASE_BODY.md
generate_release_notes: true
discussion_category_name: Announcements
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to PyPI via Trusted Publishing
uses: pypa/gh-action-pypi-publish@release/v1
homebrew:
needs: release
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Derive version from tag
id: ver
run: echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
- name: Generate Homebrew formula
env:
REPO: ${{ github.repository }}
VERSION: ${{ steps.ver.outputs.version }}
run: |
chmod +x packaging/homebrew/generate_formula.sh
# Hash the exact sdist bytes the release just published, so the formula
# checksum always matches what users download.
sdist="https://github.com/${REPO}/releases/download/v${VERSION}/codeanalyzer_clang-${VERSION}.tar.gz"
SHA256="$(curl -fLsS "$sdist" | shasum -a 256 | cut -d' ' -f1)"
REPO="$REPO" VERSION="$VERSION" SHA256="$SHA256" \
./packaging/homebrew/generate_formula.sh > codeanalyzer-clang.rb
cat codeanalyzer-clang.rb
- name: Push formula to codellm-devkit/homebrew-tap
env:
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
VERSION: ${{ steps.ver.outputs.version }}
run: |
git clone "https://x-access-token:${TAP_TOKEN}@github.com/codellm-devkit/homebrew-tap.git" tap
mkdir -p tap/Formula
cp codeanalyzer-clang.rb tap/Formula/codeanalyzer-clang.rb
cd tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/codeanalyzer-clang.rb
git commit -m "codeanalyzer-clang ${VERSION}" || { echo "no formula change"; exit 0; }
git push