Skip to content

Merge pull request #403 from fvaleye/dependabot/pip/ruff-0.8.5 #80

Merge pull request #403 from fvaleye/dependabot/pip/ruff-0.8.5

Merge pull request #403 from fvaleye/dependabot/pip/ruff-0.8.5 #80

Workflow file for this run

name: Release to PyPI
on:
push:
tags: [ 'v*' ]
defaults:
run:
working-directory: ./
jobs:
validate-git-tag:
name: Validate the git tag
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: compare git tag with cargo metadata
run: |
TAG=${GITHUB_REF##*/}
CURR_VER=$( grep version pyproject.toml | head -n 1 | awk '{print $3}' | tr -d '"' )
if [[ "${TAG}" != "v${CURR_VER}" ]]; then
echo "Pyproject metadata has version set to ${CURR_VER}, but got pushed tag ${TAG}."
exit 1
fi
release-pypi-ubuntu:
needs: validate-git-tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install Poetry
uses: abatilo/actions-poetry@v2
- name: Setup
run: make init
- name: Publish
run: poetry publish --build --username "${{ secrets.PYPI_USERNAME }}" --password "${{ secrets.PYPI_PASSWORD }}"
release-documentation:
needs: release-pypi-ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install Poetry
uses: abatilo/actions-poetry@v2
- name: Setup
run: make init
- name: Build and Publish Sphinx documentation
run: |
echo "Generate the new documentation"
make build-documentation
mv docs/build ~/build
echo "Configure git"
git config --global user.name 'Github Action'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
echo "Commit the new changes in the gh-pages"
git reset --hard HEAD
git clean -d -fx .
git fetch
git checkout gh-pages
cp -avr ~/build/html/. ./documentation
git status
git add ./documentation
git commit -m "Publish the new documentation for ${GITHUB_REF_NAME}"
git push origin gh-pages
release-docker:
needs: release-pypi-ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
florianvaleye/tracarbon
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}