oidc-fastapi-test/.forgejo/workflows/build.yaml
phil 6f060dc2bf
Some checks failed
/ build (push) Failing after 8s
/ test (push) Failing after 2s
CI: bump uv
2025-02-25 02:26:37 +01:00

99 lines
2.8 KiB
YAML

on:
push:
workflow_dispatch:
inputs:
verbose:
description: "Verbose"
required: false
default: false
type: boolean
jobs:
build:
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.6.3"
- name: Install
run: uv sync
- name: Run tests (API call)
run: .venv/bin/pytest -s tests/basic.py
- name: Get version
uses: mtkennerly/dunamai-action@v1
with:
args: --style semver
env-var: VERSION
- name: Version
run: echo $VERSION
- name: Get distance from tag
uses: mtkennerly/dunamai-action@v1
with:
args: --format "{distance}"
env-var: DISTANCE
- name: Distance
run: echo $DISTANCE
- name: Check if the container should be built (distance from git tag is 0, or force build)
id: builder
env:
RUN: ${{ toJSON(inputs.build || env.DISTANCE == "0" }}
run: |
echo "run=$RUN" >> $GITHUB_OUTPUT
echo "Run build: $RUN"
- name: Workaround for bug of podman-login
if: fromJSON(steps.builder.outputs.run)
run: |
mkdir -p $HOME/.docker
echo "{ \"auths\": {} }" > $HOME/.docker/config.json
- name: Log in to the container registry (with another workaround)
if: fromJSON(steps.builder.outputs.run)
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
if: fromJSON(steps.builder.outputs.run)
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
if: fromJSON(steps.builder.outputs.run)
uses: actions/push-to-registry@v2
with:
registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}"
image: oidc-fastapi-test
tags: latest ${{ steps.version.outputs.version }}
- name: Build wheel
if: fromJSON(steps.builder.outputs.run)
run: uv build --wheel
- name: Publish Python package (home)
if: fromJSON(steps.builder.outputs.run)
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
continue-on-error: true