-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (47 loc) · 1.38 KB
/
build_and_publish.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
name: Build and Publish
on: push
permissions:
contents: write
jobs:
build-extension:
runs-on: ubuntu-24.04
env:
VERSION: ""
SHORT_COMMIT: ""
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install package
run: pip install .
- name: Extract commit metadata
run: |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "SHORT_COMMIT=$(echo ${GITHUB_SHA} | cut -c1-6)" >> $GITHUB_ENV
- name: Build
run: |
pip install build
python3 -m build
- uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ env.SHORT_COMMIT }}
path: dist/
retention-days: 7
- name: Upload to PYPI
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: __token__ # PyPI uses this username for API tokens
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
pip install twine
python3 -m twine upload dist/*
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
tag_name: ${{ env.VERSION }}
files: dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}