Skip to content

Commit

Permalink
Adaptation du projet pour correspondre au recommandations PYPA
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolite committed Mar 10, 2023
1 parent 5046a36 commit c7072d6
Show file tree
Hide file tree
Showing 14 changed files with 895 additions and 111 deletions.
194 changes: 168 additions & 26 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and release
name: Build and publish artefacts and documentation

on:
push:
Expand All @@ -7,51 +7,193 @@ on:

jobs:

create_release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
job_status: ${{ job.status }}
steps:
- name: Checkout project
uses: actions/checkout@v3

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body_path: CHANGELOG.md
draft: false
prerelease: false

build:

runs-on: ubuntu-latest
name: Build artefacts
needs: create_release
outputs:
job_status: ${{ job.status }}
strategy:
max-parallel: 2
fail-fast: true
matrix:
include:
- os: ubuntu-20.04
python-version: "3.8"
- os: ubuntu-22.04
python-version: "3.10"

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Checkout project
uses: actions/checkout@v3

- name: Set up Python 3.8
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/setup.py'
cache-dependency-path: '**/pyproject.toml'

- name: Install dependencies
- name: Install system dependencies
run: |
sudo apt update
sudo apt install python3-rados
python -m pip install --upgrade pip
python -m pip install --upgrade pip setuptools wheel
sudo apt -y install python3-rados python3-gdal
- name: Build wheel
- name: Install python dependencies
run: |
VERSION=${{ github.ref_name }} python setup.py bdist_wheel
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade build bump2version
bump2version --current-version 0.0.0 --new-version ${{ github.ref_name }} patch pyproject.toml src/rok4_tools/__init__.py
- name: Create Release
id: create_release
uses: actions/create-release@v1
- name: Build package
if: "(${{ matrix.os }}=='ubuntu-20.04')&&(${{ matrix.python-version }}=='3.8')"
run: |
source .venv/bin/activate
python3 -m build
- name: Copy documentation
if: "(${{ matrix.os }}=='ubuntu-20.04')&&(${{ matrix.python-version }}=='3.8')"
run: |
cp README.md CHANGELOG.md dist/
cp docs/images dist/
- name: Upload packages
if: "(${{ matrix.os }}=='ubuntu-20.04')&&(${{ matrix.python-version }}=='3.8')"
uses: actions/upload-artifact@v3
with:
name: dist-py3
path: dist/
if-no-files-found: error
retention-days: 1

publish_artefacts:
name: Add built artefacts to release and PyPI
needs: [create_release, build]
if: "always()&&(needs.create_release.outputs.job_status=='success')&&(needs.build.outputs.job_status=='success')"
runs-on: ubuntu-latest

steps:

- uses: actions/download-artifact@v3
with:
name: dist-py3
path: dist/

- name: Add wheel package to release
id: upload-release-whl
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
body_path: CHANGELOG.md
draft: false
prerelease: false
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./dist/rok4_tools-${{ github.ref_name }}-py3-none-any.whl
asset_name: rok4_tools-${{ github.ref_name }}-py3-none-any.whl
asset_content_type: application/zip

- name: Add wheel package to release
id: upload-release-asset
- name: Add tarball package to release
id: upload-release-targz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/rok4tools-${{ github.ref_name }}-py3-none-any.whl
asset_name: rok4tools-${{ github.ref_name }}-py3-none-any.whl
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./dist/rok4-tools-${{ github.ref_name }}.tar.gz
asset_name: rok4-tools-${{ github.ref_name }}.tar.gz
asset_content_type: application/zip

- name: Isolate wheel and tarball
run: |
mkdir to_publish
cp ./dist/*.whl ./dist/*.tar.gz to_publish/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: to_publish/

commit_documentation:
name: Add documentation into gh-pages branch
needs: build
if: "always()&&(needs.create_release.outputs.job_status=='success')&&(needs.build.outputs.job_status=='success')"
runs-on: ubuntu-latest

steps:

- name: Checkout project on gh-pages
uses: actions/checkout@v3
with:
ref: 'gh-pages'
token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/download-artifact@v3
with:
name: dist-py3
path: artifact/

- name: Copy version elements to final location
run: |
mkdir -p docs/versions/${{ github.ref_name }}/docs
cp -r artifact/images docs/versions/${{ github.ref_name }}/docs/
- name: Add pages from templates
run: |
sed "s#__version__#${{ github.ref_name }}#" templates/CHANGELOG.template.md >docs/versions/${{ github.ref_name }}/CHANGELOG.md
cat artifact/CHANGELOG.md >>docs/versions/${{ github.ref_name }}/CHANGELOG.md
sed "s#__version__#${{ github.ref_name }}#" templates/README.template.md >docs/versions/${{ github.ref_name }}/README.md
cat artifact/README.md >>docs/versions/${{ github.ref_name }}/README.md
sed -i "s#x.y.z#${{ github.ref_name }}#" docs/versions/${{ github.ref_name }}/README.md
sed "s#__version__#${{ github.ref_name }}#" templates/index.template.md >docs/index.md
echo "# Versions" >docs/versions.md
echo "" >>docs/versions.md
for v in `ls -t docs/versions`; do sed "s#__version__#$v#" templates/versions.template.md >>docs/versions.md; done
rm -r artifact
- name: Publish on gh-pages branch
run: |
git config user.name github-actions
git config user.email [email protected]
git add -v docs/versions/${{ github.ref_name }}/ docs/index.md docs/versions.md
git commit -m "Add documentation for version ${{ github.ref_name }}"
git push
delete_version:
name: Remove release and tag if error occured
needs: build
if: "always()&&(needs.create_release.outputs.job_status=='success')&&(needs.build.outputs.job_status!='success')"
runs-on: ubuntu-latest

steps:
- name: Remove release and tag
uses: dev-drprasad/[email protected]
with:
tag_name: ${{ github.ref_name }}
delete_release: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# Outils ROK4 Python

## Summary

Ajout de l'outil make-layer
Ajout de l'outil make-layer et suivi des recommandations PyPA pour la gestion du projet.

## Changelog

### [Added]

* Outil MAKE-LAYER : génère un descripteur de couche compatible avec le serveur à partir des pyramides de données à utiliser
* Ajout de la publication PyPI dans la CI GitHub

### [Changed]

* Renommage pour plus de cohérence avec les pratiques :
* Le module rok4 est renommé : rok4lib -> rok4
* Le module d'outil est renommé : rok4tools -> rok4_tools. Le package a le nom rok4-tools
* Le script make-layer.py -> make_layer.py
* Passage de la configuration du projet dans le fichier `pyproject.toml`

<!--
### [Added]
Expand Down
Loading

0 comments on commit c7072d6

Please sign in to comment.