-
Notifications
You must be signed in to change notification settings - Fork 19
108 lines (95 loc) · 3.16 KB
/
_build.yaml
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# -*- coding: utf-8 -*-
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
# GitHub: https://github.com/btschwertfeger
#
# Template workflow to build the project for a specific os
# and Python version.
#
name: Build
on:
workflow_call:
inputs:
os:
type: string
required: true
python-version:
type: string
required: true
permissions:
contents: read
jobs:
Build:
runs-on: ${{ inputs.os }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
files.pythonhosted.org:443
github.com:443
objects.githubusercontent.com:443
pypi.org:443
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0 # IMPORTANT: otherwise the current tag does not get fetched and the build version gets worse
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ inputs.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Check git status (not Windows)
if: runner.os != 'Windows'
run: |
if [[ -z "$(git status --porcelain)" ]]; then
echo "No changes found."
else
echo "Changes detected. Please commit or discard changes before publishing."
git status --porcelain
exit 1
fi
- name: Check git status (Windows)
if: runner.os == 'Windows'
run: |
if (-not (git status --porcelain)) {
Write-Output "No changes found."
} else {
Write-Output "Changes detected. Please commit or discard changes before publishing."
git status --porcelain
exit 1
}
- name: Build Linux
if: runner.os == 'linux'
run: |
uv build .
uv tool install dist/python_kraken_sdk*.whl
uv run kraken --version
- name: Build macOS
if: runner.os == 'macOS'
run: |
uv build .
uv tool install dist/python_kraken_sdk*.whl
uv run kraken --version
- name: Build Windows
if: runner.os == 'Windows'
run: |
uv build .
try {
$WHEEL = Get-ChildItem -Path ./dist -Filter "python_kraken_sdk*.whl" -ErrorAction Stop
uv tool install $WHEEL#
uv run kraken --version
} catch {
Write-Error "Error: .whl file not found in .\dist."
exit 1
}
- name: Store the distribution packages
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
# upload artifacts with the oldest supported version
if: runner.os == 'linux' && inputs.python-version == '3.11'
with:
name: python-package-distributions
path: dist/