-
Notifications
You must be signed in to change notification settings - Fork 9
105 lines (87 loc) · 3.01 KB
/
Copy pathdocker.yml
File metadata and controls
105 lines (87 loc) · 3.01 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
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Publish Python Package
on:
push:
branches:
- main
- actions
jobs:
unit_tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest
- name: Run unit tests
run: |
python -m pytest tests/unit -q
- name: Run pipeline smoke tests
run: |
python -m pytest tests/pipeline -q
publish_package:
name: Build and Publish
runs-on: ubuntu-latest
needs: unit_tests
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install build tools
run: |
pip install setuptools wheel twine
- name: Extract version info
id: version
run: |
VERSION=$(python setup.py --version)
PACKAGE_NAME=$(python setup.py --name)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
- name: Build package
env:
FLASH_ATTENTION_SKIP_CUDA_BUILD: "TRUE"
run: |
python setup.py sdist bdist_wheel --dist-dir=dist
- name: Check if version exists on PyPI
id: check-pypi
run: |
VERSION="${{ steps.version.outputs.version }}"
PACKAGE="${{ steps.version.outputs.package_name }}"
EXISTS=$(curl --silent -f https://pypi.org/pypi/${PACKAGE}/${VERSION}/json > /dev/null && echo "yes" || echo "no")
echo "exists=$EXISTS" >> "$GITHUB_OUTPUT"
- name: Upload to PyPI
if: steps.check-pypi.outputs.exists == 'no'
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/*
- name: Check if GitHub Release exists
id: check-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="v${{ steps.version.outputs.version }}"
EXISTS=$(gh release view "$TAG" > /dev/null 2>&1 && echo "yes" || echo "no")
echo "exists=$EXISTS" >> $GITHUB_OUTPUT
- name: Create GitHub Release
if: steps.check-release.outputs.exists == 'no'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create v${{ steps.version.outputs.version }} dist/* \
--title "Release v${{ steps.version.outputs.version }}" \
--notes "Automated release from GitHub Actions"
- name: Debug Info (optional)
run: |
echo "Package: ${{ steps.version.outputs.package_name }}"
echo "Version: ${{ steps.version.outputs.version }}"
echo "PyPI Exists: ${{ steps.check-pypi.outputs.exists }}"
echo "GitHub Release Exists: ${{ steps.check-release.outputs.exists }}"