Fix installation of Ubuntu packages in GitHub workflows #100
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: publishing | |
on: push | |
env: | |
PYTHON_VERSION: "3.11" | |
RUST_VERSION: "1.81" | |
TRUNK_VERSION: "0.17.5" | |
UV_VERSION: "0.4.20" | |
jobs: | |
build: | |
name: Build distribution | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
version: ${{ env.UV_VERSION }} | |
enable-cache: true | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Set up Rust | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ env.RUST_VERSION }} --target wasm32-unknown-unknown --profile minimal | |
echo ~/.cargo/bin >> $GITHUB_PATH | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: frontend | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install libarchive-tools | |
uv sync | |
cargo install --locked trunk@${{ env.TRUNK_VERSION }} | |
- name: Build distribution | |
run: | | |
# Build distribution without local version identifier | |
SETUPTOOLS_SCM_PRETEND_VERSION=$(uv run -- hatch version | sed 's/+.*//') make dist | |
- name: Store distribution packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
publish-to-pypi: | |
name: Publish Python distribution to PyPI | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: | |
- build | |
runs-on: ubuntu-22.04 | |
environment: | |
name: pypi | |
url: https://pypi.org/p/valens | |
permissions: | |
id-token: write | |
steps: | |
- name: Download dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
publish-to-testpypi: | |
name: Publish Python distribution to TestPyPI | |
if: github.ref == 'refs/heads/main' | |
needs: | |
- build | |
runs-on: ubuntu-22.04 | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/valens | |
permissions: | |
id-token: write | |
steps: | |
- name: Download dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ |