Skip to content

Commit

Permalink
Fix binary builds (#1491)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek authored May 14, 2024
1 parent 478d69e commit c743bf8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 75 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/build-distributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,28 +168,3 @@ jobs:
with:
name: distribution-${{ matrix.job.target }}
path: hatch-dist-${{ matrix.job.target }}.tar.gz

publish:
name: Publish distributions
if: inputs.version
needs:
- linux
- windows-macos
runs-on: ubuntu-latest

permissions:
contents: write
id-token: write

steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
path: distributions
merge-multiple: true

- name: Add assets to current release
uses: softprops/action-gh-release@v2
with:
files: |-
distributions/*
123 changes: 74 additions & 49 deletions .github/workflows/build-hatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,30 @@ jobs:
name: Build wheel and source distribution
runs-on: ubuntu-latest

outputs:
old-version: ${{ steps.version.outputs.old-version }}
version: ${{ steps.version.outputs.version }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install build frontend
run: python -m pip install --upgrade build
- name: Install tools
run: python -m pip install --upgrade build hatch

# Windows installers don't accept non-integer versions so we ubiquitously
# perform the following transformation: X.Y.Z.devN -> X.Y.Z.N
- name: Set project version
id: version
run: |-
old_version="$(hatch version)"
version="${old_version/dev/}"
echo "old-version=$old_version" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
echo "$version"
- name: Build
run: python -m build
Expand Down Expand Up @@ -86,14 +102,11 @@ jobs:
os: macos-12
use-dist: true

outputs:
version: ${{ steps.version.outputs.version }}

env:
CARGO: cargo
CARGO_BUILD_TARGET: ${{ matrix.job.target }}
PYAPP_REPO: pyapp
PYAPP_VERSION: "0.20.0"
PYAPP_VERSION: "0.20.1"
PYAPP_UV_ENABLED: "true"
PYAPP_PASS_LOCATION: "true"

Expand Down Expand Up @@ -162,7 +175,7 @@ jobs:
run: |-
echo "PYAPP_SKIP_INSTALL=true" >> $GITHUB_ENV
echo "PYAPP_FULL_ISOLATION=true" >> $GITHUB_ENV
echo "PYAPP_DISTRIBUTION_SOURCE=${{ env.DIST_URL }}/hatch-${{ github.ref_name }}/hatch-dist-${{ matrix.job.target }}.tar.gz" >> $GITHUB_ENV
echo "PYAPP_DISTRIBUTION_SOURCE=${{ env.DIST_URL }}/hatch-v${{ needs.python-artifacts.outputs.version }}/hatch-dist-${{ matrix.job.target }}.tar.gz" >> $GITHUB_ENV
echo "PYAPP_DISTRIBUTION_PYTHON_PATH=${{ startsWith(matrix.job.os, 'windows-') && 'python\\python.exe' || 'python/bin/python3' }}" >> $GITHUB_ENV
# Disable in the case of self updates
Expand All @@ -171,13 +184,10 @@ jobs:
- name: Build binary
run: hatch build --target binary

# Windows installers don't accept non-integer versions so we ubiquitously
# perform the following transformation: X.Y.Z.devN -> X.Y.Z.N
- name: Set project version
id: version
- name: Correct binary version
run: |-
old_version="$(hatch version)"
version="${old_version/dev/}"
old_version="${{ needs.python-artifacts.outputs.old-version }}"
version="${{ needs.python-artifacts.outputs.version }}"
if [[ "$version" != "$old_version" ]]; then
cd dist/binary
Expand All @@ -186,9 +196,6 @@ jobs:
mv "$old_binary" "$binary"
fi
echo "version=$version" >> $GITHUB_OUTPUT
echo "$version"
- name: Archive binary
run: |-
mkdir packaging
Expand Down Expand Up @@ -226,11 +233,13 @@ jobs:
windows-packaging:
name: Build Windows installers
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
needs: binaries
needs:
- binaries
- python-artifacts
runs-on: windows-2022

env:
VERSION: ${{ needs.binaries.outputs.version }}
VERSION: ${{ needs.python-artifacts.outputs.version }}

steps:
- name: Checkout code
Expand Down Expand Up @@ -306,11 +315,13 @@ jobs:
macos-packaging:
name: Build macOS installer and sign/notarize artifacts
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
needs: binaries
needs:
- binaries
- python-artifacts
runs-on: macos-12

env:
VERSION: ${{ needs.binaries.outputs.version }}
VERSION: ${{ needs.python-artifacts.outputs.version }}
NOTARY_WAIT_TIME: "3600" # 1 hour

steps:
Expand Down Expand Up @@ -475,26 +486,63 @@ jobs:
path: signed/${{ steps.pkg.outputs.path }}
if-no-files-found: error

publish-project:
name: Publish release artifacts
publish-pypi:
name: Publish to PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
needs: python-artifacts
runs-on: ubuntu-latest

steps:
- name: Download Python artifacts
uses: actions/download-artifact@v4
with:
name: python-artifacts
path: dist

- name: Push Python artifacts to PyPI
uses: pypa/gh-action-pypi-publish@v1.8.14
with:
skip-existing: true

distributions-release:
name: Build release distributions
needs:
- python-artifacts
- publish-pypi
if: startsWith(github.event.ref, 'refs/tags')
uses: ./.github/workflows/build-distributions.yml
with:
version: ${{ needs.python-artifacts.outputs.version }}

distributions-dev:
name: Build development distributions
if: ${{ !startsWith(github.event.ref, 'refs/tags') }}
uses: ./.github/workflows/build-distributions.yml
# This actually does not need the binary jobs but we want to prioritize
# resources for the test jobs therefore this forces these later on
needs: binaries

publish-release:
name: Publish distributions
if: startsWith(github.event.ref, 'refs/tags')
needs:
- binaries
- windows-packaging
- macos-packaging
- distributions-release
runs-on: ubuntu-latest

permissions:
contents: write
id-token: write

steps:
- name: Download Python artifacts
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-artifacts
path: dist
pattern: distribution-*
path: distributions
merge-multiple: true

- name: Download binaries
uses: actions/download-artifact@v4
Expand All @@ -515,28 +563,5 @@ jobs:
with:
files: |-
archives/*
distributions/*
installers/*
- name: Push Python artifacts to PyPI
uses: pypa/gh-action-pypi-publish@v1.8.14
with:
skip-existing: true

distributions-release:
name: Build release distributions
needs:
- binaries
- publish-project
if: startsWith(github.event.ref, 'refs/tags')
uses: ./.github/workflows/build-distributions.yml
with:
version: ${{ needs.binaries.outputs.version }}
secrets: inherit

distributions-dev:
name: Build development distributions
if: ${{ !startsWith(github.event.ref, 'refs/tags') }}
uses: ./.github/workflows/build-distributions.yml
# This actually does not need the binary jobs but we want to prioritize
# resources for the test jobs therefore this forces these later on
needs: binaries
2 changes: 1 addition & 1 deletion docs/history/hatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

***Added:***

- Upgrade PyApp to 0.20.0 for binary builds
- Upgrade PyApp to 0.20.1 for binary builds

***Fixed:***

Expand Down

0 comments on commit c743bf8

Please sign in to comment.