Repository navigation
121 lines (108 loc) · 3.5 KB
/
Copy pathrelease.yml
File metadata and controls
121 lines (108 loc) · 3.5 KB
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
#
# This runs when version tag is pushed
#
name: REL
on:
push:
tags: ["v[0-9]*"]
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
- os: windows-11-arm
- os: macos-latest
- os: ubuntu-latest
- os: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v7
- name: Build wheels
uses: pypa/cibuildwheel@v4.1.1
env:
CIBW_BUILD: "cp310-* cp314t-*"
- uses: actions/upload-artifact@v7.0.1
with:
path: ./wheelhouse/*.whl
name: dist-wheels-${{ matrix.os }}
sdist:
name: "Build source package"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with: {python-version: "3.14"}
- run: |
pip install build
python -m build --sdist
- uses: actions/upload-artifact@v7.0.1
with:
path: ./dist/*.tar.gz
name: dist-sdist
publish:
name: "Publish"
runs-on: ubuntu-latest
needs: [build_wheels, sdist]
environment: pypi
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v7
- name: "Get files"
uses: actions/download-artifact@v8
with:
path: dist/
merge-multiple: true
- name: "Install pandoc"
run: |
sudo -nH apt-get -qqy update
sudo -nH apt-get -u -y install pandoc
pandoc --version
- name: "Prepare"
run: |
PKG_INFO=$(tar -xzOf dist/*.tar.gz --wildcards --no-wildcards-match-slash '*/PKG-INFO')
PACKAGE=$(echo "${PKG_INFO}" | sed -n 's/^Name: //p' | head -1)
VERSION=$(echo "${PKG_INFO}" | sed -n 's/^Version: //p' | head -1)
TGZ=$(basename dist/*.tar.gz)
# default - gh:release, pypi
# PRERELEASE - gh:prerelease, pypi
# DRAFT - gh:draft,prerelease, testpypi
PRERELEASE="false"; DRAFT="false"
case "${VERSION}" in
*[ab]*|*rc*) PRERELEASE="true";;
*dev*) PRERELEASE="true"; DRAFT="true";;
esac
test "${{github.ref}}" = "refs/tags/v${VERSION}" || { echo "ERR: tag mismatch"; exit 1; }
test -f "dist/${TGZ}" || { echo "ERR: sdist missing"; exit 1; }
echo "PACKAGE=${PACKAGE}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "TGZ=${TGZ}" >> $GITHUB_ENV
echo "PRERELEASE=${PRERELEASE}" >> $GITHUB_ENV
echo "DRAFT=${DRAFT}" >> $GITHUB_ENV
mkdir -p tmp
make -s shownote > tmp/note.md
cat tmp/note.md
ls -l dist
- name: "Create Github release"
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
title="${PACKAGE} v${VERSION}"
ghf="--notes-file=./tmp/note.md"
if test "${DRAFT}" = "true"; then ghf="${ghf} --draft"; fi
if test "${PRERELEASE}" = "true"; then ghf="${ghf} --prerelease"; fi
gh release create "v${VERSION}" "dist/${TGZ}" --title="${title}" ${ghf}
- name: "Upload to PYPI"
if: env.DRAFT == 'false'
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
- name: "Upload to Test PYPI"
if: env.DRAFT == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/