Skip to content

Commit dda6eb0

Browse files
authored
Update publish-to-pypi.yml
1 parent 594ab08 commit dda6eb0

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: release
44

55
# Usage:
66
# - Create a new tag with the version number in the format v*.*.* where * are integers: `git tag v1.2.3`
7-
# - Push the tag to the repository: `git push --tags`
7+
# - Push the tag to the repository: `git push origin tag v1.2.3`
88

99
# Result:
1010
# - Check if the new version is greater than the latest version on PyPI
@@ -16,33 +16,25 @@ name: release
1616
# Checklist for using this workflow up for a new project:
1717

1818
# 1. In github settings:
19-
# - Create an environment called `release` (GH_ENV_NAME) and setup the permissions (https://github.com/<ORGANIZATION>/<REPO_NAME>/settings/environments)
19+
# - Create an environment called `release`
20+
# - Setup the permissions (https://github.com/<ORGANIZATION>/<REPO_NAME>/settings/environments)
21+
# - Add the following variables:
22+
# - PACKAGE_NAME: the name of your package on pypi
23+
# - PYTHON_VERSION: the version of Python you want to use
2024

2125
# 2. On PyPi:
2226
# - Create the project and add a trusted publisher (https://pypi.org/manage/project/<PACKAGE_NAME>/settings/publishing/ or https://pypi.org/manage/account/publishing if the project is not on pypi yet)
2327
# - Ensure the publisher is configured to use:
24-
# - environment name: `release` (can be changed, but should be the one created in the github settings)
2528
# - the filename of this workflow yml (in this case: publish-to-pypi.yml)
2629

27-
# 3. In this file:
28-
# - In the `env` section (~L45):
29-
# - Update the name of your package (PACKAGE_NAME)
30-
# - Update the version of Python you want to use (PYTHON_VERSION)
31-
# - Update the name name of the environment you created in github settings (GH_ENV_NAME)
32-
3330
# - In the `setup_and_build` job:
3431
# - Update the the shell commands to install your package
3532

3633
on:
3734
push:
3835
tags:
36+
- v[0-9]+\.[0-9]+\.[0-9]+
3937
# https://peps.python.org/pep-0440/
40-
- r"v[0-9]+\.[0-9]+\.[0-9]"
41-
42-
env:
43-
GH_ENV_NAME: "release"
44-
PACKAGE_NAME: "cht_tiling"
45-
PYTHON_VERSION: "3.10"
4638

4739
jobs:
4840
details:
@@ -58,7 +50,7 @@ jobs:
5850
run: |
5951
if [ "${{ github.ref_type }}" = "tag" ]; then
6052
TAG_NAME=${GITHUB_REF#refs/tags/}
61-
NEW_VERSION=$(echo $TAG_NAME | awk -F'-' '{print $1}')
53+
NEW_VERSION=$(echo $TAG_NAME | sed 's/^v//' | awk -F'-' '{print $1}')
6254
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
6355
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
6456
echo "Version is $NEW_VERSION"
@@ -75,7 +67,7 @@ jobs:
7567
- name: Fetch information from PyPI
7668
run: |
7769
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}")
78-
latest_previous_version=$(echo $response | jq --raw-output "select(.releases != null) | .releases | keys_unsorted | last")
70+
latest_previous_version=$(echo $response | jq --raw-output "select(.releases != null) | .releases | keys_unsorted[]" | sort -V | tail -n 1)
7971
if [ -z "$latest_previous_version" ]; then
8072
echo "Package not found on PyPI."
8173
latest_previous_version="0.0.0"
@@ -110,16 +102,17 @@ jobs:
110102
- name: Install Build tools
111103
shell: bash -el {0}
112104
run: |
113-
conda run -n publish pip install --upgrade build pip setuptools
105+
conda install -n publish pip setuptools wheel python-build
114106
115107
- name: Install dependencies
116108
shell: bash -el {0}
117109
run: |
110+
conda install -n publish gdal basemap cftime fiona netCDF4 pygeos pyproj rasterio rtree shapely --channel conda-forge
118111
conda run -n publish pip install .
119112
120113
- name: Build source and wheel distribution
121114
run: |
122-
conda run -n publish python -m build
115+
conda run -n publish python -s -m build
123116
124117
- name: Upload artifacts
125118
uses: actions/upload-artifact@v3
@@ -132,7 +125,8 @@ jobs:
132125
needs: [setup_and_build, details]
133126
runs-on: ubuntu-latest
134127
environment:
135-
name: ${{ env.GH_ENV_NAME }}
128+
name: release
129+
136130
permissions:
137131
id-token: write
138132
steps:

0 commit comments

Comments
 (0)