-
Notifications
You must be signed in to change notification settings - Fork 25
109 lines (95 loc) · 3.18 KB
/
python-publish-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
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
106
107
108
109
name: Publish Python Package - PyPI
# This workflow will upload a Python Package using Twine to PyPI and create a draft release when a tag is pushed
on:
workflow_dispatch:
push:
tags:
- 'v*.*.*'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Build Package - ${{ github.ref_name }}
run: make dist
- name: Install Test Package
run: |
pip install -r requirements.txt
pip install dist/scanoss-*-py3-none-any.whl
which scanoss-py
- name: Run Local Tests
run: |
which scanoss-py
scanoss-py version
scanoss-py utils fast
scanoss-py scan tests > results.json
id_count=$(cat results.json | grep '"id":' | wc -l)
echo "ID Count: $id_count"
if [[ $id_count -lt 1 ]]; then
echo "Error: Scan test did not produce any results. Failing"
exit 1
fi
pip uninstall -y scanoss
- name: Publish Package - ${{ github.ref_name }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
# skip-existing: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Create Draft Release ${{ github.ref_type }} - ${{ github.ref_name }}
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
uses: softprops/action-gh-release@v1
with:
draft: true
files: dist/*
test:
if: success()
needs: [ deploy ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10.x'
- name: Install Remote Package
run: |
scanoss_version=$(python ./version.py)
echo "Sleeping before checking PyPI for new release version ${scanoss_version}..."
sleep 60
echo "Installing scanoss ${scanoss_version}..."
pip install --upgrade scanoss==$scanoss_version
which scanoss-py
- name: Run Tests
run: |
which scanoss-py
scanoss-py version
scanoss-py utils fast
scanoss-py scan tests > results.json
id_count=$(cat results.json | grep '"id":' | wc -l)
echo "ID Count: $id_count"
if [[ $id_count -lt 1 ]]; then
echo "Error: Scan test did not produce any results. Failing"
exit 1
fi
- name: Run Tests (fast winnowing)
run: |
pip install scanoss_winnowing
which scanoss-py
scanoss-py version
scanoss-py utils fast
scanoss-py scan tests > results.json
id_count=$(cat results.json | grep '"id":' | wc -l)
echo "ID Count: $id_count"
if [[ $id_count -lt 1 ]]; then
echo "Error: Scan test did not produce any results. Failing"
exit 1
fi