Skip to content

Commit 85af8df

Browse files
committed
Add Github release workflow
1 parent 6025226 commit 85af8df

File tree

9 files changed

+317
-8
lines changed

9 files changed

+317
-8
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -e -x
4+
5+
PY_MAJOR=${PYTHON_VERSION%%.*}
6+
PY_MINOR=${PYTHON_VERSION#*.}
7+
8+
ML_PYTHON_VERSION="cp${PY_MAJOR}${PY_MINOR}-cp${PY_MAJOR}${PY_MINOR}"
9+
if [ "${PY_MAJOR}" -lt "4" -a "${PY_MINOR}" -lt "8" ]; then
10+
ML_PYTHON_VERSION+="m"
11+
fi
12+
13+
# Compile wheels
14+
PYTHON="/opt/python/${ML_PYTHON_VERSION}/bin/python"
15+
PIP="/opt/python/${ML_PYTHON_VERSION}/bin/pip"
16+
"${PIP}" install --upgrade setuptools pip wheel
17+
cd "${GITHUB_WORKSPACE}"
18+
make clean
19+
"${PYTHON}" setup.py bdist_wheel
20+
21+
# Bundle external shared libraries into the wheels.
22+
for whl in "${GITHUB_WORKSPACE}"/dist/*.whl; do
23+
auditwheel repair $whl -w "${GITHUB_WORKSPACE}"/dist/
24+
rm "${GITHUB_WORKSPACE}"/dist/*-linux_*.whl
25+
done
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Trigger Release
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
7+
jobs:
8+
check-review:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Validate release PR
12+
uses: edgedb/action-release/validate-pr@master
13+
id: release
14+
continue-on-error: true
15+
with:
16+
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
17+
version_file: immutables/_version.py
18+
version_line_pattern: |
19+
__version__\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
20+
- name: Trigger release
21+
uses: edgedb/action-release/trigger@master
22+
if: steps.release.outputs.version != 0
23+
with:
24+
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
25+
release_validation_check: "validate-release-request"

.github/workflows/release.yml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "master"
7+
- "ci"
8+
- "[0-9]+.[0-9x]+*"
9+
paths:
10+
- "immutables/_version.py"
11+
12+
jobs:
13+
validate-release-request:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Validate release PR
17+
uses: edgedb/action-release/validate-pr@master
18+
id: checkver
19+
with:
20+
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
21+
version_file: immutables/_version.py
22+
version_line_pattern: |
23+
__version__\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
24+
25+
- name: Stop if not approved
26+
if: steps.checkver.outputs.approved != 'true'
27+
run: |
28+
echo ::error::PR is not approved yet.
29+
exit 1
30+
31+
- name: Store release version for later use
32+
env:
33+
VERSION: ${{ steps.checkver.outputs.version }}
34+
run: |
35+
mkdir -p dist/
36+
echo "${VERSION}" > dist/VERSION
37+
38+
- uses: actions/upload-artifact@v1
39+
with:
40+
name: dist
41+
path: dist/
42+
43+
build-sdist:
44+
needs: validate-release-request
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- uses: actions/checkout@v1
49+
with:
50+
fetch-depth: 50
51+
submodules: true
52+
53+
- name: Set up Python 3.7
54+
uses: actions/setup-python@v1
55+
with:
56+
python-version: 3.7
57+
58+
- name: Build source distribution
59+
run: |
60+
pip install -U setuptools wheel pip
61+
python setup.py sdist
62+
63+
- uses: actions/upload-artifact@v1
64+
with:
65+
name: dist
66+
path: dist/
67+
68+
build-wheels:
69+
needs: validate-release-request
70+
runs-on: ${{ matrix.os }}
71+
strategy:
72+
matrix:
73+
python-version: [3.5, 3.6, 3.7, 3.8]
74+
os: [ubuntu-16.04, macos-latest, windows-latest]
75+
exclude:
76+
# Python 3.5 is unable to properly
77+
# find the recent VS tooling
78+
# https://bugs.python.org/issue30389
79+
- os: windows-latest
80+
python-version: 3.5
81+
82+
steps:
83+
- uses: actions/checkout@v1
84+
with:
85+
fetch-depth: 50
86+
submodules: true
87+
88+
- name: Set up Python ${{ matrix.python-version }}
89+
uses: actions/setup-python@v1
90+
with:
91+
python-version: ${{ matrix.python-version }}
92+
93+
- name: Install Python Deps
94+
run: |
95+
python -m pip install --upgrade setuptools pip wheel
96+
97+
- name: Test
98+
run: |
99+
make debug && make test
100+
101+
- name: Build Wheels (linux)
102+
if: startsWith(matrix.os, 'ubuntu')
103+
uses: docker://quay.io/pypa/manylinux1_x86_64
104+
env:
105+
PYTHON_VERSION: ${{ matrix.python-version }}
106+
with:
107+
entrypoint: /github/workspace/.github/workflows/build-manylinux-wheels.sh
108+
109+
- name: Build Wheels (non-linux)
110+
if: "!startsWith(matrix.os, 'ubuntu')"
111+
run: |
112+
make clean
113+
python setup.py bdist_wheel
114+
115+
- name: Test Wheels
116+
shell: bash
117+
if: |
118+
!contains(github.event.pull_request.labels.*.name, 'skip wheel tests')
119+
run: |
120+
pip install --pre immutables -f "file:///${GITHUB_WORKSPACE}/dist"
121+
make -C "${GITHUB_WORKSPACE}" testinstalled
122+
123+
- uses: actions/upload-artifact@v1
124+
with:
125+
name: dist
126+
path: dist/
127+
128+
publish:
129+
needs: [build-sdist, build-wheels]
130+
runs-on: ubuntu-latest
131+
132+
steps:
133+
- uses: actions/checkout@v1
134+
with:
135+
fetch-depth: 5
136+
submodules: false
137+
138+
- uses: actions/download-artifact@v1
139+
with:
140+
name: dist
141+
path: dist/
142+
143+
- name: Extract Release Version
144+
id: relver
145+
run: |
146+
set -e
147+
echo ::set-output name=version::$(cat dist/VERSION)
148+
rm dist/VERSION
149+
150+
- name: Merge and tag the PR
151+
uses: edgedb/action-release/merge@master
152+
with:
153+
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
154+
ssh_key: ${{ secrets.RELEASE_BOT_SSH_KEY }}
155+
gpg_key: ${{ secrets.RELEASE_BOT_GPG_KEY }}
156+
gpg_key_id: "5C468778062D87BF!"
157+
tag_name: v${{ steps.relver.outputs.version }}
158+
159+
- name: Publish Github Release
160+
uses: elprans/gh-action-create-release@master
161+
env:
162+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163+
with:
164+
tag_name: v${{ steps.relver.outputs.version }}
165+
release_name: v${{ steps.relver.outputs.version }}
166+
target: ${{ github.event.pull_request.base.ref }}
167+
body: ${{ github.event.pull_request.body }}
168+
draft: false
169+
170+
- run: |
171+
ls -al dist/
172+
173+
- name: Upload to PyPI
174+
uses: pypa/gh-action-pypi-publish@master
175+
with:
176+
user: __token__
177+
password: ${{ secrets.PYPI_TOKEN }}
178+
# password: ${{ secrets.TEST_PYPI_TOKEN }}
179+
# repository_url: https://test.pypi.org/legacy/

.github/workflows/tests.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- ci
8+
pull_request:
9+
branches:
10+
- master
11+
12+
jobs:
13+
test:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
max-parallel: 4
17+
matrix:
18+
python-version: [3.6, 3.7, 3.8]
19+
os: [ubuntu-latest, macos-latest]
20+
21+
steps:
22+
- uses: actions/checkout@v1
23+
with:
24+
fetch-depth: 50
25+
submodules: true
26+
27+
- name: Check if release PR.
28+
uses: edgedb/action-release/validate-pr@master
29+
continue-on-error: true
30+
id: release
31+
with:
32+
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
33+
version_file: immutables/_version.py
34+
version_line_pattern: |
35+
__version__\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
36+
37+
- name: Set up Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v1
39+
if: steps.release.outputs.version == 0
40+
with:
41+
python-version: ${{ matrix.python-version }}
42+
43+
- name: Install Python Deps
44+
if: steps.release.outputs.version == 0
45+
run: |
46+
pip install --upgrade setuptools pip wheel
47+
pip download --dest=/tmp/deps .[test]
48+
pip install -U --no-index --find-links=/tmp/deps /tmp/deps/*
49+
50+
- name: Test
51+
if: steps.release.outputs.version == 0
52+
run: |
53+
make debug && make test

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ __pycache__/
1919
/.cache
2020
/.pytest_cache
2121
/.coverage
22-
22+
/.mypy_cache

Makefile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
.PHONY: rtest build test clean
1+
.PHONY: rtest build test clean all
22

33

4+
PYTHON ?= python
5+
ROOT = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
6+
7+
8+
all: build
9+
410
build:
5-
python setup.py build_ext --inplace
11+
$(PYTHON) setup.py build_ext --inplace
12+
13+
debug:
14+
DEBUG_IMMUTABLES=1 $(PYTHON) setup.py build_ext --inplace
615

716
test:
8-
python setup.py test -v
17+
$(PYTHON) setup.py test -v
918

1019
rtest:
1120
~/dev/venvs/36-debug/bin/python setup.py build_ext --inplace
@@ -14,8 +23,11 @@ rtest:
1423
~/dev/venvs/36-debug/bin/python -m test.regrtest -R3:3 --testdir tests/
1524

1625
clean:
17-
find . -name '*.pyc' | xargs rm
18-
find . -name '*.so' | xargs rm
26+
find . -name '*.pyc' | xargs rm -f
27+
find . -name '*.so' | xargs rm -f
1928
rm -rf ./build
2029
rm -rf ./dist
2130
rm -rf ./*.egg-info
31+
32+
testinstalled:
33+
cd /tmp && $(PYTHON) $(ROOT)/tests/__init__.py

immutables/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# flake8: noqa
2+
13
try:
24
from ._map import Map
35
except ImportError:
@@ -6,6 +8,6 @@
68
import collections.abc as _abc
79
_abc.Mapping.register(Map)
810

11+
from ._version import __version__
912

1013
__all__ = 'Map',
11-
__version__ = '0.12'

immutables/_version.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file MUST NOT contain anything but the __version__ assignment.
2+
#
3+
# When making a release, change the value of __version__
4+
# to an appropriate value, and open a pull request against
5+
# the correct branch (master if making a new feature release).
6+
# The commit message MUST contain a properly formatted release
7+
# log, and the commit must be signed.
8+
#
9+
# The release automation will: build and test the packages for the
10+
# supported platforms, publish the packages on PyPI, merge the PR
11+
# to the target branch, create a Git tag pointing to the commit.
12+
13+
__version__ = '0.12'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
with open(os.path.join(
13-
os.path.dirname(__file__), 'immutables', '__init__.py')) as f:
13+
os.path.dirname(__file__), 'immutables', '_version.py')) as f:
1414
for line in f:
1515
if line.startswith('__version__ ='):
1616
_, _, version = line.partition('=')

0 commit comments

Comments
 (0)