@@ -29,18 +29,33 @@ jobs:
29
29
VERSION : ${{ env.VERSION }}
30
30
run : |
31
31
if curl -s -f https://pypi.org/pypi/socketsecurity/$VERSION/json > /dev/null; then
32
- echo "Error: Version ${VERSION} already exists on PyPI"
33
- exit 1
32
+ echo "Version ${VERSION} already exists on PyPI"
33
+ echo "pypi_exists=true" >> $GITHUB_OUTPUT
34
+ else
35
+ echo "Version ${VERSION} not found on PyPI - proceeding with PyPI deployment"
36
+ echo "pypi_exists=false" >> $GITHUB_OUTPUT
37
+ fi
38
+
39
+ - name : Check Docker image existence
40
+ id : docker_check
41
+ env :
42
+ VERSION : ${{ env.VERSION }}
43
+ run : |
44
+ if curl -s -f "https://hub.docker.com/v2/repositories/socketdev/cli/tags/${{ env.VERSION }}" > /dev/null; then
45
+ echo "Docker image socketdev/cli:${VERSION} already exists"
46
+ echo "docker_exists=true" >> $GITHUB_OUTPUT
34
47
else
35
- echo "Version ${VERSION} not found on PyPI - proceeding with release"
48
+ echo "docker_exists=false" >> $GITHUB_OUTPUT
36
49
fi
37
50
38
51
- name : Build package
52
+ if : steps.version_check.outputs.pypi_exists != 'true'
39
53
run : |
40
54
pip install build
41
55
python -m build
42
56
43
57
- name : Publish to PyPI
58
+ if : steps.version_check.outputs.pypi_exists != 'true'
44
59
45
60
with :
46
61
password : ${{ secrets.PYPI_TOKEN }}
51
66
username : ${{ secrets.DOCKERHUB_USERNAME }}
52
67
password : ${{ secrets.DOCKERHUB_TOKEN }}
53
68
54
- - name : Verify package is available
69
+ - name : Verify package is installable
55
70
id : verify_package
56
71
env :
57
72
VERSION : ${{ env.VERSION }}
70
85
exit 1
71
86
72
87
- name : Build & Push Docker
73
- if : steps.verify_package.outputs.success == 'true'
88
+ if : |
89
+ steps.verify_package.outputs.success == 'true' &&
90
+ steps.docker_check.outputs.docker_exists != 'true'
74
91
uses : docker/build-push-action@v5
75
92
env :
76
93
VERSION : ${{ env.VERSION }}
0 commit comments