-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreusable-python-build_setuptools_package.yml
More file actions
122 lines (119 loc) · 4.65 KB
/
reusable-python-build_setuptools_package.yml
File metadata and controls
122 lines (119 loc) · 4.65 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Build setuptools package
on:
workflow_call:
inputs:
package-name:
description: Name of the package to build
required: true
type: string
python-version:
description: Python version to use (e.g. 3.10)
required: true
type: string
version-tag:
description: Version tag of the package to build
required: true
type: string
virtual-repo-names:
description: 'List of repository names to resolve on (e.g. ["public-pypi-dev"])'
required: true
type: string
os:
description: OS to build against (e.g. "ubuntu-latest")
required: true
type: string
lfs:
description: Boolean to indicate if GitHub LFS is needed
required: false
type: boolean
default: false
timeout-minutes:
description: Timeout in minutes for the job
required: true
type: number
outputs:
build-dir-path:
description: Path to the build directory
value: ${{ jobs.build_package.outputs.build-dir-path }}
version:
description: Version of the package
value: ${{ jobs.build_package.outputs.version }}
secrets:
JFROG_ARTIFACTORY_URL:
description: JFrog Artifactory URL
required: true
JFROG_ARTIFACTORY_TOKEN:
description: JFrog Artifactory Token
required: true
defaults:
run:
shell: 'bash -l {0}'
jobs:
build_package:
name: Build setuptools package
runs-on: ${{ inputs.os }}
timeout-minutes: ${{ inputs.timeout-minutes }}
outputs:
build-dir-path: ${{ steps.define-build-path.outputs.dir-path }}
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
lfs: ${{ inputs.lfs }}
fetch-depth: 0
persist-credentials: false
- name: Get version
id: get-version
env:
INPUTS_VERSION_TAG: ${{ inputs.version-tag }}
run: |
if [ "${INPUTS_VERSION_TAG}" = "v0.0.0" ]; then
echo "Version tag not available"
exit 1
fi
VERSION=$(echo "${INPUTS_VERSION_TAG}" | sed 's/v//')
echo "version: ${VERSION}"
if [ -z "${VERSION}" ]; then
echo "Version is not available"
exit 1
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- uses: jfrog/setup-jfrog-cli@v4.9.1
name: Setup JFrog CLI
env:
JF_URL: https://${{ secrets.JFROG_ARTIFACTORY_URL }}
JF_ACCESS_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }}
- name: Set up Python version
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Verify package installation
env:
INPUTS_VIRTUAL_REPO_NAMES: ${{ inputs.virtual-repo-names }}
run: |
repository_list=$(echo "${INPUTS_VIRTUAL_REPO_NAMES}" | jq -r '.[]')
for repo_name in ${repository_list}; do
PIP_EXTRA_INDEX_URL="$PIP_EXTRA_INDEX_URL https://github:${{ secrets.JFROG_ARTIFACTORY_TOKEN }}@${{ secrets.JFROG_ARTIFACTORY_URL }}/artifactory/api/pypi/${repo_name}/simple"
done
export PIP_EXTRA_INDEX_URL
pip install .
- name: Pip install build
run: pip install build
- name: Build package
run: python -m build
- name: Define build path
id: define-build-path
run: |
DIR_PATH="dist/"
echo "dir-path: ${DIR_PATH}"
if [[ ! -d ${DIR_PATH} ]]; then
echo "Build folder {DIR_PATH} not found"
exit 1
fi
echo "dir-path=${DIR_PATH}" >> $GITHUB_OUTPUT
- name: Archive build artifact
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.package-name }}-pip-package-build
path: ${{ steps.define-build-path.outputs.dir-path }}