Modifie l'authentification à PYPI dans le job de déploiement de la CI pour utiliser un Token API #475
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: OpenFisca France Local | |
on: | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
openfisca-dependencies: [minimal, maximal] | |
python-version: ["3.9.9", "3.10.6"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache build | |
id: restore-build | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}-${{ matrix.openfisca-dependencies }} | |
restore-keys: | # in case of a cache miss (systematically unless the same commit is built repeatedly), the keys below will be used to restore dependencies from previous builds, and the cache will be stored at the end of the job, making up-to-date dependencies available for all jobs of the workflow; see more at https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action | |
build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }} | |
build-${{ env.pythonLocation }}- | |
- name: Install test dependancies | |
run: make install-test | |
- name: Build package | |
run: make build | |
- name: Minimal version | |
if: matrix.openfisca-dependencies == 'minimal' | |
run: | # Installs the OpenFisca dependencies minimal version from setup.py | |
pip install $(python ${GITHUB_WORKSPACE}/.github/get_minimal_version.py) | |
- name: Cache release | |
id: restore-release | |
uses: actions/cache@v3 | |
with: | |
path: dist | |
key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}-${{ matrix.openfisca-dependencies }} | |
test-python: | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: true | |
matrix: | |
openfisca-dependencies: [minimal, maximal] | |
needs: [ build ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9.9 | |
- name: Cache build | |
id: restore-build | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}-${{ matrix.openfisca-dependencies }} | |
- run: | | |
shopt -s globstar | |
openfisca test tests/**/*.py | |
if: matrix.openfisca-dependencies != 'minimal' | |
deploy: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
openfisca-dependencies: [maximal] | |
needs: [ build ] | |
env: | |
PYPI_USERNAME: __token__ | |
PYPI_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN_API_ALLAN }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch all the tags | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9.9 | |
- name: Cache build | |
id: restore-build | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: build-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}-${{ matrix.openfisca-dependencies }} | |
- name: Cache release | |
id: restore-release | |
uses: actions/cache@v3 | |
with: | |
path: dist | |
key: release-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ github.sha }}-${{ matrix.openfisca-dependencies }} | |
- name: Upload a Python package to PyPi | |
run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_PASSWORD | |
- name: Publish a git tag | |
run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh" |