|
20 | 20 | - name: Install dependencies |
21 | 21 | run: | |
22 | 22 | python -m pip install --upgrade pip |
| 23 | + python -m pip install --upgrade hatch |
| 24 | +
|
| 25 | + - name: Build Release |
| 26 | + run: | |
| 27 | + hatch -v build -t wheel:standard -t sdist:standard |
| 28 | +
|
| 29 | + - name: Set File Names and Release IDs |
| 30 | + run: | |
| 31 | + src_file=( ./dist/*.tar.gz ) |
| 32 | + wheel_file=( ./dist/*.whl ) |
| 33 | + echo "RELEASE_ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH)" >> $GITHUB_ENV |
| 34 | + echo "SOURCE_DIST_FILE=$(basename $src_file)" >> $GITHUB_ENV |
| 35 | + echo "WHEEL_FILE=$(basename $wheel_file)" >> $GITHUB_ENV |
| 36 | +
|
| 37 | + - name: Set Upload Url |
| 38 | + run: | |
| 39 | + echo "UPLOAD_URL=https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets{?name,label}" >> $GITHUB_ENV |
| 40 | +
|
| 41 | + - name: Output Variables For Uploading |
| 42 | + id: get_upload_vars |
| 43 | + run: | |
| 44 | + echo "Release ID: $RELEASE_ID" |
| 45 | + echo "Source Dist File: $SOURCE_DIST_FILE" |
| 46 | + echo "Source Dist Upload Url: $SOURCE_DIST_URL" |
| 47 | + echo "Wheel File: $WHEEL_FILE" |
| 48 | + echo "Upload Url: $UPLOAD_URL" |
| 49 | + echo "::set-output name=source_dist_path::./dist/${SOURCE_DIST_FILE}" |
| 50 | + echo "::set-output name=source_dist_name::${SOURCE_DIST_FILE}" |
| 51 | + echo "::set-output name=wheel_path::./dist/${WHEEL_FILE}" |
| 52 | + echo "::set-output name=wheel_name::./dist/${WHEEL_FILE}" |
| 53 | + echo "::set-output name=upload_url::${UPLOAD_URL}" |
| 54 | +
|
| 55 | + - name: Upload Source Distribution to GitHub release |
| 56 | + |
| 57 | + env: |
| 58 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + with: |
| 60 | + upload_url: ${{ steps.get_upload_vars.outputs.upload_url }} |
| 61 | + asset_path: ${{ steps.get_upload_vars.outputs.source_dist_path }} |
| 62 | + asset_name: ${{ steps.get_upload_vars.outputs.source_dist_name }} |
| 63 | + asset_content_type: application/x-gzip |
| 64 | + |
| 65 | + - name: Upload Wheel to GitHub Release |
| 66 | + |
| 67 | + env: |
| 68 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + with: |
| 70 | + upload_url: ${{ steps.get_upload_vars.outputs.upload_url }} |
| 71 | + asset_path: ${{ steps.get_upload_vars.outputs.wheel_path }} |
| 72 | + asset_name: ${{ steps.get_upload_vars.outputs.wheel_name }} |
| 73 | + asset_content_type: application/zip |
| 74 | + |
| 75 | + - name: Publish Build to PyPI |
| 76 | + env: |
| 77 | + HATCH_INDEX_USER: '__token__' |
| 78 | + HATCH_INDEX_AUTH: ${{ secrets.PYPI_ACCESS_TOKEN }} |
| 79 | + run: | |
| 80 | + hatch publish dist/* |
0 commit comments