forked from stanford-crfm/levanter
-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (57 loc) · 1.82 KB
/
publish_dev.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Publish Dev Build
on:
workflow_run:
workflows: ["Run Tests"]
types:
- completed
branches: [main]
workflow_dispatch:
jobs:
build-package:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'}}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Calculate Version and Build Number
run: |
PROJECT_VERSION=$(sed -n 's/__version__ = "\(.*\)"/\1/p' src/levanter/__init__.py)
BUILD_NUMBER=$(git rev-list --count HEAD)
FULL_VERSION="${PROJECT_VERSION}.dev${BUILD_NUMBER}"
echo "FULL_VERSION=${FULL_VERSION}" >> $GITHUB_ENV
echo "Calculated version with build number: $FULL_VERSION"
- name: Update pyproject.toml version
run: |
# replace the version in pyproject.toml
sed -i "s/version = \".*\"/version = \"$FULL_VERSION\"/g" pyproject.toml
- name: Build package
run: |
python -m pip install --upgrade pip
pip install build
python -m build
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: package
path: dist/
# cf https://test.pypi.org/manage/project/levanter/settings/publishing/
publish-dev:
runs-on: ubuntu-latest
needs:
- build-package
permissions:
id-token: write
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: package
path: dist/
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1