From 11118fe9359244e1e1b0671beda47ebf0900edfb Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Wed, 7 Feb 2024 15:46:31 -0600 Subject: [PATCH] ci: Add workflow to upload nightly wheels to Anaconda Cloud * On a schedule that follows _after_ the schedule job for the packaging tests workflow, use the gh command line API to find the latest run of the packaging tests workflow. Filtering on 'schedule' events to find the latest schedule run, extract the run id, and then use that to download all of the 'awkward-wheel' and 'awkward-cpp-wheels-*' artifacts from the workflow. * Use the scientific-python/upload-nightly-action GitHub Action to then upload these wheels to the scikit-hep-nightly-wheels Anaconda Cloud organization registry. - c.f. https://github.com/scientific-python/upload-nightly-action - c.f. https://anaconda.org/scikit-hep-nightly-wheels --- .github/workflows/upload_nightly_wheels.yml | 65 +++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/upload_nightly_wheels.yml diff --git a/.github/workflows/upload_nightly_wheels.yml b/.github/workflows/upload_nightly_wheels.yml new file mode 100644 index 0000000000..d05cfcf412 --- /dev/null +++ b/.github/workflows/upload_nightly_wheels.yml @@ -0,0 +1,65 @@ +name: Upload nightly wheels to Anaconda Cloud + +on: + # Run daily at 2:34 UTC to upload nightly wheels to Anaconda Cloud + schedule: + - cron: '34 2 * * *' + # Run on demand with workflow dispatch + workflow_dispatch: + +permissions: + actions: read + +jobs: + upload_nightly_wheels: + name: Upload nightly wheels to Anaconda Cloud + runs-on: ubuntu-latest + defaults: + run: + # The login shell is necessary for the setup-micromamba setup + # to work in subsequent jobs. + # https://github.com/mamba-org/setup-micromamba#about-login-shells + shell: bash -e -l {0} + if: github.repository_owner == 'scikit-hep' + + steps: + # https://github.com/actions/download-artifact/issues/3#issuecomment-1017141067 + - name: Download wheel artifacts from last build on 'main' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PROJECT_REPO="scikit-hep/awkward" + BRANCH="main" + WORKFLOW_NAME="packaging-test.yml" + ARTIFACT_PATTERN="awkward*wheel*" # awkward-wheel and awkward-cpp-wheels-* + + gh run --repo "${PROJECT_REPO}" \ + list --branch "${BRANCH}" \ + --workflow "${WORKFLOW_NAME}" \ + --json event,status,conclusion,databaseId > runs.json + RUN_ID=$( + jq --compact-output \ + '[ + .[] | + # Filter on "schedule" events to main (nightly build) ... + select(.event == "schedule") | + # that have completed successfully ... + select(.status == "completed" and .conclusion == "success") + ] | + # and get ID of latest build of wheels. + sort_by(.databaseId) | reverse | .[0].databaseId' runs.json + ) + gh run --repo "${PROJECT_REPO}" view "${RUN_ID}" + gh run --repo "${PROJECT_REPO}" \ + download "${RUN_ID}" --pattern "${ARTIFACT_PATTERN}" + + mkdir dist + mv ${ARTIFACT_PATTERN}/*.whl dist/ + ls -l dist/ + + - name: Upload wheels to Anaconda Cloud as nightlies + uses: scientific-python/upload-nightly-action@6e9304f7a3a5501c6f98351537493ec898728299 # 0.3.0 + with: + artifacts_path: dist + anaconda_nightly_upload_organization: scikit-hep-nightly-wheels + anaconda_nightly_upload_token: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }}