summaryrefslogtreecommitdiffstats
path: root/.github/workflows/release.yml
blob: 59062ae8c1d2cbd04cce61a819809027e04dc75d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Release

on:
  push:
    tags:
      - '*.*.*'

jobs:

  build:
    name: Build wheels on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}-latest
    strategy:
      matrix:
        os: [ ubuntu, windows, macos ]

    steps:
      - uses: actions/checkout@v3

      - name: Build wheels
        uses: pypa/cibuildwheel@v2.10.1
        env:
          CIBW_PROJECT_REQUIRES_PYTHON: ">=3.7"
        with:
          package-dir: .
          output-dir: dist

      - uses: actions/upload-artifact@v3
        with:
          name: dist
          path: ./dist/*

  Release:
    needs: [ build ]
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Download artifacts
        uses: actions/download-artifact@v3
        with:
          name: dist
          path: dist

      - name: Install Poetry
        run: |
          curl -fsS https://install.python-poetry.org | python - -y

      - name: Update PATH
        run: echo "$HOME/.local/bin" >> $GITHUB_PATH

      - name: Build sdist
        run: poetry build --format sdist

      - name: Check distributions
        run: |
          ls -la dist

      - name: Check Version
        id: check-version
        run: |
          [[ "${GITHUB_REF#refs/tags/}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \
            || echo ::set-output name=prerelease::true

      - name: Create Release
        uses: ncipollo/release-action@v1
        with:
          artifacts: "dist/*"
          token: ${{ secrets.GITHUB_TOKEN }}
          draft: false
          prerelease: steps.check-version.outputs.prerelease == 'true'

      - name: Publish to PyPI
        env:
          POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
        run: |
          poetry publish