Use dynamic versioning
This commit is contained in:
parent
c7deb34bae
commit
ea7e3087cd
5 changed files with 157 additions and 150 deletions
|
@ -18,9 +18,11 @@ jobs:
|
|||
volumes:
|
||||
- "uv_cache:/root/.cache/uv"
|
||||
- "ca-cert:/etc/containers/certs.d"
|
||||
|
||||
services:
|
||||
treetrail-database:
|
||||
image: code.philo.ydns.eu/philorg/treetrail-database
|
||||
|
||||
steps:
|
||||
- name: Echo env
|
||||
if: ${{ inputs.verbose }}
|
||||
|
@ -43,40 +45,34 @@ jobs:
|
|||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get the version from git
|
||||
id: version
|
||||
run: echo "version=$(git describe --dirty --tags)" >> $GITHUB_OUTPUT
|
||||
- name: Install the latest version of uv
|
||||
uses: astral-sh/setup-uv@v4
|
||||
with:
|
||||
version: "0.6.6"
|
||||
|
||||
- name: Check if the container should be built
|
||||
id: builder
|
||||
env:
|
||||
RUN: ${{ toJSON(inputs.build || !contains(steps.version.outputs.version, '-')) }}
|
||||
run: |
|
||||
echo "run=$RUN" >> $GITHUB_OUTPUT
|
||||
echo "Run build: $RUN"
|
||||
- name: Install
|
||||
run: uv sync
|
||||
|
||||
- name: Info - version and test if the git version is clean (then python package and image container should be built)
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
RUN: ${{ steps.builder.outputs.run }}
|
||||
FORCE: ${{ toJSON(inputs.build) }}
|
||||
run: |
|
||||
echo "Version $VERSION, force (manual input): $FORCE, run the build: $RUN"
|
||||
- name: Get version
|
||||
run: echo "VERSION=$(.venv/bin/dunamai from any --style semver)" >> $GITHUB_ENV
|
||||
|
||||
- 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 }}
|
||||
run: sed "s/0.0.0/${VERSION}/" -i pyproject.toml
|
||||
- name: Version
|
||||
run: echo $VERSION
|
||||
|
||||
- name: Get distance from tag
|
||||
run: echo "DISTANCE=$(.venv/bin/dunamai from any --format '{distance}')" >> $GITHUB_ENV
|
||||
|
||||
- name: Distance
|
||||
run: echo $DISTANCE
|
||||
|
||||
- name: Workaround for bug of podman-login
|
||||
if: fromJSON(steps.builder.outputs.run)
|
||||
if: env.DISTANCE == '0'
|
||||
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)
|
||||
if: env.DISTANCE == '0'
|
||||
uses: actions/podman-login@v1
|
||||
with:
|
||||
registry: ${{ vars.REGISTRY }}
|
||||
|
@ -85,37 +81,31 @@ jobs:
|
|||
auth_file_path: /tmp/auth.json
|
||||
|
||||
- name: Build the container image
|
||||
if: fromJSON(steps.builder.outputs.run)
|
||||
if: env.DISTANCE == '0'
|
||||
uses: actions/buildah-build@v1
|
||||
with:
|
||||
image: treetrail-backend
|
||||
oci: true
|
||||
labels: treetrail-backend
|
||||
tags: latest ${{ steps.version.outputs.version }}
|
||||
tags: latest env.VERSION
|
||||
containerfiles: |
|
||||
./Containerfile
|
||||
build-args: |
|
||||
APP_VERSION=${{ steps.version.outputs.version }}
|
||||
|
||||
- name: Push the image to the registry
|
||||
if: fromJSON(steps.builder.outputs.run)
|
||||
if: env.DISTANCE == '0'
|
||||
uses: actions/push-to-registry@v2
|
||||
with:
|
||||
registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}"
|
||||
image: treetrail-backend
|
||||
tags: latest ${{ steps.version.outputs.version }}
|
||||
tags: latest env.VERSION
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v4
|
||||
with:
|
||||
version: "0.5.5"
|
||||
|
||||
- name: Build python package
|
||||
if: fromJSON(steps.builder.outputs.run)
|
||||
- name: Build wheel
|
||||
if: env.DISTANCE == '0'
|
||||
run: uv build --wheel
|
||||
|
||||
- name: Publish Python package (home)
|
||||
if: fromJSON(steps.builder.outputs.run)
|
||||
if: env.DISTANCE == '0'
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue