-
-
Notifications
You must be signed in to change notification settings - Fork 23
103 lines (98 loc) · 3.51 KB
/
Publish.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
96
97
98
99
100
101
102
103
---
name: Publish
on: workflow_call
jobs:
Publish_PIP:
runs-on: ubuntu-latest
# permissions:
# id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Branch Name
run: |
branchname=$(git rev-parse --abbrev-ref HEAD)
echo "branchname=$branchname" >> "$GITHUB_ENV"
- name: Determine if this is a release branch
run: |
isrelease=0
if [[ $branchname =~ v[0-9]\. ]]; then
isrelease=1
fi
echo "isrelease=$isrelease" >> "$GITHUB_ENV"
- name: Check Milestone
if: ${{ env.isrelease == 1 }}
shell: python
# https://api.github.com/repos/damies13/rfswarm/milestones
run: |
import os
import requests
branchname = os.getenv("branchname")
print("branchname:", branchname)
milestones = requests.get('https://api.github.com/repos/damies13/rfswarm/milestones')
dopublish = 0
for ms in milestones.json():
print(ms['title'])
if ms['title'] == branchname:
print(ms)
open_issues = ms['open_issues']
closed_issues = ms['closed_issues']
total_issues = open_issues + closed_issues
print('open', open_issues, 'closed', closed_issues, 'total', total_issues)
pct = (closed_issues/total_issues) * 100
print(pct, "%")
if pct == 100:
dopublish = 1
print('dopublish', dopublish)
env_file = os.getenv('GITHUB_ENV')
with open(env_file, "a") as myfile:
myfile.write("dopublish={}\n".format(dopublish))
- name: Echo Vars
run: |
echo branchname: ${{ env.branchname }}
echo isrelease: ${{ env.isrelease }}
echo dopublish : ${{ env.dopublish }}
- name: Apt Update
if: ${{ env.dopublish == 1 }}
run: |
sudo apt update -y
- name: Setup Python
if: ${{ env.dopublish == 1 }}
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: PIP Install
if: ${{ env.dopublish == 1 }}
run: pip install --upgrade build setuptools twine wheel
- name: Download packages to dist
if: ${{ env.dopublish == 1 }}
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Show Dist UM
if: ${{ env.dopublish == 1 && matrix.platform != 'windows-latest' }}
run: |
ls -la dist
- name: Show Dist W
if: ${{ env.dopublish == 1 && matrix.platform == 'windows-latest' }}
run: |
dir dist
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
# Still need to have a check all the milestones are complete
- name: Do Publish
if: ${{ env.dopublish == 1 }}
# https://github.com/pypa/gh-action-pypi-publish?tab=readme-ov-file#specifying-a-different-username
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# verbose: true
# password: ${{ secrets.PYPI_TOKEN }}
env:
# PYPI_USER: ${{ secrets.PYPI_TOKENU }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
echo ${#PYPI_TOKEN}
echo python3 -m twine upload -u __token__ -p ${{ secrets.PYPI_TOKEN }} --verbose dist/rfswarm*