From 56427de983cb5b12d36aa4324dcb7f87c76b5a13 Mon Sep 17 00:00:00 2001 From: Jan Willhaus Date: Wed, 31 Jan 2024 22:46:16 +0100 Subject: [PATCH] build: Publish brew formula --- .github/workflows/publish.yaml | 54 ++++++++++++++++++++++++++++++++++ brew/template.rb.j2 | 25 ++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 brew/template.rb.j2 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 597f7b5..d9fb9a3 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -4,6 +4,8 @@ on: push: tags: - "v*.*.*" + branches: + - "publish-to-brew-tap" #FIXME: REMOVE pull_request: jobs: @@ -45,3 +47,55 @@ jobs: - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + + homebrew: + if: github.event_name == 'push' # && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + environment: release + needs: build + steps: + - uses: actions/checkout@v4 + with: + repository: janw/homebrew-tap + + - uses: actions/checkout@v4 + with: + path: '_podcast-archiver' + + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v6 + id: gpg-import + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + fingerprint: 2B939A343491740FE1483E5C41E311388E4BB349 + + - name: List keys + run: gpg -K + + - name: Install poetry + poetry-brew + run: | + pipx install 'poetry>=1.7.0' + pipx inject poetry poetry-homebrew-formula + + - name: Update formula + shell: bash + run: | + poetry homebrew-formula -C _podcast-archiver/ \ + --verbose \ + --template _podcast-archiver/brew/template.rb.j2 \ + --output ./Formula/podcast-archiver.rb + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + add-paths: | + Formula/* + commit-message: "bump(podcast-archiver): ${{github.ref_name}}" + title: "bump(podcast-archiver): ${{github.ref_name}}" + body: "" + token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }} + push-to-fork: janw-bot/homebrew-tap + committer: Jan Willhaus [bot] diff --git a/brew/template.rb.j2 b/brew/template.rb.j2 new file mode 100644 index 0000000..625afe6 --- /dev/null +++ b/brew/template.rb.j2 @@ -0,0 +1,25 @@ +class {{ formula_name }} < Formula + include Language::Python::Virtualenv + + desc "{{ package.description }}" +{% if package.homepage %} homepage "{{ package.homepage }}" +{% endif %} +{% if package.license %} license "{{ package.license }}" +{% endif %} + +{{ PACKAGE_URL }} + + depends_on "python3" + depends_on "rust" => :build + +{{ RESOURCES }} + + def install + virtualenv_create(libexec, "python3") + virtualenv_install_with_resources + end + + test do + false + end +end