-
-
Notifications
You must be signed in to change notification settings - Fork 2k
189 lines (156 loc) · 6.72 KB
/
cd-syftcli.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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: CD - Syft-CLI
on:
schedule:
- cron: "00 10 * * */7" # At 10:00 UTC on every three days
workflow_dispatch:
inputs:
skip_tests:
description: "If true, skip tests"
required: false
default: "false"
jobs:
call-pr-tests-linting:
if: github.repository == 'OpenMined/PySyft' && (github.event.inputs.skip_tests == 'false' || github.event_name == 'schedule') # don't run on forks
uses: OpenMined/PySyft/.github/workflows/pr-tests-linting.yml@dev
# call-pr-tests-syft:
# if: github.repository == 'OpenMined/PySyft' && (github.event.inputs.skip_tests == 'false' || github.event_name == 'schedule') # don't run on forks
# uses: OpenMined/PySyft/.github/workflows/pr-tests-syft.yml@dev
# call-pr-tests-stack:
# if: github.repository == 'OpenMined/PySyft' && (github.event.inputs.skip_tests == 'false' || github.event_name == 'schedule') # don't run on forks
# uses: OpenMined/PySyft/.github/workflows/pr-tests-stack.yml@dev
# secrets: inherit
deploy-syft-cli:
needs: [call-pr-tests-linting]
if: always() && (needs.call-pr-tests-linting.result == 'success' || github.event.inputs.skip_tests == 'true')
runs-on: ubuntu-latest
outputs:
deployed_version: ${{ steps.bump-version.outputs.deployed_version }}
current_hash: ${{ steps.get-hashes.outputs.current_hash }}
previous_hash: ${{ steps.get-hashes.outputs.previous_hash }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.SYFT_BOT_COMMIT_TOKEN }}
- name: Install checksumdir
run: |
pip install --upgrade checksumdir
- name: Get the hashes
id: get-hashes
shell: bash
run: |
echo "current_hash=$(checksumdir ./packages/syftcli/syftcli -e version.py)" >> $GITHUB_OUTPUT
echo "previous_hash=$(cat ./scripts/syftcli_hash)" >> $GITHUB_OUTPUT
- name: Current Hash
run: echo ${{steps.get-hashes.outputs.current_hash}}
- name: Previous Hash
run: echo ${{steps.get-hashes.outputs.previous_hash}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
if: ${{steps.get-hashes.outputs.current_hash != steps.get-hashes.outputs.previous_hash }}
run: |
python -m pip install --upgrade pip
pip install --upgrade tox setuptools wheel twine bump2version==1.0.1 PyYAML==6.0.1
- name: Bump the Version
if: ${{steps.get-hashes.outputs.current_hash != steps.get-hashes.outputs.previous_hash }}
id: bump-version
run: |
python3 syftcli/version.py
bump2version patch --allow-dirty --no-commit
tox -e lint || true
echo "deployed_version=$(python3 syftcli/version.py)" >> $GITHUB_OUTPUT
python3 syftcli/version.py
working-directory: ./packages/syftcli
- name: Write the new hash
if: ${{steps.get-hashes.outputs.current_hash != steps.get-hashes.outputs.previous_hash }}
run: echo $(checksumdir packages/syftcli/syftcli -e version.py) > ./scripts/syftcli_hash
- name: Commit changes to Syft CLI
if: ${{steps.get-hashes.outputs.current_hash != steps.get-hashes.outputs.previous_hash }}
uses: EndBug/add-and-commit@v9
with:
author_name: ${{ secrets.OM_BOT_NAME }}
author_email: ${{ secrets.OM_BOT_EMAIL }}
message: "[syftcli]bump version"
add: "['./packages/syftcli/.bumpversion.cfg','./packages/syftcli/setup.py','./packages/syftcli/syftcli/version.py', './scripts/syftcli_hash']"
- name: Build and publish
if: ${{steps.get-hashes.outputs.current_hash != steps.get-hashes.outputs.previous_hash }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.OM_SYFTCLI_PYPI_TOKEN }}
run: |
tox -e syftcli.publish
twine upload packages/syftcli/dist/*
create-syftcli-binaries:
needs: [deploy-syft-cli]
if: always() && (needs.deploy-syft-cli.result == 'success' && (needs.deploy-syft-cli.outputs.current_hash != needs.deploy-syft-cli.outputs.previous_hash))
strategy:
max-parallel: 99
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: true
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install pip dependencies
run: |
python -m pip install --upgrade pip
pip install uv==0.4.1 tox==4.18.0 tox-uv==1.11.2
uv --version
- name: Build syftcli
env:
SYFT_CLI_VERSION: ${{ needs.deploy-syft-cli.outputs.deployed_version }}
run: |
tox -e syftcli.build
- name: upload binaries
uses: actions/upload-artifact@v4
with:
name: syftcli-binaries-${{needs.deploy-syft-cli.outputs.deployed_version}}-${{matrix.os}}
path: ./packages/syftcli/dist/cli/*
if-no-files-found: error
create-syftcli-github-release:
needs: [create-syftcli-binaries, deploy-syft-cli]
if: always() && (needs.create-syftcli-binaries.result == 'success')
runs-on: ubuntu-latest
permissions:
contents: write # For tag and release notes.
steps:
- uses: actions/checkout@v4
- name: Deployed Version
run: echo ${{needs.deploy-syft-cli.outputs.deployed_version}}
- name: Check if version is released on Pypi
id: check-pypi
run: |
VERSION=${{needs.deploy-syft-cli.outputs.deployed_version}}
RESPONSE=$(curl -s --head https://pypi.org/pypi/syftcli/$VERSION/json)
if [[ $RESPONSE == *"HTTP/2 200"* ]]; then
echo "released=true" >> $GITHUB_OUTPUT
else
echo "released=false" >> $GITHUB_OUTPUT
fi
- name: Make sure directory exists
if: steps.check-pypi.outputs.released == 'true'
run: |
mkdir -p ./downloaded-binaries
- name: Download binary
if: steps.check-pypi.outputs.released == 'true'
uses: actions/download-artifact@v4
with:
pattern: syftcli-binaries-${{needs.deploy-syft-cli.outputs.deployed_version}}-*
path: ./downloaded-binaries/
merge-multiple: true
- name: GitHub Release
if: steps.check-pypi.outputs.released == 'true'
uses: softprops/action-gh-release@v2
with:
name: syftcli-v${{ needs.deploy-syft-cli.outputs.deployed_version }}
generate_release_notes: false
prerelease: false
files: |
./downloaded-binaries/*
tag_name: syftcli-v${{ needs.deploy-syft-cli.outputs.deployed_version }}