-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (83 loc) · 2.37 KB
/
build.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
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
---
name: Build
on:
workflow_dispatch:
pull_request_target:
branches: [main]
types: [closed]
push:
permissions:
contents: read
env:
FORCE_COLOR: 1
MYPY_FORCE_COLOR: 1
PY_COLORS: 1
TOX_TESTENV_PASSENV: >-
FORCE_COLOR
MYPY_FORCE_COLOR
NO_COLOR
PY_COLORS
PYTEST_THEME
PYTEST_THEME_MODE
TOX_PARALLEL_NO_SPINNER: 1
jobs:
test:
name: Test
uses: ./.github/workflows/test.yml
build:
name: Build
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true || startsWith(github.ref, 'refs/tags/release/')
needs:
- test
runs-on: ubuntu-latest
environment: build
permissions:
id-token: write
issues: write
pull-requests: write
steps:
- if: github.event.ref_type == 'tag'
uses: actions/checkout@v4
- if: github.event.ref_type != 'tag'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.x
cache: pip
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[build]
- name: Build
run: python -m build
- name: Get Version
id: version
shell: bash
run: |
export VERSION=$(python -c "import sys;sys.path.append('src/modem_info');from _version import version;print(version)")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "version=$VERSION"
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]] || exit 1
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
repository-url: https://test.pypi.org/legacy/
- name: Render PR Template
id: pr-template
if: github.event_name == 'pull_request_target'
uses: chuhlomin/render-template@v1.10
with:
template: ./.github/templates/pr-build.md
vars: |
version: ${{ steps.version.outputs.version }}
- name: Update PR with Build
if: github.event_name == 'pull_request_target'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.pr-template.outputs.result }}
reactions: rocket