-
Notifications
You must be signed in to change notification settings - Fork 5
74 lines (65 loc) · 2.55 KB
/
Copy pathpython-release.yml
File metadata and controls
74 lines (65 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Python Releasing Workflow
name: Python - Release
on:
workflow_call:
inputs:
version:
description: 'Python main version to vendor'
type: string
# All Major versions of Python that are currently supported
default: '3.11'
cooldown-days:
description: 'Number of days to use as the dependency cooldown window (excludes packages newer than N days)'
type: number
default: 3
permissions:
contents: write
pull-requests: write
jobs:
version-changes:
runs-on: ubuntu-latest
outputs:
release: ${{ steps.check_release.outputs.release }}
version: ${{ steps.check_release.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: "Check release"
id: check_release
env:
GH_TOKEN: ${{ github.token }}
COOLDOWN_DAYS: ${{ inputs.cooldown-days }}
run: |
set -e
if [[ -f .release.yml ]]; then
python -m pip install --upgrade uv
if [[ -f requirements.txt ]]; then
uv pip sync requirements.txt --exclude-newer "$(date -u -d "$COOLDOWN_DAYS days ago" +%Y-%m-%dT%H:%M:%SZ)"
else
uv pip install yq --exclude-newer "$(date -u -d "$COOLDOWN_DAYS days ago" +%Y-%m-%dT%H:%M:%SZ)"
fi
current_version=$(cat .release.yml | yq -r ".version")
elif [[ -f pyproject.toml ]]; then
current_version=$(grep -oP '^version = "(.*)"$' pyproject.toml | cut -d '"' -f 2)
elif [[ -f setup.py ]]; then
current_version=$(grep -oP '^__version__ = "(.*)"$' setup.py | cut -d '"' -f 2)
else
echo "No version file found"
current_version="NA"
fi
released_version=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/:owner/:repo/releases/latest | jq -r ".tag_name")
if [[ "$current_version" == "NA" || "$current_version" == "$released_version" ]]; then
echo "No new release found"
echo "release=false" >> "$GITHUB_OUTPUT"
else
echo "New release found"
echo "version=$current_version" >> "$GITHUB_OUTPUT"
echo "release=true" >> "$GITHUB_OUTPUT"
fi
github-release:
uses: advanced-security/reusable-workflows/.github/workflows/release.yml@v0.3.4
needs: [ version-changes ]
if: ${{ needs.version-changes.outputs.release == 'true' }}
secrets: inherit
with:
version: ${{ needs.version-changes.outputs.version }}