-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (44 loc) · 1.56 KB
/
release.yml
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
# Builds and releases to Github whenever a "v" tag is added.
# Useful docs:
# https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28
# https://cli.github.com/manual/gh_release_create
name: Build and release to Github
on:
workflow_dispatch:
push:
tags:
- 'v*'
jobs:
build:
name: Build and release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version-file: '.python-version'
- name: Install dependencies
run: |
pip install .[dev]
pip install build
- name: Run unit tests
run: python -m unittest discover -v -s "./epymorph" -p "*_test.py"
- name: Update pyproject.toml version
run: |
version="${GITHUB_REF#refs/tags/v}"
sed -i "s/version = .*/version = \"${version}\"/" pyproject.toml
- name: Build project
run: python -m build
- name: Create release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
version="${GITHUB_REF#refs/tags/v}"
# release assets
wheel_file="./dist/epymorph-${version}-py3-none-any.whl"
source_file="./dist/epymorph-${version}.tar.gz"
gh release create "v${version}" --generate-notes $wheel_file $source_file