diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2c9bb9e9..c5ec68a9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }}