-
Notifications
You must be signed in to change notification settings - Fork 872
134 lines (121 loc) · 5.33 KB
/
wheel_distributing.yml
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
123
124
125
126
127
128
129
130
131
132
133
134
name: Build and publish wheel distribution
on:
workflow_call:
inputs:
ReleaseType:
type: string
default: "Test"
required: false
description: 'Official release or test'
UploadAsLatest:
type: string
default: "False"
required: false
description: 'Also publish the wheel distribution to internal pypi index as latest'
SourceFolderName:
type: string
required: true
description: 'The source folder name of the package to be built'
ConfigsFolderPath:
type: string
default: "scripts/distributing/configs"
required: false
description: 'Configs folder path'
outputs:
PackageVersion:
description: 'The version of the package'
value: ${{ jobs.sdk_release.outputs.PackageVersion }}
jobs:
sdk_release:
runs-on: ubuntu-latest
name: Build and publish wheel distribution
outputs:
PackageVersion: ${{ steps.override_version.outputs.version }}
steps:
- name: Check input parameters
run: |
echo "ReleaseType: ${{ inputs.ReleaseType }}"
echo "UploadAsLatest: ${{ inputs.UploadAsLatest }}"
echo "SourceFolderName: ${{ inputs.SourceFolderName }}"
echo "ConfigsFolderPath: ${{ inputs.ConfigsFolderPath }}"
- name: Checkout repo
uses: actions/checkout@v3
with:
ref: ${{ github.event_name == 'push' && 'main' || github.event.inputs.branch }}
submodules: true
- name: Override version with workflow run number
id: override_version
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.ReleaseType == 'Test')
run: |
echo "VERSION = \"0.0.${{ github.run_number }}\"" > src/${{ inputs.SourceFolderName }}/promptflow/version.txt
echo "VERSION: 0.0.${{ github.run_number }}"
echo "version=0.0.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
- name: Set up conda environment
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
activate-environment: release-env
environment-file: ${{ inputs.ConfigsFolderPath }}/${{ inputs.SourceFolderName }}-release-env.yaml
auto-update-conda: true
auto-activate-base: false
- name: Show conda info
shell: bash -l {0}
run: |
conda activate release-env
conda info
conda list
conda config --show-sources
conda config --show
python --version
- name: Delete existing packages in the 'dist' folder
working-directory: src/${{ inputs.SourceFolderName }}/
shell: bash
run: |
echo "Delete existing packages in the 'dist' directory of '${{ inputs.SourceFolderName }}/'"
rm -f ./dist/*
if [ $? != 0 ]; then
echo "Failed to delete existing dist folder for '${{ inputs.SourceFolderName }}/'"
exit 1
fi
- name: Build wheel
working-directory: src/${{ inputs.SourceFolderName }}/
shell: bash -l {0}
run: |
conda activate release-env
echo "Build wheel for '${{ inputs.SourceFolderName }}/'"
python setup.py bdist_wheel -b bdist
echo "List files in 'dist'"
cd dist
pwd
ls
# Need to enbale the check after fixing `long_description` syntax errors
- name: Twine check for artifact
if: false
working-directory: src/${{ inputs.SourceFolderName }}/
shell: bash -l {0}
run: |
conda activate release-env
echo "Listing the wheels under '${{ inputs.SourceFolderName }}\dist\*.whl'"
ls dist/*.whl
echo "Twine check for artifact: ${{ inputs.SourceFolderName }}"
last_dist=$(ls -t dist/*.whl | head -n 1)
twine check "$last_dist" --strict
- name: Generate SBOM
working-directory: src/${{ inputs.SourceFolderName }}/
run: |
echo "Generate SBOM for '${{ inputs.SourceFolderName }}\dist\'"
curl -Lo $RUNNER_TEMP/sbom-tool https://github.com/microsoft/sbom-tool/releases/latest/download/sbom-tool-linux-x64
chmod +x $RUNNER_TEMP/sbom-tool
$RUNNER_TEMP/sbom-tool generate -b ./dist -bc . -pn Test -pv 1.0.0 -ps MyCompany -nsb https://sbom.mycompany.com -V Verbose
- name: Official release
if: inputs.ReleaseType == 'Release'
shell: bash -l {0}
run: |
conda activate release-env
python scripts/distributing/publish_package.py --config ${{ inputs.ConfigsFolderPath }}/distribution_settings.json --src_folder_name ${{ inputs.SourceFolderName }} --package_dir_path src/${{ inputs.SourceFolderName }}/dist --storage_key ${{ secrets.PACKAGE_STORAGE_KEY }} --upload_as_latest ${{ inputs.UploadAsLatest }}
- name: Test release
if: inputs.ReleaseType == 'Test'
shell: bash -l {0}
run: |
conda activate release-env
python scripts/distributing/publish_package.py --config ${{ inputs.ConfigsFolderPath }}/distribution_settings.json --src_folder_name ${{ inputs.SourceFolderName }} --package_dir_path src/${{ inputs.SourceFolderName }}/dist --storage_key ${{ secrets.PACKAGE_STORAGE_KEY }} --upload_as_latest ${{ inputs.UploadAsLatest }} --release_type test