Skip to content

Commit

Permalink
Auto-publish releases to Homebrew (#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoWilken committed Nov 4, 2021
1 parent caf625d commit 61a6396
Showing 1 changed file with 47 additions and 17 deletions.
64 changes: 47 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,57 @@ on:
release:
types: [published]
jobs:
build_release:
pypi:
name: Build aliBuild release and publish it on Pypi
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@master
- name: Set up Python 3.7
- name: Checkout alibuild
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Replace the tag in the setup.py
run: >-
GITHUB_TAG=`echo $GITHUB_REF | cut -f3 -d/` ;
echo $GITHUB_TAG ;
perl -p -i -e "s/LAST_TAG/$GITHUB_TAG/g" alibuild_helpers/__init__.py
- name: Build the python distribution
run: >-
python setup.py sdist
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
python-version: 3.9
- name: Replace the hard-coded version number
run: sed -i "s/LAST_TAG/${GITHUB_REF#refs/tags/}/g" alibuild_helpers/__init__.py
- name: Build the Python distribution
run: python setup.py sdist
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.pypi_password }}

brew:
name: Update alibuild Homebrew formula
needs: pypi
runs-on: macos-latest
if: startsWith(github.ref, 'refs/tags/') && !github.event.release.prerelease
steps:
- name: Checkout Homebrew repo
run: brew tap alisw/system-deps
- name: Update alibuild formula with new version
run: |
set -x
cd "$(dirname "$(brew formula alibuild)")"
IFS=$'\n' read -r sha url < \
<(curl -fSsL "https://pypi.org/pypi/alibuild/${GITHUB_REF#refs/tags/}/json" |
jq -r '.urls[0] | (.digests.sha256, .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}\"/
" alibuild.rb
rm -f alibuild.rb.bak
brew update-python-resources alibuild
- name: Push updated formula
run: |
set -x
cd "$(dirname "$(brew formula alibuild)")"
git add alibuild.rb
git commit -m "Update alibuild to ${GITHUB_REF#refs/tags/}"
git show
git push https://alibuild:$GITHUB_TOKEN@github.com/alisw/homebrew-system-deps master
env:
GITHUB_TOKEN: ${{ secrets.homebrew_repo_token }}

0 comments on commit 61a6396

Please sign in to comment.