-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (136 loc) · 5.67 KB
/
Copy pathbuild.yml
File metadata and controls
168 lines (136 loc) · 5.67 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Build
on:
push:
branches: [main, "release/*"]
pull_request:
jobs:
package:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.git_version.outputs.BUILD_VERSION }}
version_major: ${{ steps.git_version.outputs.BUILD_VERSION_MAJOR }}
version_minor: ${{ steps.git_version.outputs.BUILD_VERSION_MINOR }}
version_patch: ${{ steps.git_version.outputs.BUILD_VERSION_PATCH }}
version_build: ${{ steps.git_version.outputs.BUILD_VERSION_BUILD }}
tag: ${{ steps.git_version.outputs.BUILD_VERSION_TAG }}
branch: ${{ steps.git_version.outputs.BUILD_VERSION_BRANCH }}
commit: ${{ steps.git_version.outputs.BUILD_VERSION_COMMIT }}
short: ${{ steps.git_version.outputs.BUILD_VERSION_SHORT }}
full: ${{ steps.git_version.outputs.BUILD_VERSION_FULL }}
extended: ${{ steps.git_version.outputs.BUILD_VERSION_EXTENDED }}
default_branch: ${{ steps.git_version.outputs.BUILD_VERSION_DEFAULT_BRANCH }}
release_branches: ${{ steps.git_version.outputs.BUILD_VERSION_RELEASE_BRANCHES }}
steps:
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6.2.0
with:
python-version: "3.13"
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build
- name: Generate _version.py from git tags
run: python tools/write_version.py
- name: Build package
run: python -m build
- name: Install built package
run: pip install dist/*.whl
- name: Extract version info from built package
id: git_version
run: |
while IFS='=' read -r key value; do
echo "$key=$value" >> "$GITHUB_OUTPUT"
done < <(git-version --property env)
- name: Show version info
run: |
echo "═══════════════════════════════════════"
echo " GIT VERSION INFORMATION"
echo "═══════════════════════════════════════"
echo " Version: ${{ steps.git_version.outputs.BUILD_VERSION }}"
echo " Major: ${{ steps.git_version.outputs.BUILD_VERSION_MAJOR }}"
echo " Minor: ${{ steps.git_version.outputs.BUILD_VERSION_MINOR }}"
echo " Patch: ${{ steps.git_version.outputs.BUILD_VERSION_PATCH }}"
echo " Build: ${{ steps.git_version.outputs.BUILD_VERSION_BUILD }}"
echo " Tag: ${{ steps.git_version.outputs.BUILD_VERSION_TAG }}"
echo " Branch: ${{ steps.git_version.outputs.BUILD_VERSION_BRANCH }}"
echo " Commit: ${{ steps.git_version.outputs.BUILD_VERSION_COMMIT }}"
echo " Short: ${{ steps.git_version.outputs.BUILD_VERSION_SHORT }}"
echo " Full: ${{ steps.git_version.outputs.BUILD_VERSION_FULL }}"
echo " Extended: ${{ steps.git_version.outputs.BUILD_VERSION_EXTENDED }}"
echo " DefaultBranch: ${{ steps.git_version.outputs.BUILD_VERSION_DEFAULT_BRANCH }}"
echo " ReleaseBranches: ${{ steps.git_version.outputs.BUILD_VERSION_RELEASE_BRANCHES }}"
echo "═══════════════════════════════════════"
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.1
with:
name: dist
path: dist/
test:
runs-on: ubuntu-latest
needs: package
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build
- name: Generate _version.py from git tags
run: python tools/write_version.py
- name: Build package
run: python -m build
- name: Install built package
run: pip install dist/*.whl
- name: Install test dependencies
run: pip install pytest
- name: Run tests from repo
run: python -m pytest tests/ -v
docker:
runs-on: ubuntu-latest
needs: package
steps:
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
- name: Download built package
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Build Docker image
run: |
docker build -t ghcr.io/synacker/git-version-utils:${{ needs.package.outputs.version }} \
--build-arg WHEEL=dist/*.whl .
docker tag ghcr.io/synacker/git-version-utils:${{ needs.package.outputs.version }} \
ghcr.io/synacker/git-version-utils:latest
- name: Show version info
run: |
docker run --rm \
-v "$(pwd):/workspace" -w /workspace \
ghcr.io/synacker/git-version-utils:latest \
git-version --safe-directory '*' --property env
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.3
- name: Set up Python
uses: actions/setup-python@v6.2.0
with:
python-version: "3.13"
- name: Install lint tools
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Lint with ruff
run: ruff check src/ tests/