-
Notifications
You must be signed in to change notification settings - Fork 5
92 lines (79 loc) · 3.07 KB
/
publish.yml
File metadata and controls
92 lines (79 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: publish
on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Ensure latest pip
run: python -m pip install --upgrade pip
- name: Install click
run: pip install click===8.1.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade hatch
- name: Build Release
run: |
hatch -v build -t wheel:standard -t sdist:standard
- name: Set File Names and Release IDs
run: |
src_file=( ./dist/*.tar.gz )
wheel_file=( ./dist/*.whl )
echo "RELEASE_ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "SOURCE_DIST_FILE=$(basename $src_file)" >> $GITHUB_ENV
echo "WHEEL_FILE=$(basename $wheel_file)" >> $GITHUB_ENV
- name: Set Upload Url
run: |
echo "UPLOAD_URL=https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets{?name,label}" >> $GITHUB_ENV
- name: Output Variables For Uploading
id: get_upload_vars
run: |
echo "Release ID: $RELEASE_ID"
echo "Source Dist File: $SOURCE_DIST_FILE"
echo "Source Dist Upload Url: $SOURCE_DIST_URL"
echo "Wheel File: $WHEEL_FILE"
echo "Upload Url: $UPLOAD_URL"
echo "::set-output name=source_dist_path::./dist/${SOURCE_DIST_FILE}"
echo "::set-output name=source_dist_name::${SOURCE_DIST_FILE}"
echo "::set-output name=wheel_path::./dist/${WHEEL_FILE}"
echo "::set-output name=wheel_name::./dist/${WHEEL_FILE}"
echo "::set-output name=upload_url::${UPLOAD_URL}"
- name: Upload Source Distribution to GitHub release
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_upload_vars.outputs.upload_url }}
asset_path: ${{ steps.get_upload_vars.outputs.source_dist_path }}
asset_name: ${{ steps.get_upload_vars.outputs.source_dist_name }}
asset_content_type: application/x-gzip
- name: Upload Wheel to GitHub Release
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_upload_vars.outputs.upload_url }}
asset_path: ${{ steps.get_upload_vars.outputs.wheel_path }}
asset_name: ${{ steps.get_upload_vars.outputs.wheel_name }}
asset_content_type: application/zip
- name: Publish Build to PyPI
env:
HATCH_INDEX_USER: '__token__'
HATCH_INDEX_AUTH: ${{ secrets.PYPI_ACCESS_TOKEN }}
run: |
hatch publish dist/*
- name: Notify Slack Action
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()