name: Build and Deploy on: push: branches: - main workflow_dispatch: jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.13' - name: Install build dependencies run: | python -m pip install --upgrade pip pip install build hatch hatch-requirements-txt - name: Compute SemVer (X.Y.Z) for this run id: version shell: bash run: | set -euo pipefail BASE="${{ vars.VERSION_BASE }}" # Try a few common CI run number env vars; fall back to timestamp. RUN_NO="${GITHUB_RUN_NUMBER:-${CI_PIPELINE_IID:-${CI_RUN_NUMBER:-}}}" if [[ -z "${RUN_NO}" ]]; then # UTC timestamp as integer to keep it numeric (SemVer patch must be numeric) RUN_NO="$(date -u +%Y%m%d%H%M%S)" fi VERSION="${BASE}.${RUN_NO}" echo "BASE=$BASE" echo "RUN_NO=$RUN_NO" echo "VERSION=$VERSION" echo "HATCH_VERSION=$VERSION" >> "$GITHUB_ENV" - name: Build package run: | python -m build - name: Set up Gitea package registry authentication run: | echo "[distutils]" > ~/.pypirc echo "index-servers = gitea" >> ~/.pypirc echo "[gitea]" >> ~/.pypirc echo "repository = https://git.mydatapath.com/api/packages/datapath/pypi" >> ~/.pypirc echo "username = ${{ secrets.DPGITEA_USERNAME }}" >> ~/.pypirc echo "password = ${{ secrets.DPGITEA_TOKEN }}" >> ~/.pypirc - name: Upload package to Gitea repository run: | pip install twine echo "Uploading package version ${{ steps.version.outputs.version }} to Gitea repository" twine upload --repository gitea dist/* || { echo "Upload failed. Check credentials and repository settings."; exit 1; } - name: Verify upload run: | echo "Package version ${{ steps.version.outputs.version }} successfully uploaded to Gitea repository"