Spaces:
Running
Running
skip flit build and publish if version is not bumped
Browse files
.github/workflows/release.yaml
CHANGED
@@ -80,19 +80,51 @@ jobs:
|
|
80 |
with:
|
81 |
python-version: '3.x'
|
82 |
|
83 |
-
# Step 3: Install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
- name: Install Flit
|
|
|
85 |
run: pip install flit
|
86 |
|
87 |
-
# Step
|
88 |
- name: Create .pypirc file
|
|
|
89 |
run: |
|
90 |
echo "[pypi]" > ~/.pypirc
|
91 |
echo "username = __token__" >> ~/.pypirc
|
92 |
echo "password = ${{ secrets.PYPI_API_TOKEN }}" >> ~/.pypirc
|
93 |
|
94 |
-
# Step
|
95 |
- name: Build and Publish Package
|
|
|
96 |
run: |
|
97 |
flit build
|
98 |
-
flit publish
|
|
|
80 |
with:
|
81 |
python-version: '3.x'
|
82 |
|
83 |
+
# Step 3: Install dependencies
|
84 |
+
- name: Install dependencies
|
85 |
+
run: pip install toml
|
86 |
+
|
87 |
+
# Step 4: Extract current version from pyproject.toml
|
88 |
+
- name: Extract current version
|
89 |
+
id: get_version
|
90 |
+
run: |
|
91 |
+
VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
|
92 |
+
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
93 |
+
|
94 |
+
# Step 5: Get the latest Git tag
|
95 |
+
- name: Get latest tag
|
96 |
+
id: get_latest_tag
|
97 |
+
run: |
|
98 |
+
LATEST_TAG=$(git describe --tags --abbrev=0)
|
99 |
+
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
|
100 |
+
|
101 |
+
# Step 6: Compare current version with the latest tag
|
102 |
+
- name: Check if version is bumped
|
103 |
+
id: check_version
|
104 |
+
run: |
|
105 |
+
if [ "v${{ env.VERSION }}" = "${{ env.LATEST_TAG }}" ]; then
|
106 |
+
echo "Version not bumped. Exiting."
|
107 |
+
echo "version_bumped=false" >> $GITHUB_ENV
|
108 |
+
else
|
109 |
+
echo "Version bumped. Proceeding."
|
110 |
+
echo "version_bumped=true" >> $GITHUB_ENV
|
111 |
+
|
112 |
+
# Step 7: Install Flit (only if version bumped)
|
113 |
- name: Install Flit
|
114 |
+
if: env.version_bumped == 'true'
|
115 |
run: pip install flit
|
116 |
|
117 |
+
# Step 8: Create .pypirc file (only if version bumped)
|
118 |
- name: Create .pypirc file
|
119 |
+
if: env.version_bumped == 'true'
|
120 |
run: |
|
121 |
echo "[pypi]" > ~/.pypirc
|
122 |
echo "username = __token__" >> ~/.pypirc
|
123 |
echo "password = ${{ secrets.PYPI_API_TOKEN }}" >> ~/.pypirc
|
124 |
|
125 |
+
# Step 9: Build and publish package (only if version bumped)
|
126 |
- name: Build and Publish Package
|
127 |
+
if: env.version_bumped == 'true'
|
128 |
run: |
|
129 |
flit build
|
130 |
+
flit publish
|