-
-
Notifications
You must be signed in to change notification settings - Fork 1
70 lines (62 loc) · 2.41 KB
/
publish_to_pypi.yml
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
name: Push project build to PyPI
on:
release:
types: [created]
workflow_dispatch:
inputs:
branch_to_build:
description: "Specify the branch you want to build"
required: false
default: $GITHUB_REF
version_to_build:
description: "Specify the version you want to build: use SEMVER format only"
required: false
default: "0.0.0.dev"
build_description:
description: "Provide a description for the build"
required: true
default: "Custom build"
jobs:
build:
runs-on: ubuntu-latest
environment: Deploy
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_KEY }}
steps:
# Check out the code from the repository
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install poetry, build, and publish via release
if: ${{ github.event_name == 'release' }}
run: |
pip install poetry
poetry self add poetry-version-plugin
latesttag=${{ github.event.release.tag_name }}
git checkout ${latesttag}
make deploy
echo "latest_tag=${latesttag}" >> $GITHUB_ENV
echo "release_description=$(echo '${{ github.event.release.body }}' | head -n 1)" >> $GITHUB_ENV
echo "current_job_status=${{ job.status }}" >> $GITHUB_ENV
- name: Install poetry, build, and publish via manual workflow dispatch
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
pip install poetry
poetry self add poetry-version-plugin
git fetch --all
git checkout ${{ github.event.inputs.branch_to_build }}
git tag ${{ github.event.inputs.version_to_build }}
make deploy
echo "latest_tag=${{ github.event.inputs.version_to_build }}" >> $GITHUB_ENV
echo "release_description=$(echo '${{ github.event.inputs.build_description }}' | head -n 1)" >> $GITHUB_ENV
echo "current_job_status=${{ job.status }}" >> $GITHUB_ENV
- name: Notify Slack of release workflow result
if: always()
uses: slackapi/[email protected]
with:
channel-id: "C05PLVB1Y04"
payload-file-path: ".github/workflows/payloads/release_payload.json"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_WORKABLE_APP_OAUTH_TOKEN }}