oidc-fastapi-test/.forgejo/workflows/build.yaml

93 lines
2.8 KiB
YAML
Raw Normal View History

2025-01-10 19:45:26 +01:00
on:
push:
workflow_dispatch:
inputs:
verbose:
description: "Verbose"
required: false
default: false
type: boolean
jobs:
2025-01-10 23:48:44 +01:00
build:
2025-01-10 19:45:26 +01:00
runs-on: container
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.16"
- name: Install
run: uv sync
- name: Run tests (API call)
run: .venv/bin/pytest -s tests/basic.py
2025-01-11 03:11:03 +01:00
- name: Get version with git describe
2025-01-10 19:45:26 +01:00
id: version
2025-01-11 03:20:22 +01:00
run: |
echo "version=$(git describe)" >> $GITHUB_OUTPUT
echo "$VERSION"
2025-01-11 03:07:34 +01:00
2025-01-11 03:20:22 +01:00
- name: Check if the container should be built
id: builder
2025-01-11 03:07:34 +01:00
env:
2025-01-11 03:20:22 +01:00
RUN: ${{ toJSON(inputs.build || !contains(steps.version.outputs.version, '-')) }}
run: |
echo "run=$RUN" >> $GITHUB_OUTPUT
echo "Run build: $RUN"
2025-01-10 19:45:26 +01:00
2025-01-11 02:46:42 +01:00
- name: Set the version in pyproject.toml (workaround for uv not supporting dynamic version)
if: fromJSON(steps.builder.outputs.run)
env:
VERSION: ${{ steps.version.outputs.version }}
2025-01-11 03:11:03 +01:00
run: sed "s/0.0.0/$VERSION/" -i pyproject.toml
2025-01-11 02:46:42 +01:00
2025-01-10 19:45:26 +01:00
- name: Workaround for bug of podman-login
2025-02-04 03:03:28 +01:00
if: fromJSON(steps.builder.outputs.run)
2025-01-10 19:45:26 +01:00
run: |
mkdir -p $HOME/.docker
echo "{ \"auths\": {} }" > $HOME/.docker/config.json
- name: Log in to the container registry (with another workaround)
2025-02-04 03:03:28 +01:00
if: fromJSON(steps.builder.outputs.run)
2025-01-10 19:45:26 +01:00
uses: actions/podman-login@v1
with:
registry: ${{ vars.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
auth_file_path: /tmp/auth.json
- name: Build the container image
2025-02-04 03:03:28 +01:00
if: fromJSON(steps.builder.outputs.run)
2025-01-10 19:45:26 +01:00
uses: actions/buildah-build@v1
with:
image: oidc-fastapi-test
oci: true
labels: oidc-fastapi-test
tags: latest ${{ steps.version.outputs.version }}
containerfiles: |
./Containerfile
- name: Push the image to the registry
2025-02-04 03:03:28 +01:00
if: fromJSON(steps.builder.outputs.run)
2025-01-10 19:45:26 +01:00
uses: actions/push-to-registry@v2
with:
registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}"
image: oidc-fastapi-test
2025-01-10 23:51:21 +01:00
tags: latest ${{ steps.version.outputs.version }}
2025-01-10 23:48:44 +01:00
- name: Build wheel
2025-02-04 03:03:28 +01:00
if: fromJSON(steps.builder.outputs.run)
2025-01-10 23:48:44 +01:00
run: uv build --wheel
- name: Publish Python package (home)
2025-02-04 03:03:28 +01:00
if: fromJSON(steps.builder.outputs.run)
2025-01-10 23:48:44 +01:00
env:
LOCAL_PYPI_TOKEN: ${{ secrets.LOCAL_PYPI_TOKEN }}
run: uv publish --publish-url https://code.philo.ydns.eu/api/packages/philorg/pypi --token $LOCAL_PYPI_TOKEN