Skip to content

Commit ac466a4

Browse files
fix(CI): added github actions (#188)
* fix(CI): added github actions Signed-off-by: Sridhar G K <gksridhar09@gmail.com> * fix(CI): github actions content permission Signed-off-by: Sridhar G K <gksridhar09@gmail.com> * fix(CI): pylint fixes Signed-off-by: Sridhar G K <gksridhar09@gmail.com> * fix(CI): pylint skipped as per old travis config Signed-off-by: Sridhar G K <gksridhar09@gmail.com> * chore: deprecate the travis config Signed-off-by: Devx Network Services <devx.network.services@ibm.com> * chore: removed python 3.13 and updated actions using bob Signed-off-by: Devx Network Services <devx.network.services@ibm.com> * fix: npm vulnerabilities Signed-off-by: Sridhar G K <gksridhar09@gmail.com> * chore: added slack notification Signed-off-by: Sridhar G K <gksridhar09@gmail.com> * fix: resolved setup.py build issue Signed-off-by: Sridhar G K <gksridhar09@gmail.com> * chore: fix the npm registry Signed-off-by: Sridhar G K <gksridhar09@gmail.com> * chore: validating the version mismatch in workflow and follow same pattern as go sdk Signed-off-by: Sridhar G K <gksridhar09@gmail.com> --------- Signed-off-by: Sridhar G K <gksridhar09@gmail.com> Signed-off-by: Devx Network Services <devx.network.services@ibm.com> Co-authored-by: Devx Network Services <devx.network.services@ibm.com>
1 parent 75279fa commit ac466a4

File tree

10 files changed

+2270
-2010
lines changed

10 files changed

+2270
-2010
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[bumpversion]
22
current_version = 0.28.0
33
commit = True
4-
message = Update version {current_version} -> {new_version}
4+
message = Update version {current_version} -> {new_version} [skip ci]
55

66
[bumpversion:file:ibm_cloud_networking_services/version.py]
77
search = __version__ = '{current_version}'
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Build & Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build:
15+
name: build-test (python ${{ matrix.python-version }})
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
python-version: ['3.10', '3.11', '3.12']
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
cache: pip
32+
33+
- name: Install dependencies
34+
run: |
35+
pip install 'tox<4' tox-gh-actions
36+
37+
- name: Run tests
38+
run: tox
39+
40+
create-release:
41+
name: semantic-release
42+
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
43+
needs: build
44+
runs-on: ubuntu-latest
45+
46+
permissions:
47+
contents: write
48+
49+
steps:
50+
- name: Notify Slack - Release Started
51+
run: |
52+
curl -X POST "${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}" \
53+
-H 'Content-Type: application/json' \
54+
-d '{
55+
"sdk": "networking-python-sdk",
56+
"language": "python",
57+
"status": "started",
58+
"actor": "${{ github.actor }}"
59+
}'
60+
61+
- name: Checkout repository
62+
uses: actions/checkout@v4
63+
with:
64+
fetch-depth: 0
65+
persist-credentials: false
66+
67+
- name: Setup Node.js
68+
uses: actions/setup-node@v4
69+
with:
70+
node-version: 22
71+
72+
- name: Setup Python
73+
uses: actions/setup-python@v5
74+
with:
75+
python-version: '3.10'
76+
77+
- name: Install pandoc
78+
run: |
79+
sudo apt-get update
80+
sudo apt-get install -y pandoc
81+
pip install pypandoc
82+
83+
- name: Install publishing tools
84+
run: |
85+
pip install bump2version build twine
86+
npm ci
87+
88+
- name: Verify version consistency
89+
run: |
90+
# Extract versions from all files
91+
BUMPVERSION_VERSION=$(grep "current_version" .bumpversion.cfg | cut -d'=' -f2 | tr -d ' ')
92+
SETUP_VERSION=$(grep "__version__ = " setup.py | head -1 | cut -d"'" -f2)
93+
VERSION_PY=$(grep "__version__ = " ibm_cloud_networking_services/version.py | cut -d"'" -f2)
94+
README_VERSION=$(grep "# IBM Cloud Networking Services Python SDK Version" README.md | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
95+
96+
echo "Version in .bumpversion.cfg: $BUMPVERSION_VERSION"
97+
echo "Version in setup.py: $SETUP_VERSION"
98+
echo "Version in version.py: $VERSION_PY"
99+
echo "Version in README.md: $README_VERSION"
100+
101+
# Check if all versions match
102+
if [ "$BUMPVERSION_VERSION" != "$SETUP_VERSION" ] || \
103+
[ "$BUMPVERSION_VERSION" != "$VERSION_PY" ] || \
104+
[ "$BUMPVERSION_VERSION" != "$README_VERSION" ]; then
105+
echo "❌ ERROR: Version mismatch detected!"
106+
echo "All version strings must match before release."
107+
exit 1
108+
fi
109+
110+
echo "✅ All version strings are consistent: $BUMPVERSION_VERSION"
111+
112+
- name: Run semantic-release
113+
env:
114+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
115+
run: npx semantic-release
116+
117+
- name: Publish to PyPI
118+
if: success()
119+
env:
120+
TWINE_USERNAME: __token__
121+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
122+
run: |
123+
python -m build
124+
python -m twine upload dist/*
125+
126+
- name: Get package version
127+
if: success()
128+
id: get_version
129+
run: |
130+
VERSION=$(python -c "from ibm_cloud_networking_services.version import __version__; print(__version__)")
131+
echo "version=$VERSION" >> $GITHUB_OUTPUT
132+
133+
- name: Notify Slack - Release Completed
134+
if: success()
135+
run: |
136+
curl -X POST "${{ secrets.SLACK_PYPI_WEBHOOK_URL }}" \
137+
-H 'Content-Type: application/json' \
138+
-d '{
139+
"version": "${{ steps.get_version.outputs.version }}",
140+
"package_name": "ibm-cloud-networking-services",
141+
"pypi_url": "https://pypi.org/project/ibm-cloud-networking-services/${{ steps.get_version.outputs.version }}/",
142+
"github_release": "${{ github.server_url }}/${{ github.repository }}/releases/tag/v${{ steps.get_version.outputs.version }}",
143+
"commit_sha": "${{ github.sha }}",
144+
"actor": "${{ github.actor }}"
145+
}'
146+
147+
- name: Notify Slack - Release Failed
148+
if: failure()
149+
run: |
150+
curl -X POST "${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}" \
151+
-H 'Content-Type: application/json' \
152+
-d '{
153+
"sdk": "networking-python-sdk",
154+
"language": "python",
155+
"status": "failed",
156+
"actor": "${{ github.actor }}"
157+
}'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ coverage.xml
4646
*,cover
4747

4848
.vscode
49+
node_modules/
4950

5051
# virtual env
5152
venv/

.releaserc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
[
1414
"@semantic-release/git",
1515
{
16-
"message": "chore(release): ${nextRelease.version} release notes\n\n${nextRelease.notes}"
16+
"assets": ["package.json", "setup.py", "ibm_cloud_networking_services/version.py", "README.md", "CHANGELOG.md", ".bumpversion.cfg"],
17+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
18+
"author": {
19+
"name": "IBM",
20+
"email": "devx.network.services@ibm.com"
21+
}
1722
}
1823
],
1924
"@semantic-release/github"
File renamed without changes.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.com/IBM/networking-python-sdk.svg?branch=master)](https://travis-ci.com/IBM/networking-python-sdk)
1+
[![Build Status](https://github.com/IBM/networking-python-sdk/actions/workflows/build-release.yml/badge.svg)](https://github.com/IBM/networking-python-sdk/actions/workflows/build-release.yml)
22
[![Release](https://img.shields.io/github/v/release/IBM/networking-python-sdk)](https://github.com/IBM/networking-python-sdk/releases/latest)
33
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ibm-cloud-networking-services)](https://pypi.org/project/ibm-cloud-networking-services/)
44
[![PyPI](https://img.shields.io/pypi/v/ibm-cloud-networking-services)](https://pypi.org/project/ibm-cloud-networking-services/)
@@ -92,7 +92,7 @@ IBM Cloud services:
9292

9393
- An [IBM Cloud][ibm-cloud-onboarding] account.
9494
- An IAM API key to allow the SDK to access your account. Create one [here](https://cloud.ibm.com/iam/apikeys).
95-
- Python 3.6 or above.
95+
- Python 3.10 or above.
9696

9797
## Installation
9898

0 commit comments

Comments
 (0)