Fix actions #2
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: Publish the package on pypi | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
jobs: | |
check_version_update: | |
if: github.event.pull_request.merged | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check pypi version | |
uses: maybe-hello-world/pyproject-check-version@v4 | |
id: versioncheck | |
with: | |
pyproject-path: "./pyproject.toml" | |
- name: Check if local version has been updated 🕵️ | |
run: | | |
if ${{ steps.versioncheck.outputs.local_version_is_higher }}; then | |
echo "Version bumped." | |
else | |
echo "Local version must be greater than public one." | |
echo "Please bump package version." | |
exit 1 | |
fi | |
outputs: | |
new_pkg_version: ${{ steps.versioncheck.outputs.local_version }} | |
build: | |
name: Build distribution 📦 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 🚧 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: Install pypa/build 🚧 | |
run: >- | |
python3 -m | |
pip install | |
build | |
--user | |
- name: Build a binary wheel and a source tarball 🛠️ | |
run: python3 -m build | |
- name: Store the distribution packages | |
uses: actions/upload-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
publish-to-pypi: | |
name: Publish Python 🐍 distribution 📦 to PyPI | |
#if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | |
if: github.event.pull_request.merged # publish on PR merge | |
needs: | |
- check_version_update # Only publish if there is a version update | |
- build # Only publish if the package was built | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/credentialdigger | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
skip-existing: true | |
docker: | |
name: Push Docker image to Docker Hub 🐳 | |
if: github.event.pull_request.merged | |
needs: | |
- check_version_update | |
- publish-to-pypi | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker 🐳 image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./ui/Dockerfile | |
push: true | |
tags: saposs/credentialdigger:${{ needs.check_version_update.outputs.new_pkg_version }} |