feat: move action to own branch

This commit is contained in:
Oskar Manhart 2025-05-31 11:58:22 +02:00
parent ee1dcf4a21
commit ed6097b3fe
3 changed files with 11 additions and 76 deletions

View file

@ -1,34 +0,0 @@
on:
workflow_call:
inputs:
github-repository:
required: true
type: string
pypi-package:
required: true
type: string
pypi-base-url:
required: true
type: string
outputs:
version: ${{ jobs.check-version-exists.outputs.version }}
jobs:
check-version-exists:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: check
run: |
pip3 install requests
exec python3 .forgejo/workflows/check_version_exists.py >> $GITHUB_OUTPUT
env:
REPOSITORY: ${{ inputs.github-repository }}
PACKAGE: ${{ inputs.pypi-package}}
BASE_URL: ${{ inputs.pypi-base-url}}

View file

@ -1,37 +0,0 @@
#/usr/bin/env python3
import os
import re
import sys
import requests
def get_github_version(repository: str) -> str:
res = requests.get(f"https://api.github.com/repos/{repository}/releases/latest").json()
return res["tag_name"].removeprefix("v")
def does_pypi_version_exist(base_url: str, package: str, version: str) -> bool:
base_url = base_url.removesuffix("/")
version = version.replace(".", "\\.")
body = requests.get(f"{base_url}/simple/{package}").text
return len(re.findall(rf"<a href=\".+\">{package}-{version}-.+</a>", body, re.MULTILINE)) > 0
def main():
repository = os.environ["REPOSITORY"]
package = os.environ["PACKAGE"]
base_url = os.environ["FORGEJO_URL"]
version = get_github_version(repository)
if does_pypi_version_exist(base_url, package, version):
sys.exit(0)
print(f"version=v{version}")
if __name__ == "__main__":
main()

View file

@ -11,11 +11,17 @@ env:
jobs:
check-version-exists:
runs-on: ubuntu-latest
uses: ./.forgejo/workflows/check-version-exists.yaml
with:
pypi-base-url: ${{ env.REPOSITORY_URL }}
pypi-package: pycairo
github-repository: "pygobject/pycairo"
outputs:
version: ${{ steps.check.outputs.version }}
steps:
- id: check
uses: https://git.weddingfactory.eu/wheels@check-action
with:
pypi-base-url: ${{ env.REPOSITORY_URL }}
pypi-package: pycairo
github-repository: "pygobject/pycairo"
build:
name: Build wheels on ${{ matrix.os }}