1- name : CI/CD
1+ name : CloudProxy CI/CD Pipeline
22
33on :
44 push :
99 - ' docs/**'
1010
1111jobs :
12- test-and-release :
12+ test :
13+ name : 🧪 Test Suite
1314 runs-on : ubuntu-latest
14- permissions :
15- contents : write
16- packages : write
17-
1815 steps :
19- - name : Checkout code
16+ - name : 📥 Checkout code
2017 uses : actions/checkout@v4
21- with :
22- fetch-depth : 0
2318
24- - name : Set up Python 3.11
19+ - name : 🐍 Set up Python 3.11
2520 uses : actions/setup-python@v4
2621 with :
2722 python-version : ' 3.11'
2823
29- - name : Install dependencies
24+ - name : 📚 Install dependencies
3025 run : |
3126 python -m pip install --upgrade pip
3227 pip install pytest pytest-mock
3328 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3429
35- - name : Test with pytest
30+ - name : 🧪 Run pytest
3631 run : |
3732 pytest
3833
39- - name : Get latest tag
34+ prepare-release :
35+ name : 🏷️ Prepare Release
36+ needs : test
37+ runs-on : ubuntu-latest
38+ outputs :
39+ new_version : ${{ steps.set_outputs.outputs.new_version }}
40+ permissions :
41+ contents : write
42+ steps :
43+ - name : 📥 Checkout code
44+ uses : actions/checkout@v4
45+ with :
46+ fetch-depth : 0
47+
48+ - name : 🔍 Get latest tag
4049 id : get_latest_tag
4150 run : |
4251 git fetch --tags
4352 latest_tag=$(git tag -l --sort=-v:refname "v*" | head -n 1 || echo "v0.0.0")
4453 echo "Latest tag: $latest_tag"
4554 echo "LATEST_TAG=$latest_tag" >> "$GITHUB_ENV"
4655
47- - name : Bump version
56+ - name : 🔢 Calculate new version
4857 id : bump_version
4958 run : |
5059 latest_version=${LATEST_TAG#v}
5362 echo "NEW_VERSION=$new_version" >> "$GITHUB_ENV"
5463 echo "New version will be: $new_version"
5564
56- - name : Check if tag exists
65+ - name : ✅ Verify version uniqueness
5766 id : check_tag
5867 run : |
5968 if git tag -l | grep -q "^${{ env.NEW_VERSION }}$"; then
6574 echo "Using incremented version: $new_version"
6675 echo "NEW_VERSION=$new_version" >> "$GITHUB_ENV"
6776 fi
77+
78+ - name : 📤 Export version for other jobs
79+ id : set_outputs
80+ run : |
81+ echo "new_version=${{ env.NEW_VERSION }}" >> $GITHUB_OUTPUT
6882
69- - name : Create Release
83+ - name : 🚀 Create GitHub Release
7084 id : create_release
7185 uses : actions/create-release@v1
7286 env :
@@ -82,39 +96,62 @@ jobs:
8296 draft : false
8397 prerelease : false
8498
85- - name : Set up Docker Buildx
99+ publish-docker :
100+ name : 🐳 Publish Docker Image
101+ needs : prepare-release
102+ runs-on : ubuntu-latest
103+ permissions :
104+ packages : write
105+ steps :
106+ - name : 📥 Checkout code
107+ uses : actions/checkout@v4
108+
109+ - name : 🏗️ Set up Docker Buildx
86110 uses : docker/setup-buildx-action@v3
87111
88- - name : Login to Docker Hub
112+ - name : 🔑 Login to Docker Hub
89113 uses : docker/login-action@v3
90114 with :
91115 username : ${{ secrets.DOCKERHUB_USERNAME }}
92116 password : ${{ secrets.DOCKERHUB_TOKEN }}
93117
94- - name : Build and push Docker image
118+ - name : 🚢 Build and push Docker image
95119 uses : docker/build-push-action@v5
96120 with :
97121 context : .
98122 push : true
99123 tags : |
100124 laffin/cloudproxy:latest
101- laffin/cloudproxy:${{ env.NEW_VERSION }}
125+ laffin/cloudproxy:${{ needs.prepare-release.outputs.new_version }}
126+
127+ publish-pypi :
128+ name : 📦 Publish PyPI Package
129+ needs : prepare-release
130+ runs-on : ubuntu-latest
131+ steps :
132+ - name : 📥 Checkout code
133+ uses : actions/checkout@v4
134+
135+ - name : 🐍 Set up Python
136+ uses : actions/setup-python@v5
137+ with :
138+ python-version : ' 3.11'
102139
103- # PyPI Publishing Steps
104- - name : Update version in pyproject.toml
140+ - name : 📝 Update version in pyproject.toml
105141 run : |
106142 # Strip the 'v' prefix from the version
107- VERSION=${NEW_VERSION#v}
143+ VERSION=${{ needs.prepare-release.outputs.new_version }}
144+ VERSION=${VERSION#v}
108145 # Use sed to update the version in pyproject.toml to match the release
109146 sed -i "s/version = \"[0-9]*\.[0-9]*\.[0-9]*\"/version = \"$VERSION\"/" pyproject.toml
110147 cat pyproject.toml | grep version
111148
112- - name : Install PyPI publishing dependencies
149+ - name : 📚 Install PyPI publishing dependencies
113150 run : |
114151 python -m pip install --upgrade pip
115152 pip install build twine
116153
117- - name : Build and publish to PyPI
154+ - name : 📤 Build and publish to PyPI
118155 env :
119156 TWINE_USERNAME : __token__
120157 TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
0 commit comments