aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/release.yml
blob: fb948c2652d4437927585ea3cce74c3c8fd3ae68 (about) (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Release

on:
  pull_request:
    branches:
      - "master"
      - "ci"
      - "[0-9]+.[0-9x]+*"
    paths:
      - "immutables/_version.py"

jobs:
  validate-release-request:
    runs-on: ubuntu-latest
    steps:
    - name: Validate release PR
      uses: edgedb/action-release/validate-pr@master
      id: checkver
      with:
        github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
        version_file: immutables/_version.py
        version_line_pattern: |
          __version__\s*=\s*(?:['"])([[:PEP440:]])(?:['"])

    - name: Stop if not approved
      if: steps.checkver.outputs.approved != 'true'
      run: |
        echo ::error::PR is not approved yet.
        exit 1

    - name: Store release version for later use
      env:
        VERSION: ${{ steps.checkver.outputs.version }}
      run: |
        mkdir -p dist/
        echo "${VERSION}" > dist/VERSION

    - uses: actions/upload-artifact@v2
      with:
        name: dist
        path: dist/

  build-sdist:
    needs: validate-release-request
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 50
        submodules: true

    - uses: actions/setup-python@v2

    - name: Build source distribution
      run: |
        python -m pip install -U setuptools wheel pip
        python setup.py sdist

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

  build-wheels:
    needs: validate-release-request
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        cibw_arch: [auto]
        include:
          - os: ubuntu-latest
            cibw_arch: aarch64
          - os: macos-latest
            cibw_arch: universal2

    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 50
        submodules: true

    - name: Set up QEMU
      if: matrix.os == 'ubuntu-latest' && matrix.cibw_arch == 'aarch64'
      uses: docker/setup-qemu-action@v1
      with:
        platforms: arm64

    - uses: pypa/cibuildwheel@v2.0.1
      env:
        CIBW_BUILD_VERBOSITY: 1
        CIBW_BUILD: "cp36-* cp37-* cp38-* cp39-*"
        CIBW_ARCHS: ${{ matrix.cibw_arch }}
        CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux1_x86_64
        CIBW_MANYLINUX_I686_IMAGE: quay.io/pypa/manylinux1_i686
        CIBW_SKIP: "pp*"
        CIBW_TEST_EXTRAS: "test"
        CIBW_TEST_COMMAND: "cd .. && python {project}/tests/__init__.py"
        CIBW_TEST_COMMAND_WINDOWS: "cd .. && python {project}\\tests\\__init__.py"
        CIBW_TEST_SKIP: "*universal2:arm64"
        CIBW_ENVIRONMENT: "IMMU_SKIP_MYPY_TESTS=1"

    - uses: actions/upload-artifact@v2
      with:
        name: dist
        path: wheelhouse/*.whl

  publish:
    needs: [build-sdist, build-wheels]
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 5
        submodules: false

    - uses: actions/download-artifact@v2
      with:
        name: dist
        path: dist/

    - name: Extract Release Version
      id: relver
      run: |
        set -e
        echo ::set-output name=version::$(cat dist/VERSION)
        rm dist/VERSION

    - name: Merge and tag the PR
      uses: edgedb/action-release/merge@master
      with:
        github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
        ssh_key: ${{ secrets.RELEASE_BOT_SSH_KEY }}
        gpg_key: ${{ secrets.RELEASE_BOT_GPG_KEY }}
        gpg_key_id: "5C468778062D87BF!"
        tag_name: v${{ steps.relver.outputs.version }}

    - name: Publish Github Release
      uses: elprans/gh-action-create-release@master
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: v${{ steps.relver.outputs.version }}
        release_name: v${{ steps.relver.outputs.version }}
        target: ${{ github.event.pull_request.base.ref }}
        body: ${{ github.event.pull_request.body }}
        draft: false

    - run: |
        ls -al dist/

    - name: Upload to PyPI
      uses: pypa/gh-action-pypi-publish@master
      with:
        user: __token__
        password: ${{ secrets.PYPI_TOKEN }}
        # password: ${{ secrets.TEST_PYPI_TOKEN }}
        # repository_url: https://test.pypi.org/legacy/