-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (80 loc) · 2.3 KB
/
build.yml
File metadata and controls
96 lines (80 loc) · 2.3 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
name: Build
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Ensure tag commit is on main branch
if: startsWith(github.ref, 'refs/tags/v')
run: |
git fetch --depth=1 origin main
git merge-base --is-ancestor "$GITHUB_SHA" origin/main
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
pyproject.toml
requirements.txt
- name: Install project
run: |
python -m pip install --upgrade pip
python -m pip install -e .
- name: Run tests
run: python -m unittest discover -s tests -p "test_*.py"
build:
needs: tests
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: |
pyproject.toml
requirements.txt
- name: Install build backend
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build distributions
run: python -m build
- name: Verify distributions
run: python -m twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: microbiome2function-dist-${{ github.sha }}
path: dist/*
if-no-files-found: error
- name: Upload assets to GitHub release
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${GITHUB_REF_NAME}"
if gh release view "$TAG" >/dev/null 2>&1; then
gh release upload "$TAG" dist/* --clobber
else
gh release create "$TAG" dist/* --generate-notes --title "$TAG"
fi