From 0bc6caa8da9145da160b4c58658c104ec7c5c81f Mon Sep 17 00:00:00 2001 From: CodyKoInABox Date: Thu, 22 May 2025 20:32:54 -0300 Subject: [PATCH 1/6] create file --- .github/workflows/publishing.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflows/publishing.yml diff --git a/.github/workflows/publishing.yml b/.github/workflows/publishing.yml new file mode 100644 index 0000000..e69de29 From 51b60baef8b4b149dbca5dd630d8a02a9c4b4dcc Mon Sep 17 00:00:00 2001 From: CodyKoInABox Date: Thu, 22 May 2025 20:33:54 -0300 Subject: [PATCH 2/6] update version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 87bc1c5..749395e 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="spicecode", - version="2.0.0", # 2.0.0 = N2 + version="2.1.0", # 2.0.0 = N2 packages=find_packages(exclude=["spicecode-venv", "spicecode.egg-info"]), install_requires=install_requires, entry_points={ From 8d09ffc732a1919249efe337c2953ffc2375aa23 Mon Sep 17 00:00:00 2001 From: CodyKoInABox Date: Thu, 22 May 2025 20:42:10 -0300 Subject: [PATCH 3/6] update name to follow convention --- .github/workflows/{publishing.yml => release.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{publishing.yml => release.yml} (100%) diff --git a/.github/workflows/publishing.yml b/.github/workflows/release.yml similarity index 100% rename from .github/workflows/publishing.yml rename to .github/workflows/release.yml From c3535df5da3f4f3ad719c71f692e93e5ec7a7343 Mon Sep 17 00:00:00 2001 From: CodyKoInABox Date: Thu, 22 May 2025 20:44:39 -0300 Subject: [PATCH 4/6] create workflow --- .github/workflows/release.yml | 146 ++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e69de29..88adc93 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -0,0 +1,146 @@ +name: release + +on: + push: + tags: # regex for version tags according to python's pep 0440 std version convention https://peps.python.org/pep-0440/#version-specifiers + - "[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]+" + +env: + PACKAGE_NAME: "spicecode" + OWNER: "spicecodecli" + +jobs: + 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 and 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_pypi: + needs: 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 | jq --raw-output "select(.releases != null) | .releases | keys_unsorted | last") + 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.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 + + setup_and_build: + needs: [details, check_pypi] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install wheel setuptools build + + - name: Update version in setup.py + run: | + # Replace version in setup.py with the new version from tag + sed -i "s/version=\"[0-9]*\.[0-9]*\.[0-9]*\"/version=\"${{ needs.details.outputs.new_version }}\"/g" setup.py + cat setup.py + + - name: Install dependencies + run: | + pip install -r requirements.txt + + - name: Build source and wheel distribution + run: | + python setup.py sdist bdist_wheel + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: dist + path: dist/ + + pypi_publish: + name: Upload release to PyPI + needs: [setup_and_build, details] + runs-on: ubuntu-latest + environment: + name: release + permissions: + id-token: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: dist + path: dist/ + + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + github_release: + name: Create GitHub Release + needs: [setup_and_build, details] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: dist + path: dist/ + + - name: Create GitHub Release + id: create_release + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release create ${{ needs.details.outputs.tag_name }} dist/* --title ${{ needs.details.outputs.tag_name }} --generate-notes From a4353e4bdf641d92f713dbaa2827310f58e87425 Mon Sep 17 00:00:00 2001 From: CodyKoInABox Date: Thu, 22 May 2025 20:45:29 -0300 Subject: [PATCH 5/6] update file name to work with pypi --- .github/workflows/{release.yml => publishing.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{release.yml => publishing.yml} (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/publishing.yml similarity index 100% rename from .github/workflows/release.yml rename to .github/workflows/publishing.yml From e327858c6e4e18b13b868aa7658642b323e660f3 Mon Sep 17 00:00:00 2001 From: CodyKoInABox Date: Thu, 22 May 2025 20:46:04 -0300 Subject: [PATCH 6/6] update environment name --- .github/workflows/publishing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publishing.yml b/.github/workflows/publishing.yml index 88adc93..a7e9678 100644 --- a/.github/workflows/publishing.yml +++ b/.github/workflows/publishing.yml @@ -107,7 +107,7 @@ jobs: needs: [setup_and_build, details] runs-on: ubuntu-latest environment: - name: release + name: publish permissions: id-token: write steps: