Skip to content

Commit 208ff7b

Browse files
committed
use action for both jobs
1 parent e32e700 commit 208ff7b

File tree

2 files changed

+48
-28
lines changed

2 files changed

+48
-28
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: 'Update Package Version'
19+
description: 'Updates pyproject.toml version with timestamp'
20+
runs:
21+
using: "composite"
22+
steps:
23+
- name: Setup Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.12'
27+
28+
- name: Install toml
29+
run: pip install toml
30+
shell: bash
31+
32+
- name: Get and update version
33+
shell: bash
34+
run: |
35+
CURRENT_VERSION=$(python -c "import toml; print(toml.load('bindings/python/pyproject.toml')['project']['version'])")
36+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
37+
NEW_VERSION="${CURRENT_VERSION}.dev${TIMESTAMP}"
38+
NEW_VERSION=$NEW_VERSION python -c "
39+
import toml
40+
import os
41+
config = toml.load('bindings/python/pyproject.toml')
42+
config['project']['version'] = os.environ['NEW_VERSION']
43+
with open('bindings/python/pyproject.toml', 'w') as f:
44+
toml.dump(config, f)
45+
print(f'Updated version to: {config[\"project\"][\"version\"]}')
46+
"

.github/workflows/release_python_nightly.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,7 @@ jobs:
3434
steps:
3535
- uses: actions/checkout@v4
3636

37-
- name: Setup Python
38-
uses: actions/setup-python@v5
39-
with:
40-
python-version: '3.12'
41-
42-
- name: Install toml
43-
run: pip install toml
44-
45-
# Override the library version
46-
- name: Get current version
47-
run: |
48-
CURRENT_VERSION=$(python -c "import toml; print(toml.load('bindings/python/pyproject.toml')['project']['version'])")
49-
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
50-
51-
- name: Update version with timestamp
52-
run: |
53-
TIMESTAMP=$(date +%Y%m%d%H%M%S)
54-
NEW_VERSION="${CURRENT_VERSION}.dev${TIMESTAMP}"
55-
NEW_VERSION=$NEW_VERSION python -c "
56-
import toml
57-
import os
58-
config = toml.load('bindings/python/pyproject.toml')
59-
config['project']['version'] = os.environ['NEW_VERSION']
60-
with open('bindings/python/pyproject.toml', 'w') as f:
61-
toml.dump(config, f)
62-
print(f'Updated version to: {config[\"project\"][\"version\"]}')
63-
"
37+
- uses: ./.github/actions/overwrite-package-version # overwrite the pacakge version with current timestamp
6438

6539
- uses: PyO3/maturin-action@v1
6640
with:
@@ -85,6 +59,7 @@ jobs:
8559
- { os: ubuntu-latest, target: "armv7l" }
8660
steps:
8761
- uses: actions/checkout@v4
62+
- uses: ./.github/actions/overwrite-package-version # overwrite the pacakge version with current timestamp
8863
- uses: actions/setup-python@v5
8964
with:
9065
python-version: 3.9
@@ -109,7 +84,6 @@ jobs:
10984
path: bindings/python/dist
11085

11186
testpypi-publish:
112-
name: Publish Python 🐍 distribution 📦 to TestPypi
11387
needs: [ sdist, wheels ]
11488
runs-on: ubuntu-latest
11589

0 commit comments

Comments
 (0)