-
Notifications
You must be signed in to change notification settings - Fork 15
fix(CI): added github actions #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0834788
fix(CI): added github actions
sridhargk 066d4ee
fix(CI): github actions content permission
sridhargk 2cc890b
fix(CI): pylint fixes
sridhargk 9fbf256
fix(CI): pylint skipped as per old travis config
sridhargk 3c49366
chore: deprecate the travis config
DevxNetworkServices b99f18d
chore: removed python 3.13 and updated actions using bob
DevxNetworkServices df2b516
fix: npm vulnerabilities
sridhargk b03964f
chore: added slack notification
sridhargk 76bdb00
fix: resolved setup.py build issue
sridhargk 5cfadc7
chore: fix the npm registry
sridhargk ad7fd24
chore: validating the version mismatch in workflow and follow same pa…
sridhargk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| name: Build & Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: build-test (python ${{ matrix.python-version }}) | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ['3.10', '3.11', '3.12'] | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| cache: pip | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| pip install 'tox<4' tox-gh-actions | ||
|
|
||
| - name: Run tests | ||
| run: tox | ||
|
|
||
| create-release: | ||
| name: semantic-release | ||
| if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Notify Slack - Release Started | ||
| run: | | ||
| curl -X POST "${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}" \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "sdk": "networking-python-sdk", | ||
| "language": "python", | ||
| "status": "started", | ||
| "actor": "${{ github.actor }}" | ||
| }' | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.10' | ||
|
|
||
| - name: Install pandoc | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y pandoc | ||
| pip install pypandoc | ||
|
|
||
| - name: Install publishing tools | ||
| run: | | ||
| pip install bump2version build twine | ||
| npm ci | ||
|
|
||
| - name: Verify version consistency | ||
| run: | | ||
| # Extract versions from all files | ||
| BUMPVERSION_VERSION=$(grep "current_version" .bumpversion.cfg | cut -d'=' -f2 | tr -d ' ') | ||
| SETUP_VERSION=$(grep "__version__ = " setup.py | head -1 | cut -d"'" -f2) | ||
| VERSION_PY=$(grep "__version__ = " ibm_cloud_networking_services/version.py | cut -d"'" -f2) | ||
| README_VERSION=$(grep "# IBM Cloud Networking Services Python SDK Version" README.md | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') | ||
|
|
||
| echo "Version in .bumpversion.cfg: $BUMPVERSION_VERSION" | ||
| echo "Version in setup.py: $SETUP_VERSION" | ||
| echo "Version in version.py: $VERSION_PY" | ||
| echo "Version in README.md: $README_VERSION" | ||
|
|
||
| # Check if all versions match | ||
| if [ "$BUMPVERSION_VERSION" != "$SETUP_VERSION" ] || \ | ||
| [ "$BUMPVERSION_VERSION" != "$VERSION_PY" ] || \ | ||
| [ "$BUMPVERSION_VERSION" != "$README_VERSION" ]; then | ||
| echo "❌ ERROR: Version mismatch detected!" | ||
| echo "All version strings must match before release." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ All version strings are consistent: $BUMPVERSION_VERSION" | ||
|
|
||
| - name: Run semantic-release | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| run: npx semantic-release | ||
|
|
||
| - name: Publish to PyPI | ||
| if: success() | ||
| env: | ||
| TWINE_USERNAME: __token__ | ||
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | ||
| run: | | ||
| python -m build | ||
| python -m twine upload dist/* | ||
|
|
||
| - name: Get package version | ||
| if: success() | ||
| id: get_version | ||
| run: | | ||
| VERSION=$(python -c "from ibm_cloud_networking_services.version import __version__; print(__version__)") | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Notify Slack - Release Completed | ||
| if: success() | ||
| run: | | ||
| curl -X POST "${{ secrets.SLACK_PYPI_WEBHOOK_URL }}" \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "version": "${{ steps.get_version.outputs.version }}", | ||
| "package_name": "ibm-cloud-networking-services", | ||
| "pypi_url": "https://pypi.org/project/ibm-cloud-networking-services/${{ steps.get_version.outputs.version }}/", | ||
| "github_release": "${{ github.server_url }}/${{ github.repository }}/releases/tag/v${{ steps.get_version.outputs.version }}", | ||
| "commit_sha": "${{ github.sha }}", | ||
| "actor": "${{ github.actor }}" | ||
| }' | ||
|
|
||
| - name: Notify Slack - Release Failed | ||
| if: failure() | ||
| run: | | ||
| curl -X POST "${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}" \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "sdk": "networking-python-sdk", | ||
| "language": "python", | ||
| "status": "failed", | ||
| "actor": "${{ github.actor }}" | ||
| }' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ coverage.xml | |
| *,cover | ||
|
|
||
| .vscode | ||
| node_modules/ | ||
|
|
||
| # virtual env | ||
| venv/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.