-
Notifications
You must be signed in to change notification settings - Fork 47
79 lines (75 loc) · 2.69 KB
/
release.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
---
name: Release
'on':
release:
types: [published]
permissions:
contents: read # required for github.ref to be set
jobs:
pypi:
name: Publish release on PyPI
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout alibuild
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install build dependencies # needed by our setup.py
run: python -m pip install setuptools
- name: Build the Python distribution
run: python setup.py sdist
- name: Publish distribution to PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.pypi_password }}
brew:
name: Update Homebrew formula
needs: pypi
runs-on: macos-latest
if: startsWith(github.ref, 'refs/tags/') && !github.event.release.prerelease
steps:
- name: Install prerequisites
run: brew install pipgrip
- name: Checkout Homebrew repo
run: brew tap alisw/system-deps
- name: Update alibuild formula with new version
run: |
set -x
json=$(curl -fSsL "https://pypi.org/pypi/alibuild/${GITHUB_REF#refs/tags/}/json")
sha=$(echo "$json" | jq -r '.urls[0].digests.sha256')
url=$(echo "$json" | jq -r '.urls[0].url')
# Replace keys with two leading spaces only, so we get the toplevel
# ones applying to alibuild, not those for dependencies.
sed -i.bak "
s|^ url .*| url \"$url\"|;
s|^ sha256 .*| sha256 \"$sha\"|;
s|^ version .*| version \"${GITHUB_REF#refs/tags/v}\"|
" "$(brew formula alibuild)"
rm -f "$(brew formula alibuild).bak"
- name: Regenerate alibuild formula
run: |
set -x
# Sometimes, brew update-python-resources apparently randomly fails,
# blaming pipgrip. Retries should hopefully solve this.
attempt=0
while [ $((attempt++)) -lt 5 ]; do
echo "Attempt $attempt/5..." >&2
brew update-python-resources alibuild && break
sleep 300
done
- name: Push updated formula
run: |
set -x
cd "$(dirname "$(brew formula alibuild)")"
git config user.name alibuild
git config user.email '[email protected]'
git add alibuild.rb
git commit -m "Update alibuild to ${GITHUB_REF#refs/tags/}"
git show
git push "https://alibuild:[email protected]/alisw/homebrew-system-deps" master
env:
GITHUB_TOKEN: ${{ secrets.homebrew_repo_token }}