-
Notifications
You must be signed in to change notification settings - Fork 7
103 lines (87 loc) · 2.67 KB
/
release.yaml
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
name: Release
on:
push:
branches:
- workflow_release
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-alpha'
- 'v[0-9]+.[0-9]+.[0-9]+-beta'
jobs:
build_release:
name: build_release
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
env:
MACOSX_DEPLOYMENT_TARGET: '11.0'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install pypa/build
run: python3 -m pip install build
shell: bash
- name: Build a binary wheel and a source tarball
id: build
run: python3 -m build
shell: bash
- name: Upload the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
create_release:
name: create_release
needs: ['build_release']
runs-on: ubuntu-latest
permissions:
# IMPORTANT: mandatory for making GitHub Releases
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs#overview
contents: write
steps:
- name: Download the distribution packages
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: List the distribution packages
run: ls -1 dist/*
shell: bash
- name: Create release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
ref_name='${{ github.ref_name }}'
echo "ref_name: $ref_name"
# is this a test release, or a real release?
if [[ "$ref_name" == 'workflow_release' ]]; then
version='v0.0.0-test'
target='--target "workflow_release"'
else
version="$ref_name"
target=''
fi
echo "version: $version"
echo "target: $target"
# is this a pre-release (-rc*, -alpha, -beta, -test)?
if [[ "$version" == *"-"* ]]; then
prerelease='--prerelease'
else
prerelease=''
fi
echo "prerelease: $prerelease"
date=$(env TZ=':America/Los_Angeles' date +'%Y-%m-%d')
echo "date: $date"
gh release create \
"$version" \
dist/* \
--title "$version ($date)" \
$target $prerelease --draft \
--repo '${{ github.repository }}'
shell: bash