Skip to content

Commit

Permalink
Update Github Workflow and release version to 5.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
silabs-tuD committed Dec 25, 2024
1 parent 46debeb commit 2afc2d3
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 3 deletions.
78 changes: 76 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,83 @@
# separate terms of service, privacy policy, and support
# documentation.

## References:
# 1. https://github.com/actions/create-release
# 2. https://github.com/ArjanCodes/bragir/blob/main/.github/workflows/release.yaml

name: Upload Python Package

on:
push:
branches:
- 'feat/**'
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+a[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+b[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"

permissions:
contents: read

env:
PACKAGE_NAME: "wfx-common-tools"

jobs:

check-tag-details:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.release.outputs.new_version }}
suffix: ${{ steps.release.outputs.suffix }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: actions/checkout@v2

- name: Extract tag details
id: release
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
TAG_NAME=${GITHUB_REF#refs/tags/}
NEW_VERSION=$(echo $TAG_NAME | awk -F'-' '{print $1}')
SUFFIX=$(echo $TAG_NAME | grep -oP '[a-z]+[0-9]+' || echo "")
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT"
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
echo "Version is $NEW_VERSION"
echo "Suffix is $SUFFIX"
echo "Tag name is $TAG_NAME"
else
echo "No tag found"
exit 1
fi
check-version-pypi:
needs: check-tag-details
runs-on: ubuntu-latest
steps:
- name: Fetch information from PyPI
run: |
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}")
latest_previous_version=$(echo $response | grep -o '"[0-9]\+\.[0-9]\+\.[0-9]"' | sort -V | tail -n 1)
if [ -z "$latest_previous_version" ]; then
echo "Package not found on PyPI."
latest_previous_version="0.0.0"
fi
echo "Latest version on PyPI: $latest_previous_version"
echo "latest_previous_version=$latest_previous_version" >> $GITHUB_ENV
- name: Compare versions and exit if not newer
run: |
NEW_VERSION=${{ needs.check-tag-details.outputs.new_version }}
LATEST_VERSION=$latest_previous_version
if [ "$(printf '%s\n' "$LATEST_VERSION" "$NEW_VERSION" | sort -rV | head -n 1)" != "$NEW_VERSION" ] || [ "$NEW_VERSION" == "$LATEST_VERSION" ]; then
echo "The new version $NEW_VERSION is not greater than the latest version $LATEST_VERSION on PyPI."
exit 1
else
echo "The new version $NEW_VERSION is greater than the latest version $LATEST_VERSION on PyPI."
fi
release-build:
needs: [check-tag-details, check-version-pypi]
runs-on: ubuntu-latest

steps:
Expand All @@ -39,6 +104,15 @@ jobs:
name: release-dists
path: dist/

- name: Create Github Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{github.ref}}
generate_release_notes : true

pypi-publish:
runs-on: ubuntu-latest
needs:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exclude = [

[project]
name = "wfx_common_tools"
version = "0.0.4"
version = "5.5.0"
authors = [
{ name = "silabs-Marc", email = "[email protected]"},
]
Expand All @@ -35,6 +35,7 @@ dependencies = [
maintainers = [
{ name="silabs-tuD", email="[email protected]" },
{ name="silabs-JulienT", email="[email protected]" },
{ name = "silabs-Marc", email = "[email protected]"},
]

description = "Silicon Laboratories WFx Wi-Fi tools for all supported platforms"
Expand Down

0 comments on commit 2afc2d3

Please sign in to comment.