name: Build packages on: push: branches: - main release: types: [released, prereleased] workflow_dispatch: permissions: # added using https://github.com/step-security/secure-workflows contents: read jobs: pip: runs-on: ubuntu-20.04 permissions: id-token: write steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Python 3.8 uses: actions/setup-python@v4 with: python-version: 3.8 - name: Install run: pip install --upgrade pip wheel - name: Force version for Test PyPI uploads if: ${{ !startsWith(github.ref, 'refs/tags') }} run: | pip install setuptools_scm echo version=$(python -m setuptools_scm | awk -F+ '{print $1}' | tail -1) >> $GITHUB_ENV - name: Build packages run: ./scripts/build_package.sh env: SETUPTOOLS_SCM_PRETEND_VERSION: ${{ env.version }} - name: Publish packages to PyPI if: github.event_name == 'release' uses: pypa/gh-action-pypi-publish@release/v1 - name: Publish to Test PyPI if: ${{ github.event_name == 'release' || (github.event_name == 'push' && github.ref == 'refs/heads/main') }} uses: pypa/gh-action-pypi-publish@release/v1 with: repository_url: https://test.pypi.org/legacy/ skip_existing: true