-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (84 loc) · 2.92 KB
/
package.yaml
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
93
94
95
name: Package and Release
on:
workflow_dispatch:
inputs:
release_notes:
required: false
description: 'Override release notes (default uses tag body).'
release_version:
required: false
description: 'Override `github.ref_name`. Must be semver.'
jobs:
release:
runs-on: ubuntu-latest
permissions: write-all
steps:
# NOTE: https://github.com/actions/download-artifact
- name: Checkout.
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Ensure Python is Installed.
uses: actions/setup-python@v4
with:
python-version: '3.11'
# NOTE Check that the ref matches semver.
- name: Verify Ref.
id: release-ref-verify
run: |
release_name=$(
python3 ./scripts/validate_ref_name.py \
'${{ github.event.inputs.release_version }}' \
'${{ github.ref_name }}'
)
echo "CAPTURA_RELEASE_NAME=$release_name" >> $GITHUB_ENV
- name: Get Body.
id: release-get-body
run: |
release_notes='${{ github.event.inputs.release_notes }}'
if [[ ! $release_notes ]];
then
tag_body=$( git tag -l --format='%(contents:body)' '${{ github.ref_name }}' )
echo "CAPTURA_RELEASE_NOTES=$tag_body" >> $GITHUB_ENV
else
echo "CAPTURA_RELEASE_NOTES=$release_notes" >> $GITHUB_ENV
fi
- name: Cache Pip
uses: actions/cache@v3
id: release-venv
with:
path: .venv
key: ${{ runner.os }}-venv-release
- name: Install Dependencies.
id: release-depends
run: |
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install twine poetry
- name: Build and Verify.
id: release-build-and-verify
run: |
source .venv/bin/activate
echo "## Build\n\n~~~stdout" >> $GITHUB_STEP_SUMMARY
poetry build >> $GITHUB_STEP_SUMMARY
echo "~~~\n\n## Twine Check\n\n~~~stdout" >> $GITHUB_STEP_SUMMARY
python3 -m twine check dist/* >> $GITHUB_STEP_SUMMARY
echo "~~~" >> $GITHUB_STEP_SUMMARY
- name: Publish to PyPI.
id: release-publish
run: |
source .venv/bin/activate
poetry config repositories.pypi pypi.org
poetry config pypi-token.pypi '${{ secrets.PYPI_TOKEN }}'
poetry publish
- name: Create Release
id: release-create
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref_name }}
release_name: v${{ github.CAPTURA_RELEASE_NAME }}
body: ${{ env.CAPTURA_RELEASE_NOTES }}
draft: false
prerelease: false