Skip to content

Commit 45628a2

Browse files
authored
Build and upload weekly nightly wheels (#146)
1 parent 70f3dd7 commit 45628a2

1 file changed

Lines changed: 49 additions & 3 deletions

File tree

.github/workflows/cibuildwheel.yml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
branches: [main]
66
pull_request:
77
branches: ["*"]
8+
schedule: # runs on last commit on main branch
9+
- cron: "0 1 * * 1" # every Monday at 1AM, for weekly wheels
810
workflow_dispatch: # allows you to trigger manually
911

1012
# When this workflow is queued, automatically cancel any previous running
@@ -14,8 +16,39 @@ concurrency:
1416
cancel-in-progress: true
1517

1618
jobs:
19+
maybe_skip_scheduled:
20+
name: Determine whether to skip scheduled run
21+
runs-on: ubuntu-latest
22+
outputs:
23+
skip: ${{ env.skip }}
24+
steps:
25+
- name: On explosion main, skip scheduled run if no changes in last week
26+
if: github.event_name == 'schedule' && github.repository_owner == 'explosion'
27+
run: |
28+
LAST_COMMIT_TIME=$(git log -1 --format=%ct)
29+
CURRENT_TIME=$(date +%s)
30+
TIME_DIFF=$((CURRENT_TIME - LAST_COMMIT_TIME))
31+
echo "Time since last commit: $TIME_DIFF seconds"
32+
if [ $TIME_DIFF -gt 604800 ]; then
33+
echo "No changes in the last week. Skipping build."
34+
echo "skip=true" >> $GITHUB_ENV
35+
else
36+
echo "Changes detected in the last week. Proceeding with build."
37+
echo "skip=false" >> $GITHUB_ENV
38+
fi
39+
40+
- name: Always skip scheduled runs on forks
41+
if: github.event_name == 'schedule' && github.repository_owner != 'explosion'
42+
run: echo "skip=true" >> $GITHUB_ENV
43+
44+
- name: Never skip non-scheduled runs
45+
if: github.event_name != 'schedule'
46+
run: echo "skip=false" >> $GITHUB_ENV
47+
1748
build_wheels:
1849
name: Build wheels on ${{ matrix.os }}
50+
needs: maybe_skip_scheduled
51+
if: needs.maybe_skip_scheduled.outputs.skip == 'false'
1952
runs-on: ${{ matrix.os }}
2053
strategy:
2154
fail-fast: true
@@ -84,6 +117,8 @@ jobs:
84117

85118
build_sdist:
86119
name: Build source distribution
120+
needs: maybe_skip_scheduled
121+
if: needs.maybe_skip_scheduled.outputs.skip == 'false'
87122
runs-on: ubuntu-latest
88123
steps:
89124
- uses: actions/checkout@v6
@@ -97,7 +132,8 @@ jobs:
97132
path: dist/*.tar.gz
98133

99134
create_release:
100-
needs: [build_wheels, build_sdist]
135+
needs: [maybe_skip_scheduled, build_wheels, build_sdist]
136+
if: needs.maybe_skip_scheduled.outputs.skip == 'false'
101137
runs-on: ubuntu-latest
102138
permissions:
103139
contents: write
@@ -133,15 +169,25 @@ jobs:
133169
pattern: cibw-*
134170
path: dist
135171
merge-multiple: true
136-
172+
173+
- name: List dist directory
174+
run: ls -l dist
175+
137176
- name: Create Draft Release
138177
id: create_release
139178
uses: softprops/action-gh-release@v2
140-
if: startsWith(github.ref, 'refs/tags/release-') || startsWith(github.ref, 'refs/tags/prerelease-')
179+
if: (startsWith(github.ref, 'refs/tags/release-') || startsWith(github.ref, 'refs/tags/prerelease-')) && github.event_name != 'schedule' && github.repository_owner == 'explosion'
141180
env:
142181
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143182
with:
144183
name: ${{ env.TAG_NAME }}
145184
draft: true
146185
prerelease: ${{ env.IS_PRERELEASE }}
147186
files: "./dist/*"
187+
188+
- name: Upload nightly wheels
189+
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.repository_owner == 'explosion' && github.ref == 'refs/heads/main'
190+
uses: scientific-python/upload-nightly-action@b36e8c0c10dbcfd2e05bf95f17ef8c14fd708dbf # 0.6.2
191+
with:
192+
artifacts_path: dist
193+
anaconda_nightly_upload_token: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }}

0 commit comments

Comments
 (0)