Skip to content

Commit

Permalink
Fix PyPI URL for Homebrew formula updates
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelLipski committed Apr 20, 2024
1 parent 2a8ed18 commit cbd9cf9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
8 changes: 6 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ jobs:
# Side effects: does an actual release, but to the test PyPI
command: bash ci/pypi/ci-deploy.sh --dry-run

- run:
name: 'Wait up to 10 minutes for Test PyPI package to be available'
command: bash ci/pypi/ci-wait-for-package.sh test.pypi.org 10

- run:
name: '[Dry run] Update Homebrew with local installation test'
# Prerequisites: artifacts must be released to test PyPI first
Expand Down Expand Up @@ -269,8 +273,8 @@ jobs:
- run:
# See https://github.com/Homebrew/homebrew-core/pull/119200/commits/a4902911fadbdcf2c6b64ce691024ff97a516f1c
# for a case where the package wasn't available right after the upload and Homebrew Core build failed.
name: 'Wait up to 30 minutes for PyPI package to be available'
command: bash ci/pypi/ci-wait-for-package.sh pypi.org 30
name: 'Wait up to 10 minutes for PyPI package to be available'
command: bash ci/pypi/ci-wait-for-package.sh pypi.org 10
- run:
name: 'Update Homebrew formula'
command: bash ci/homebrew/ci-deploy.sh
Expand Down
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release notes

## New in git-machete 3.25.2

- fixed: Homebrew deploys

## New in git-machete 3.25.1

- fixed: `git machete git{hub,lab} restack-{pr,mr}` now first retargets, then pushes (so that certain CIs see the correct base branch in env vars)
Expand Down
13 changes: 3 additions & 10 deletions ci/homebrew/ci-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,17 @@ brew --version

version=$(cut -d\' -f2 git_machete/__init__.py)

function pypi_metadata_json() {
curl -s "https://$pypi_host/pypi/git-machete/$version/json" | jq '.urls | map(select(.packagetype == "sdist")) | .[0]'
}

if [[ ${1-} == "--dry-run" || ${CIRCLE_BRANCH-} != "master" ]]; then
do_push=false
pypi_host=test.pypi.org
# For some reason, sometimes the package doesn't get advertised under .../packages/source/g/git-machete/... URL within a reasonable time.
url=$(pypi_metadata_json | jq --raw-output .url)
else
do_push=true
pypi_host=pypi.org
# Do not use https://*files.pythonhosted.org/... URLs (the ones coming from the JSON above) for actual formula updates,
# see https://github.com/orgs/Homebrew/discussions/5193
url="https://$pypi_host/packages/source/g/git-machete/git-machete-$version.tar.gz"
fi

sha256=$(pypi_metadata_json | jq --raw-output .digests.sha256)
pypi_metadata_json=$(curl -s "https://$pypi_host/pypi/git-machete/$version/json" | jq '.urls | map(select(.packagetype == "sdist")) | .[0]')
url=$(echo "$pypi_metadata_json" | jq --raw-output .url)
sha256=$(echo "$pypi_metadata_json" | jq --raw-output .digests.sha256)

# We need to run `brew tap homebrew/core` manually because:
# 1. the formula files need to be present at .../.linuxbrew/Homebrew/Library/Taps/... -
Expand Down
10 changes: 5 additions & 5 deletions ci/pypi/ci-wait-for-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
set -e -o pipefail -u

host=$1
timeout_minutes=${2-30}
timeout_minutes=${2-10}
version=$(cut -d\' -f2 git_machete/__init__.py)
url=https://$host/packages/source/g/git-machete/git-machete-$version.tar.gz
url=https://$host/pypi/git-machete/$version/json

# Typically just 2 minutes of waiting are enough.
for i in $(seq 1 "$timeout_minutes"); do
echo "Checking package availability at $url, attempt #$i out of $timeout_minutes..."
if curl --fail --location --silent --show-error --output /dev/null "$url"; then
echo "Package available at $url"
if curl --fail --location --silent --show-error "$url"; then
echo "Package metadata available at $url"
exit 0
fi
sleep 60
done

echo "Package still not published after $timeout_minutes attempts"
echo "Package still not published after $timeout_minutes minutes"
exit 1
4 changes: 2 additions & 2 deletions docs/man/git-machete.1
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "GIT-MACHETE" "1" "Apr 19, 2024" "" "git-machete"
.TH "GIT-MACHETE" "1" "Apr 20, 2024" "" "git-machete"
.SH NAME
git-machete \- git-machete 3.25.1
git-machete \- git-machete 3.25.2
.sp
git machete is a robust tool that \fBsimplifies your git workflows\fP\&.
.sp
Expand Down
2 changes: 1 addition & 1 deletion git_machete/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.25.1'
__version__ = '3.25.2'

0 comments on commit cbd9cf9

Please sign in to comment.