-
Notifications
You must be signed in to change notification settings - Fork 7
93 lines (78 loc) · 2.43 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
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"]
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:
contents: write # IMPORTANT: mandatory for making GitHub Releases
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 \'${{ github.sha }}\''
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
shell: bash