diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f8e203b2..7404a8ef 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -19,6 +19,11 @@ on: type: boolean required: true default: true + include_brew: + description: 'Publish to Homebrew?' + type: boolean + required: true + default: true jobs: validate: @@ -107,3 +112,111 @@ jobs: run: | pypi_version="$(find dist/jrnl-*.tar.gz | sed -r 's!dist/jrnl-(.*)\.tar\.gz!\1!')" echo "pypi_version=$pypi_version" >> "$GITHUB_OUTPUT" + + release_homebrew: + if: ${{ github.event.inputs.include_brew == 'true' }} + needs: release_pypi + name: "Release to Homebrew" + runs-on: macos-latest + env: + HOMEBREW_NO_AUTO_UPDATE: 1 + HOMEBREW_NO_INSTALL_CLEANUP: 1 + HOME_REPO: ${{ secrets.HOME_REPO }} + steps: + - name: Get version + run: | + JRNL_VERSION="${{ github.event.inputs.version }}" + PYPI_VERSION="${{ needs.release_pypi.outputs.pypi_version }}" + + echo "::debug::jrnl version: $JRNL_VERSION" + echo "::debug::pypi version: $PYPI_VERSION" + + echo "JRNL_VERSION=$JRNL_VERSION" >> "$GITHUB_ENV" + echo "PYPI_VERSION=$PYPI_VERSION" >> "$GITHUB_ENV" + + - name: Set env variables + env: + REPO_OWNER: ${{ github.repository_owner }} + run: | + if [[ $JRNL_VERSION =~ (alpha|beta) ]]; then + echo '::debug::Prerelease (not a full release)' + { + echo "RELEASE_TYPE=pre" + echo "FORMULA_REPO=${REPO_OWNER}/homebrew-prerelease" + echo "BOT_REPO=jrnl-bot/homebrew-prerelease" + echo "FORMULA_NAME=jrnl-beta" + } >> "$GITHUB_ENV" + else + echo '::debug::Full release (not a prerelease)' + if [[ "${{ github.repository }}" == "${HOME_REPO}" ]]; then + REPO_OWNER="homebrew" + fi + { + echo "RELEASE_TYPE=full" + echo "FORMULA_REPO=${REPO_OWNER}/homebrew-core" + echo "BOT_REPO=jrnl-bot/homebrew-core" + echo "FORMULA_NAME=jrnl" + } >> "$GITHUB_ENV" + fi + + - name: Tap formula + run: | + brew tap "${FORMULA_REPO}" + echo '::debug::Set tap directory' + echo "BREW_TAP_DIRECTORY=$(brew --repo "${FORMULA_REPO}")" >> "$GITHUB_ENV" + - name: Install dependencies + run: brew install pipgrip + + - name: Query PyPI API + uses: nick-invision/retry@v3 + with: + timeout_seconds: 10 + max_attempts: 30 + retry_wait_seconds: 10 + command: | + curl -Ls https://pypi.org/pypi/jrnl/json > api_response.json + # if query doesn't have our version yet, give it some time before trying again + if [[ "null" == "$(jq ".releases[\"${PYPI_VERSION}\"][1].url" -r api_response.json)" ]]; then + echo "::debug::PYPI_VERSION: $PYPI_VERSION" + echo "::debug::JQ VALUE: $(jq ".releases[\"${PYPI_VERSION}\"][1].url" -r api_response.json)" + echo "::group::cat api_response.json" + cat api_response.json + echo "::endgroup::" + exit 1 + fi + + - name: Update Homebrew Formula + uses: nick-invision/retry@v3 + with: + timeout_minutes: 8 + max_attempts: 6 + retry_wait_seconds: 30 + command: > + brew bump-formula-pr "${FORMULA_NAME}" + --url $(jq ".releases[\"${PYPI_VERSION}\"][1].url" -r api_response.json) + --sha256 $(jq ".releases[\"${PYPI_VERSION}\"][1].digests.sha256" -r api_response.json) + --no-audit + --write-only + --force + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + path: ${{ env.BREW_TAP_DIRECTORY }} + token: ${{ secrets.JRNL_BOT_TOKEN }} + push-to-fork: ${{ env.BOT_REPO }} + + committer: ${{ secrets.JRNL_BOT_NAME }} <${{ secrets.JRNL_BOT_EMAIL }}> + author: ${{ secrets.JRNL_BOT_NAME }} <${{ secrets.JRNL_BOT_EMAIL }}> + + title: jrnl ${{ env.JRNL_VERSION }} + body: Created with `brew bump-formula-pr` + + branch: jrnl-${{ env.JRNL_VERSION }}-- + branch-suffix: random + commit-message: | + jrnl ${{ env.JRNL_VERSION }} + + Update jrnl to ${{ env.JRNL_VERSION }} + + ${{ secrets.RELEASE_COAUTHORS }} diff --git a/CHANGELOG.md b/CHANGELOG.md index ba714328..1c4c456f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,15 +4,6 @@ [Full Changelog](https://github.com/jrnl-org/jrnl/compare/v4.2.1...HEAD) -**Fixed bugs:** - -- poetry warning - "poetry.dev-dependencies" section is deprecated [\#1975](https://github.com/jrnl-org/jrnl/issues/1975) -- Homebrew autobump error on jrnl release [\#1961](https://github.com/jrnl-org/jrnl/issues/1961) - -**Build:** - -- Remove release step to publish to Homebrew [\#1994](https://github.com/jrnl-org/jrnl/pull/1994) ([micahellison](https://github.com/micahellison)) - **Packaging:** - Update dependency rich to v14 [\#1989](https://github.com/jrnl-org/jrnl/pull/1989) ([renovate[bot]](https://github.com/apps/renovate)) diff --git a/poetry.lock b/poetry.lock index 3d5ab9a2..34233dad 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand. [[package]] name = "asttokens" @@ -1146,14 +1146,14 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "poethepoet" -version = "0.35.0" -description = "A task runner that works well with poetry and uv." +version = "0.34.0" +description = "A task runner that works well with poetry." optional = false python-versions = ">=3.9" groups = ["dev"] files = [ - {file = "poethepoet-0.35.0-py3-none-any.whl", hash = "sha256:bed5ae1fd63f179dfa67aabb93fa253d79695c69667c927d8b24ff378799ea75"}, - {file = "poethepoet-0.35.0.tar.gz", hash = "sha256:b396ae862d7626e680bbd0985b423acf71634ce93a32d8b5f38340f44f5fbc3e"}, + {file = "poethepoet-0.34.0-py3-none-any.whl", hash = "sha256:c472d6f0fdb341b48d346f4ccd49779840c15b30dfd6bc6347a80d6274b5e34e"}, + {file = "poethepoet-0.34.0.tar.gz", hash = "sha256:86203acce555bbfe45cb6ccac61ba8b16a5784264484195874da457ddabf5850"}, ] [package.dependencies]