Skip to content

Commit aa4ff31

Browse files
committed
Build wheels for all Python versions
1 parent 120ddad commit aa4ff31

File tree

2 files changed

+124
-14
lines changed

2 files changed

+124
-14
lines changed

.github/workflows/release.yaml

Lines changed: 123 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,136 @@
11
name: Release
22
on:
3-
release:
4-
types:
5-
- created
3+
push:
4+
branches:
5+
- workflow_release
6+
tags:
7+
- 'v[0-9]+.[0-9]+.[0-9]+'
8+
69
jobs:
7-
release:
8-
name: Release
10+
build-release:
11+
name: build-release
912
runs-on: macos-latest
13+
strategy:
14+
matrix:
15+
python-version: [3.6, 3.7, 3.8, 3.9]
16+
1017
steps:
11-
- uses: actions/checkout@v2
12-
- name: Set up Python
18+
- name: Create artifacts directory
19+
shell: bash
20+
run: mkdir artifacts
21+
- name: Checkout repository
22+
uses: actions/checkout@v2
23+
- name: Set up Python ${{ matrix.python-version }}
1324
uses: actions/setup-python@v1
1425
with:
15-
python-version: '3.7'
26+
python-version: ${{ matrix.python-version }}
1627
- name: Install dependencies
28+
shell: bash
29+
run: pip install poetry
30+
31+
- name: Build wheel
32+
if: matrix.python-version != 3.9
33+
shell: bash
34+
run: poetry build --format "wheel"
35+
- name: Build wheel and sdist
36+
if: matrix.python-version == 3.9
37+
shell: bash
38+
run: poetry build
39+
40+
- name: Resolve wheel name
41+
id: resolve_wheel
42+
shell: bash
1743
run: |
18-
python -m pip install --upgrade pip
19-
pip install poetry
20-
- name: Build
44+
wheel_path="$(echo dist/pasteboard-*.whl)"
45+
echo "::set-output name=path::$wheel_path"
46+
echo "wheel path: $wheel_path"
47+
wheel_name="${wheel_path##*/}"
48+
echo "::set-output name=name::$wheel_name"
49+
echo "wheel name: $wheel_name"
50+
- name: Upload wheel to artifacts
51+
uses: actions/upload-artifact@v2
52+
with:
53+
name: artifacts
54+
path: ${{ steps.resolve_wheel.outputs.path }}
55+
56+
- name: Resolve tar.gz name
57+
id: resolve_targz
58+
if: matrix.python-version == 3.9
59+
shell: bash
60+
run: |
61+
targz_path="$(echo dist/pasteboard-*.tar.gz)"
62+
echo "::set-output name=path::$targz_path"
63+
echo "tar.gz path: $targz_path"
64+
targz_name="${targz_path##*/}"
65+
echo "::set-output name=name::$targz_name"
66+
echo "tar.gz name: $targz_name"
67+
- name: Upload tar.gz to artifacts
68+
if: matrix.python-version == 3.9
69+
uses: actions/upload-artifact@v2
70+
with:
71+
name: artifacts
72+
path: ${{ steps.resolve_targz.outputs.path }}
73+
74+
publish-release:
75+
name: publish-release
76+
needs: ['build-release']
77+
runs-on: ubuntu-latest
78+
79+
steps:
80+
- name: Checkout repository
81+
uses: actions/checkout@v2
82+
- name: Set up Python 3.9
83+
uses: actions/setup-python@v1
84+
with:
85+
python-version: 3.9
86+
- name: Install dependencies
87+
run: pip install poetry
88+
- name: Get release download URL
89+
uses: actions/download-artifact@v2
90+
with:
91+
name: artifacts
92+
path: artifacts
93+
94+
- name: Create dist directory
95+
shell: bash
96+
run: mkdir dist
97+
- name: Copy wheels
98+
shell: bash
99+
run: cp artifacts/*.whl dist/
100+
- name: Copy tar.gz
101+
shell: bash
102+
run: cp artifacts/*.tar.gz dist/
103+
- name: List all artifacts
104+
shell: bash
105+
run: ls -l dist/
106+
107+
- name: Get the branch and tag
108+
id: info
109+
shell: bash
110+
run: |
111+
branch="${GITHUB_REF#refs/heads/}"
112+
echo "$branch"
113+
if [[ "$branch" == "workflow_release" ]]; then
114+
echo "::set-output name=version::TEST-0.0.0"
115+
echo "::set-output name=dry_run::--dry-run"
116+
else
117+
echo "::set-output name=version::${GITHUB_REF#refs/tags/}"
118+
echo "::set-output name=dry_run::"
119+
fi
120+
echo "::set-output name=date::$(env TZ=':America/Los_Angeles' date +'%Y-%m-%d')"
121+
122+
- name: Create release
123+
shell: bash
21124
run: |
22-
poetry build
125+
set -x
126+
hub release create \
127+
--draft \
128+
--message "${{ steps.info.outputs.version }} (${{ steps.info.outputs.date }})" \
129+
$(find ./dist -type f -printf "-a %p ") \
130+
"${{ steps.info.outputs.version }}"
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23133
- name: Publish
24134
run: |
25135
poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}"
26-
poetry publish
136+
poetry publish ${{ steps.info.outputs.dry_run }}

build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313

1414

1515
def build(setup_kwargs):
16-
setup_kwargs["ext_modules"] = [pasteboard]
16+
setup_kwargs.update({"ext_modules": [pasteboard], "zip_safe": False})

0 commit comments

Comments
 (0)