From ebfc293725350ae37a17558f797584db1528dd83 Mon Sep 17 00:00:00 2001 From: Jirka Date: Sat, 24 Dec 2022 08:28:10 +0100 Subject: [PATCH] update --- .github/actions/pkg-create/action.yml | 11 +++++++---- .github/workflows/check-package.yml | 22 ++++++++++++++++++---- .github/workflows/ci-use-checks.yml | 1 + .github/workflows/publish-pypi.yml | 20 +++++--------------- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/.github/actions/pkg-create/action.yml b/.github/actions/pkg-create/action.yml index 648e2881..44ad29db 100644 --- a/.github/actions/pkg-create/action.yml +++ b/.github/actions/pkg-create/action.yml @@ -4,7 +4,8 @@ description: building, checking the package inputs: artifact-name: description: 'Unique name for collecting artifacts' - required: true + required: false + default: "" env-vars: description: 'Define env variables as dictionary/JSON' required: false @@ -28,9 +29,8 @@ runs: - name: Create package 📦 env: ${{ fromJSON(inputs.env-vars) }} - run: | - python setup.py sdist bdist_wheel - # python setup.py clean + # python setup.py clean + run: python setup.py sdist bdist_wheel shell: bash - name: Check package 📦 @@ -41,16 +41,19 @@ runs: shell: bash - name: Download 📥 previous packages + if: ${{ inputs.artifact-name != '' }} uses: actions/download-artifact@v3 with: name: ${{ inputs.artifact-name }} path: pypi - name: copy/export pkg + if: ${{ inputs.artifact-name != '' }} run: cp dist/* pypi/ shell: bash - name: Upload 📤 to the share store + if: ${{ inputs.artifact-name != '' }} uses: actions/upload-artifact@v3 with: name: ${{ inputs.artifact-name }} diff --git a/.github/workflows/check-package.yml b/.github/workflows/check-package.yml index a586a3d5..5eab0393 100644 --- a/.github/workflows/check-package.yml +++ b/.github/workflows/check-package.yml @@ -3,6 +3,10 @@ name: Check package flow on: workflow_call: inputs: + actions-ref: + description: 'Version of actions, normally the same as workflow' + required: true + type: string artifact-name: description: 'Unique name for collecting artifacts' required: true @@ -70,9 +74,14 @@ jobs: with: python-version: 3.8 - # TODO: this breaks external use + - name: Pull re-usable 🤖 actions️ + uses: actions/checkout@v3 + with: + ref: ${{ inputs.actions-ref }} + path: .cicd + repository: Lightning-AI/utilities - name: Create package 📦 - uses: ./.github/actions/pkg-create + uses: ./.cicd/.github/actions/pkg-create with: artifact-name: ${{ inputs.artifact-name }} @@ -91,9 +100,14 @@ jobs: with: python-version: ${{ matrix.python-version }} - # TODO: this breaks external use + - name: Pull re-usable 🤖 actions️ + uses: actions/checkout@v3 + with: + ref: ${{ inputs.actions-ref }} + path: .cicd + repository: Lightning-AI/utilities - name: Installing package 📦 - uses: ./.github/actions/pkg-install + uses: ./.cicd/.github/actions/pkg-install with: artifact-name: ${{ inputs.artifact-name }} import-name: ${{ inputs.import-name }} diff --git a/.github/workflows/ci-use-checks.yml b/.github/workflows/ci-use-checks.yml index 1d9e91d4..60cd21c0 100644 --- a/.github/workflows/ci-use-checks.yml +++ b/.github/workflows/ci-use-checks.yml @@ -24,6 +24,7 @@ jobs: check-package: uses: ./.github/workflows/check-package.yml with: + actions-ref: ${{ github.sha }} # use local version artifact-name: dist-packages-${{ github.sha }} import-name: "lightning_utilities" diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 362eb8e0..06aa6537 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -7,6 +7,7 @@ on: # Trigger the workflow on push or pull request, but only for the master bra - 'v?[0-9]+.[0-9]+.[0-9]+' jobs: + # based on https://github.com/pypa/gh-action-pypi-publish build-package: runs-on: ubuntu-20.04 @@ -17,22 +18,12 @@ jobs: - name: Set up Python 🐍 uses: actions/setup-python@v4 with: - python-version: 3.8 - - - name: Install dependencies - run: >- - python -m pip install --user --upgrade setuptools wheel - - - name: Build packages - run: | - python setup.py sdist bdist_wheel - ls -lh dist/ + python-version: 3.8 - - name: Upload 📤 artifact - uses: actions/upload-artifact@v3 + - name: Create package 📦 + uses: ./.github/actions/pkg-create with: - name: pypi-packages-${{ github.sha }} - path: dist + artifact-name: pypi-packages-${{ github.sha }} upload-package: timeout-minutes: 5 @@ -72,7 +63,6 @@ jobs: run: ls -lh dist/ - name: Delay releasing - if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' uses: juliangruber/sleep-action@v1 with: time: 5m