-
Notifications
You must be signed in to change notification settings - Fork 2
126 lines (114 loc) · 4.3 KB
/
Copy pathpython-nightly.yml
File metadata and controls
126 lines (114 loc) · 4.3 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
123
124
125
126
name: python-publish
on:
schedule:
- cron: '17 8 * * *'
workflow_dispatch:
inputs:
channel:
description: Package channel to publish
required: true
default: nightly
type: choice
options:
- nightly
- stable
concurrency:
group: python-publish-${{ inputs.channel || 'nightly' }}
cancel-in-progress: false
permissions:
contents: read
env:
NIGHTLY_VERSION: 0.3.0
jobs:
build:
runs-on: ubuntu-latest
outputs:
channel: ${{ steps.version.outputs.channel }}
version: ${{ steps.version.outputs.version }}
commit: ${{ steps.version.outputs.commit }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
with:
python-version: '3.12'
- name: Select the publication version
id: version
env:
DISPATCH_CHANNEL: ${{ inputs.channel }}
run: |
commit="$(git rev-parse --short=12 HEAD)"
source_version="$(python -c 'import cmax; print(cmax.__version__)')"
channel="${DISPATCH_CHANNEL:-nightly}"
case "$channel" in
stable)
version="$source_version"
;;
nightly)
date_utc="$(date -u +%Y%m%d)"
version="$(python .github/scripts/nightly_version.py \
--release-version "$NIGHTLY_VERSION" \
--date "$date_utc" \
--run-number "$GITHUB_RUN_NUMBER")"
;;
*)
echo "Unknown publication channel: $channel" >&2
exit 1
;;
esac
echo "channel=$channel" >> "$GITHUB_OUTPUT"
echo "commit=$commit" >> "$GITHUB_OUTPUT"
echo "source_version=$source_version" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "### ClusterMAX publication" >> "$GITHUB_STEP_SUMMARY"
echo "- Channel: \`$channel\`" >> "$GITHUB_STEP_SUMMARY"
echo "- Version: \`$version\`" >> "$GITHUB_STEP_SUMMARY"
echo "- Commit: \`$commit\`" >> "$GITHUB_STEP_SUMMARY"
- name: Build the distributions
env:
CLUSTERMAX_BUILD_VERSION: ${{ steps.version.outputs.version }}
SOURCE_VERSION: ${{ steps.version.outputs.source_version }}
run: |
python -m pip install \
--require-hashes \
--only-binary=:all: \
--disable-pip-version-check \
-r .github/requirements/release.txt
python -m build --no-isolation
python -m twine check dist/*
check-wheel-contents dist/clustermax-*.whl
test "$(python -c 'import cmax; print(cmax.__version__)')" = "$SOURCE_VERSION"
- name: Verify the wheel
env:
EXPECTED_VERSION: ${{ steps.version.outputs.version }}
run: |
python -m venv /tmp/clustermax-publication
/tmp/clustermax-publication/bin/pip install dist/clustermax-*.whl
cd /tmp
test "$(/tmp/clustermax-publication/bin/cmax --version)" = "cmax ${EXPECTED_VERSION}"
/tmp/clustermax-publication/bin/cmax audit --show
/tmp/clustermax-publication/bin/cmax audit security --show
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: clustermax-${{ steps.version.outputs.version }}-${{ steps.version.outputs.commit }}
path: dist/
if-no-files-found: error
retention-days: 14
publish:
if: github.repository == 'SemiAnalysisAI/ClusterMAX' && github.ref == 'refs/heads/master'
needs: build
runs-on: ubuntu-latest
environment:
name: ${{ needs.build.outputs.channel == 'nightly' && 'pypi-nightly' || 'pypi' }}
url: https://pypi.org/project/clustermax/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: clustermax-${{ needs.build.outputs.version }}-${{ needs.build.outputs.commit }}
path: dist/
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
with:
packages-dir: dist/