-
Notifications
You must be signed in to change notification settings - Fork 25
144 lines (127 loc) · 4.38 KB
/
python-publish-pypi.yml
File metadata and controls
144 lines (127 loc) · 4.38 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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*.*.*"
env:
SCANOSS_API_KEY: ${{ secrets.SC_API_KEY }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9.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 Unit Tests
run: |
make unit_test
- 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
scanoss-py wfp --skip-headers tests > fingers.wfp
wfp_count=$(cat fingers.wfp | grep 'file=' | wc -l)
echo "WFP Count: $wfp_count"
if [[ $wfp_count -lt 1 ]]; then
echo "Error: WFP 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.9.x'
- name: Install Remote Package
uses: nick-fields/retry@v3
with:
timeout_minutes: 3
retry_wait_seconds: 10
max_attempts: 3
retry_on: error
command: |
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
scanoss-py wfp --skip-headers tests > fingers.wfp
wfp_count=$(cat fingers.wfp | grep 'file=' | wc -l)
echo "WFP Count: $wfp_count"
if [[ $wfp_count -lt 1 ]]; then
echo "Error: WFP 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
scanoss-py wfp --skip-headers tests > fingers.wfp
wfp_count=$(cat fingers.wfp | grep 'file=' | wc -l)
echo "WFP Count: $wfp_count"
if [[ $wfp_count -lt 1 ]]; then
echo "Error: WFP test did not produce any results. Failing"
exit 1
fi