79 lines
2.2 KiB
YAML
79 lines
2.2 KiB
YAML
# To create a release, create a tag and push it to GitHub:
|
|
#git tag -a "v0.0.1-beta" -m "beta version testing"
|
|
#git push --tags
|
|
# https://dev.to/iamtekson/publish-package-to-pypi-and-release-new-version-using-github-actions-108k
|
|
name: Publish LitGPT to PyPI
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
release:
|
|
types: [published]
|
|
|
|
jobs:
|
|
build:
|
|
name: Build source and wheel distributions
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
with:
|
|
python-version: "3.x"
|
|
cache: "pip"
|
|
|
|
- name: Build source and wheel distributions
|
|
run: |
|
|
python -m pip install --upgrade build twine
|
|
pip install importlib_metadata==7.2.1
|
|
python -m build
|
|
twine check --strict dist/*
|
|
|
|
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: pypi-packages-${{ github.sha }}
|
|
path: dist
|
|
|
|
upload-release-assets:
|
|
needs: build
|
|
if: github.event_name == 'release'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
|
|
steps:
|
|
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
name: pypi-packages-${{ github.sha }}
|
|
path: dist
|
|
|
|
- run: ls -lh dist/
|
|
|
|
- name: Upload to release
|
|
uses: AButler/upload-release-assets@34491005a5d7ec239a784e460807ce844fde7962 # v4.0.0
|
|
with:
|
|
files: "dist/*"
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
publish-pypi:
|
|
needs: build
|
|
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
permissions:
|
|
id-token: write
|
|
|
|
steps:
|
|
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
name: pypi-packages-${{ github.sha }}
|
|
path: dist
|
|
|
|
- run: ls -lh dist/
|
|
|
|
- name: Publish distribution to PyPI
|
|
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
|