Skip to content

Do a deep fetch for publish step #4

Do a deep fetch for publish step

Do a deep fetch for publish step #4

Workflow file for this run

name: cd
on:
push:
branches: [main]
tags-ignore:
- "v*"
permissions:
contents: write # needed by github‑script to create the tag & release
id-token: write # required for trusted‑publishing
actions: write # upload/download‑artifact
concurrency:
group: build-package
cancel-in-progress: False
jobs:
build:
# We don't need matrix as we build a pure python wheel. No compiled extensions. Nice!
# strategy:
# matrix:
# os: [ubuntu-latest, macos-latest]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6 # latest verified release
with:
enable-cache: true
- name: Set up Python 3.12
run: uv python install 3.12
- name: Build distribution
run: uv build # produces dist/*
- name: Upload dist artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*
retention-days: 1 # keep only the latest set
if-no-files-found: error
check:
runs-on: ubuntu-latest
needs: build
steps:
- name: checkout tests only
uses: actions/checkout@v4
with:
sparse-checkout: |
tests/test_version.py
sparse-checkout-cone-mode: false
- name: Install uv
uses: astral-sh/setup-uv@v6 # latest verified release
with:
enable-cache: true
- name: Download all dist artifacts
uses: actions/download-artifact@v4
with:
pattern: dist # pull every OS artifact from build job
merge-multiple: true # place everything *into* ./dist
path: dist
- name: Ensure wheel is pure-Python
run: |
wheel=$(ls dist/*.whl)
if [[ $wheel != *"-none-any.whl" ]]; then
echo "❌ Detected a platform-specific wheel: $wheel"
exit 1
fi
echo "✅ Pure-Python wheel OK: $wheel"
- name: Smoke test (wheel)
run: uv run --isolated --no-project -p 3.12 --with dist/*.whl tests/test_version.py
- name: Smoke test (source distribution)
run: uv run --isolated --no-project -p 3.12 --with dist/*.tar.gz tests/test_version.py
# Publish via Github Release and to Pypi
publish:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: "main"
fetch-tags: true
fetch-depth: 0
- name: Download all dist artifacts
uses: actions/download-artifact@v4
with:
pattern: dist # pull every OS artifact from build job
merge-multiple: true # place everything *into* ./dist
path: dist
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.12
- name: get version
id: version
run: |
VERSION=$(uv run python -c "from importlib.metadata import version; print(version('adaptive_cards_python'));")
echo "version=v$VERSION" >> $GITHUB_OUTPUT
- name: get previous tag
id: previous_version
run: |
PREV_TAG=$(git describe --abbrev=0 HEAD^)
echo "previous_version=$PREV_TAG" >> $GITHUB_OUTPUT
# Also creates a matching tag!
- name: Create GitHub Release
env:
tag: ${{ steps.version.outputs.version }}
previous_tag: ${{ steps.previous_version.outputs.previous_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory $PWD
gh release create --generate-notes --notes-start-tag ${{ env.previous_tag }} ${{ env.tag }} dist/*
- name: publish package
run: uv publish --trusted-publishing always