From ca0d561993045ac18aa108bd5a5bd0837a979b51 Mon Sep 17 00:00:00 2001 From: Matthew Watkins Date: Sun, 28 Jul 2024 21:51:06 +0100 Subject: [PATCH] Fix: Broken workflow syntax Signed-off-by: Matthew Watkins --- .../increment-semantic-tag/action.yaml | 8 +- .../actions/python-matrix-builds/action.yaml | 145 ------------------ .../actions/python-project-build/action.yaml | 44 ++++++ .../action.yaml | 0 .github/workflows/test-gha-workflows.yaml | 14 +- 5 files changed, 56 insertions(+), 155 deletions(-) delete mode 100644 .github/actions/python-matrix-builds/action.yaml create mode 100644 .github/actions/python-project-build/action.yaml rename .github/actions/{twine-check-artefacts => python-twine-check}/action.yaml (100%) diff --git a/.github/actions/increment-semantic-tag/action.yaml b/.github/actions/increment-semantic-tag/action.yaml index 41a8e72..d13eb7e 100644 --- a/.github/actions/increment-semantic-tag/action.yaml +++ b/.github/actions/increment-semantic-tag/action.yaml @@ -56,10 +56,10 @@ runs: echo "Supplied tag: $TAG" fi - local RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)' - local MAJOR=$(echo "$TAG" | sed -e "s#$RE#\1#") - local MINOR=$(echo "$TAG" | sed -e "s#$RE#\2#") - local PATCH=$(echo "$TAG" | sed -e "s#$RE#\3#") + RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)' + MAJOR=$(echo "$TAG" | sed -e "s#$RE#\1#") + MINOR=$(echo "$TAG" | sed -e "s#$RE#\2#") + PATCH=$(echo "$TAG" | sed -e "s#$RE#\3#") case "$TYPE" in major) diff --git a/.github/actions/python-matrix-builds/action.yaml b/.github/actions/python-matrix-builds/action.yaml deleted file mode 100644 index 3936343..0000000 --- a/.github/actions/python-matrix-builds/action.yaml +++ /dev/null @@ -1,145 +0,0 @@ ---- -# SPDX-License-Identifier: Apache-2.0 -# SPDX-FileCopyrightText: 2024 The Linux Foundation - -name: "🧱 Python Builds (Matrix)" -description: "Builds Python packages" - -inputs: - output-location: - description: "Directory/folder path to Python build products" - required: false - default: "dist/" - versions-matrix: - description: "Python version matrix as JSON" - required: true - -runs: - using: "composite" - steps: - - name: "Populate environment variables" - id: setenv - shell: bash - run: | - echo "Action triggered by user: ${GITHUB_TRIGGERING_ACTOR}" - set -x - datetime=$(date +'%Y%m%d%H%M') - export datetime - echo "datetime=${datetime}" >> "$GITHUB_OUTPUT" - vernum="${{ inputs.versions-matrix }}.${datetime}" - echo "vernum=${vernum}" >> "$GITHUB_OUTPUT" - - - name: "Set up Python ${{ inputs.versions-matrix }}" - uses: actions/setup-python@v5 - with: - python-version: ${{ inputs.versions-matrix }} - - - name: "Setup PDM for build commands" - uses: pdm-project/setup-pdm@v4 - with: - python-version: ${{ inputs.versions-matrix }} - - - name: "Performing build" - shell: bash - run: | - python -m pip install --upgrade pip - if [ -f tox.ini ]; then - pip install tox tox-gh-actions - echo "Found file: tox.ini" - echo "Building with command: tox -e build" - tox -e build - elif [ -f pyproject.toml ]; then - echo "Found file: pyproject.toml" - echo "Building with command: pdm build" - pdm build - else - echo "Neither file found: tox.ini/pyproject.toml" - pip install --upgrade build - echo "Attempting build with: python -m build" - python -m build - fi - - - name: "Validate Artefacts with Twine" - id: twine-check-artefacts - with: - output-location: ${{ inputs.output-location}} - uses: os-climate/devops-reusable-workflows/.github/actions/twine-check-artefacts@main - - - name: "Determine Python versions" - id: parse-project-metadata - # yamllint disable-line rule:line-length - uses: os-climate/devops-reusable-workflows/.github/actions/python-versions-matrix@main - - build: - name: "Build: Python Package" - needs: [parse-project-metadata] - runs-on: "ubuntu-latest" - continue-on-error: true - # Don't run when pull request is merged - if: github.event.pull_request.merged == false - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.parse-project-metadata.outputs.matrix) }} - - steps: - - name: "Populate environment variables" - id: setenv - shell: bash - run: | - echo "Action triggered by user: ${GITHUB_TRIGGERING_ACTOR}" - set -x - datetime=$(date +'%Y%m%d%H%M') - export datetime - echo "datetime=${datetime}" >> "$GITHUB_OUTPUT" - vernum="${{ inputs.versions-matrix }}.${datetime}" - echo "vernum=${vernum}" >> "$GITHUB_OUTPUT" - - - name: "Checkout repository" - uses: actions/checkout@v4 - - - name: "Set up Python ${{ inputs.versions-matrix }}" - uses: actions/setup-python@v5 - with: - python-version: ${{ inputs.versions-matrix }} - - - name: "Setup PDM for build commands" - uses: pdm-project/setup-pdm@v4 - with: - python-version: ${{ inputs.versions-matrix }} - - - name: "Tag for test release" - # Delete all local tags, then create a synthetic tag for testing - # Use the date/time to avoid conflicts uploading to Test PyPI - shell: bash - run: | - scripts/dev-versioning.sh "${{ steps.setenv.outputs.vernum }}" - git tag | xargs -L 1 | xargs git tag --delete - git tag "v${{ steps.setenv.outputs.vernum }}" - git checkout "tags/v${{ steps.setenv.outputs.vernum }}" - grep version pyproject.toml - - - name: "Performing build" - shell: bash - run: | - python -m pip install --upgrade pip - if [ -f tox.ini ]; then - pip install tox tox-gh-actions - echo "Found file: tox.ini" - echo "Building with command: tox -e build" - tox -e build - elif [ -f pyproject.toml ]; then - echo "Found file: pyproject.toml" - echo "Building with command: pdm build" - pdm build - else - echo "Neither file found: tox.ini/pyproject.toml" - pip install --upgrade build - echo "Attempting build with: python -m build" - python -m build - fi - - - name: "Validate Artefacts with Twine" - id: twine-check-artefacts - with: - output-location: ${{ inputs.output-location}} - uses: os-climate/devops-reusable-workflows/.github/actions/twine-check-artefacts@main diff --git a/.github/actions/python-project-build/action.yaml b/.github/actions/python-project-build/action.yaml new file mode 100644 index 0000000..39d8f37 --- /dev/null +++ b/.github/actions/python-project-build/action.yaml @@ -0,0 +1,44 @@ +--- +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2024 The Linux Foundation + +name: "🧱 Python Build" +description: "Build Python Project" + +inputs: + artefacts: + description: "Path to Python build artefacts" + required: false + default: "dist" + +runs: + using: "composite" + steps: + - name: "Populate environment variables" + id: setenv + shell: bash + run: | + echo "Action triggered by user: ${GITHUB_TRIGGERING_ACTOR}" + datetime=$(date +'%Y%m%d%H%M') + export datetime + echo "datetime=${datetime}" >> "$GITHUB_OUTPUT" + + - name: "Performing build" + shell: bash + run: | + python -m pip install --upgrade pip + if [ -f tox.ini ]; then + pip install tox tox-gh-actions + echo "Found file: tox.ini" + echo "Building with command: tox -e build" + tox -e build + elif [ -f pyproject.toml ]; then + echo "Found file: pyproject.toml" + echo "Building with command: pdm build" + pdm build + else + echo "Neither file found: tox.ini/pyproject.toml" + pip install --upgrade build + echo "Attempting build with: python -m build" + python -m build + fi diff --git a/.github/actions/twine-check-artefacts/action.yaml b/.github/actions/python-twine-check/action.yaml similarity index 100% rename from .github/actions/twine-check-artefacts/action.yaml rename to .github/actions/python-twine-check/action.yaml diff --git a/.github/workflows/test-gha-workflows.yaml b/.github/workflows/test-gha-workflows.yaml index 62a63d3..f5b569f 100644 --- a/.github/workflows/test-gha-workflows.yaml +++ b/.github/workflows/test-gha-workflows.yaml @@ -77,21 +77,23 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: "Setup PDM for build commands" + - name: "Setup PDM Build Tool" uses: pdm-project/setup-pdm@v4 with: python-version: ${{ matrix.python-version }} - - name: "Build: Python project" - id: perform-matrix-builds + - name: "Build: Python Project" + id: python-project-build # yamllint disable-line rule:line-length - uses: os-climate/devops-reusable-workflows/.github/actions/python-matrix-builds@main + uses: os-climate/devops-reusable-workflows/.github/actions/python-project-build@main + with: + artefacts: "dist" - name: "Validate Artefacts with Twine" - id: twine-check-artefacts + id: python-twine-check with: output-location: ${{ env.artefacts}} - uses: os-climate/devops-reusable-workflows/.github/actions/twine-check-artefacts@main + uses: os-climate/devops-reusable-workflows/.github/actions/python-twine-check@main test: name: "Test: GitHub Actions/Workflows"