diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml new file mode 100644 index 0000000..f7a1601 --- /dev/null +++ b/.github/workflows/_build.yml @@ -0,0 +1,41 @@ +--- +name: _build + +on: + workflow_call: + inputs: + python_version: + description: The Python version. + type: string + required: false + default: '3.11' + runs_on: + description: The runner environment. + type: string + required: false + default: ubuntu-latest + outputs: + artifact_name: + description: The artifact name. + value: build-${{ github.sha }} + +jobs: + build: + name: Package + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup + uses: ./.github/actions/setup + with: + python_version: ${{ inputs.python_version }} + - name: Build + run: make build + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: build-${{ github.sha }} + if-no-files-found: error + path: dist/ diff --git a/.github/workflows/_publish.yml b/.github/workflows/_publish.yml index 658fdfd..6f58c70 100644 --- a/.github/workflows/_publish.yml +++ b/.github/workflows/_publish.yml @@ -3,6 +3,11 @@ name: _publish on: workflow_call: + inputs: + artifact_name: + description: The artifact name. + type: string + required: true secrets: registry_token: description: The package registry token. @@ -20,10 +25,10 @@ jobs: uses: ./.github/actions/setup with: install_dependencies: 'false' - - name: Download artifacts + - name: Download artifact uses: actions/download-artifact@v3 with: - name: ${{ github.sha }} + name: ${{ inputs.artifact_name }} path: dist/ - name: Publish run: poetry publish --skip-existing -u $USERNAME -p $PASSWORD diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 8ff3d2d..ebe7481 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -58,8 +58,10 @@ jobs: run: make lint build: name: Build (Python ${{ matrix.python }} on ${{ matrix.os_name }}) - runs-on: ${{ matrix.os }} - timeout-minutes: 30 + uses: ./.github/workflows/_build.yml + with: + python_version: ${{ matrix.python }} + runs_on: ${{ matrix.os }} strategy: fail-fast: false matrix: @@ -77,12 +79,45 @@ jobs: os_name: macOS - os: windows-latest os_name: Windows + install: + name: Install (Python ${{ matrix.python }} on ${{ matrix.os_name }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + needs: build + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + python: + - '3.10' + - '3.11' + include: + - os: ubuntu-latest + os_name: Linux + - os: macos-latest + os_name: macOS steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup - uses: ./.github/actions/setup + - name: Setup Python + uses: actions/setup-python@v4 with: - python_version: ${{ matrix.python }} - - name: Build - run: make build + python-version: ${{ matrix.python }} + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: ${{ needs.build.outputs.artifact_name }} + path: . + - name: Get meta + id: meta + run: echo "whl=$(ls *.whl | head -n1)" >> $GITHUB_OUTPUT + - name: Install + run: pip install $PACKAGE + env: + PACKAGE: ${{ steps.meta.outputs.whl }} + - name: Import + run: echo "import $PACKAGE_IMPORT_NAME" > main.py + env: + PACKAGE_IMPORT_NAME: makenew_pypackage + - name: Run + run: python main.py diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index de2848b..e644605 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,35 +9,21 @@ on: - v* jobs: - artifacts: - name: Build artifacts - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup - uses: ./.github/actions/setup - - name: Build - run: make build - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ github.sha }} - if-no-files-found: error - path: dist/ + build: + name: Build + uses: ./.github/workflows/_build.yml release: name: GitHub Releases runs-on: ubuntu-latest timeout-minutes: 30 - needs: artifacts + needs: build steps: - name: Checkout uses: actions/checkout@v3 - - name: Download artifacts + - name: Download artifact uses: actions/download-artifact@v3 with: - name: ${{ github.sha }} + name: ${{ needs.build.outputs.artifact_name }} path: dist/ - name: Create GitHub release uses: softprops/action-gh-release@v1 @@ -49,6 +35,8 @@ jobs: pypi: name: PyPI uses: ./.github/workflows/_publish.yml - needs: artifacts + needs: build + with: + artifact_name: ${{ needs.build.outputs.artifact_name }} secrets: registry_token: ${{ secrets.PYPI_API_TOKEN }}