Skip to content

Commit 417b171

Browse files
authored
Merge pull request #163 from lucianopaz/release_automation
Release automation
2 parents 09958f7 + bc78a89 commit 417b171

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed

.github/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This file has been mostly taken verbatim from https://github.com/pymc-devs/pymc/blob/main/.github/release.yml
2+
#
3+
# This file contains configuration for the automatic generation of release notes in GitHub.
4+
# It's not perfect, but it makes it a little less laborious to write informative release notes.
5+
# Also see https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
6+
changelog:
7+
exclude:
8+
labels:
9+
- no releasenotes
10+
categories:
11+
- title: Major Changes 🛠
12+
labels:
13+
- major
14+
- title: New Features 🎉
15+
labels:
16+
- enhancement
17+
- feature request
18+
- title: Bugfixes 🐛
19+
labels:
20+
- bug
21+
- title: Documentation 📖
22+
- documentation
23+
- title: Maintenance 🔧
24+
labels:
25+
- "*"

.github/workflows/release.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: PyPI release
2+
on:
3+
pull_request:
4+
branches: [main]
5+
push:
6+
branches: [main]
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
build:
12+
name: Build source distribution
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
- uses: actions/setup-python@v4
19+
with:
20+
python-version: 3.8
21+
- name: Build the sdist and the wheel
22+
run: |
23+
pip install build
24+
python -m build
25+
- name: Check the sdist installs and imports
26+
run: |
27+
mkdir -p test-sdist
28+
cd test-sdist
29+
python -m venv venv-sdist
30+
venv-sdist/bin/python -m pip install ../dist/CausalPy*.tar.gz
31+
echo "Checking import and version number (on release)"
32+
venv-sdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else causalpy.__version__; print(causalpy.__version__)"
33+
cd ..
34+
- name: Check the bdist installs and imports
35+
run: |
36+
mkdir -p test-bdist
37+
cd test-bdist
38+
python -m venv venv-bdist
39+
venv-bdist/bin/python -m pip install ../dist/CausalPy*.whl
40+
echo "Checking import and version number (on release)"
41+
venv-bdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else causalpy.__version__; print(causalpy.__version__)"
42+
cd ..
43+
- uses: actions/upload-artifact@v3
44+
with:
45+
name: artifact
46+
path: dist/*
47+
test:
48+
name: Upload to Test PyPI
49+
needs: [build]
50+
runs-on: ubuntu-latest
51+
if: github.event_name == 'release' && github.event.action == 'published'
52+
steps:
53+
- uses: actions/download-artifact@v3
54+
with:
55+
name: artifact
56+
path: dist
57+
- uses: pypa/gh-action-pypi-publish@release/v1
58+
with:
59+
skip_existing: true
60+
user: __token__
61+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
62+
repository_url: https://test.pypi.org/legacy/
63+
- uses: actions/setup-python@v4
64+
with:
65+
python-version: 3.8
66+
- name: Test pip install from test.pypi
67+
run: |
68+
# Give time to test.pypi to update its index. If we don't wait,
69+
# we might request to install before test.pypi is aware that it actually has the package
70+
sleep 5s
71+
python -m venv venv-test-pypi
72+
venv-test-pypi/bin/python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple causalpy
73+
echo "Checking import and version number"
74+
venv-test-pypi/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}'"
75+
76+
publish:
77+
name: Upload release to PyPI
78+
needs: [build, test]
79+
runs-on: ubuntu-latest
80+
if: github.event_name == 'release' && github.event.action == 'published'
81+
steps:
82+
- uses: actions/download-artifact@v3
83+
with:
84+
name: artifact
85+
path: dist
86+
- uses: pypa/gh-action-pypi-publish@release/v1
87+
with:
88+
user: __token__
89+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)