-
Notifications
You must be signed in to change notification settings - Fork 143
205 lines (174 loc) · 6.33 KB
/
Copy pathpackages.yml
File metadata and controls
205 lines (174 loc) · 6.33 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# Copyright 2024-2025 New Vector Ltd
# Copyright 2025-2026 Element Creations Ltd
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Packages linting, testing & releasing
on:
pull_request:
push:
branches:
- main
- 'maintenance/*'
tags:
# Publish on any tag starting with a `v`, e.g., v0.1.0
- ess-migration-tool-v*
workflow_dispatch:
permissions:
contents: read
jobs:
python:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.11"
- "3.12"
- "3.13"
- "3.14"
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
enable-cache: true
activate-environment: true
python-version: ${{ matrix.python-version }}
- name: Set up UV environment
run: uv sync --all-packages --resolution lowest-direct
- name: Run ruff check
run: |
ruff check
- name: Run ruff format
run: |
ruff format --check
- name: mypy
run: |
mypy packages/ess-migration-tool
- name: pytest packages
run: |
pytest packages
- name: Build with lowest resolution
run: uv build --package ess-migration-tool
- name: pytest packages (wheel)
run: uv run --isolated --no-project --with dist/*.whl pytest packages/ess-migration-tool/tests
- name: pytest packages (source distribution)
run: uv run --isolated --no-project --with dist/*.tar.gz pytest packages/ess-migration-tool/tests
build:
runs-on: ubuntu-latest
needs:
- python
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
# We disable cache for releases to avoid cache poisoning
enable-cache: ${{ github.ref_type != 'tag' }}
activate-environment: true
- name: Set up UV environment
run: uv sync --all-packages --resolution lowest-direct
- name: Set version
env:
GITHUB_RUN_ID: "${{ github.run_id }}"
run: |
if [ "$GITHUB_REF_TYPE" = "tag" ]; then
uv --directory packages/ess-migration-tool version "${GITHUB_REF_NAME#ess-migration-tool-v}"
else
uv version --directory packages/ess-migration-tool --bump "dev=$GITHUB_RUN_ID"
fi
- name: Build
run: uv build --package ess-migration-tool
# Check that basic features work and we didn't miss to include crucial files
- name: Smoke test (wheel)
run: |-
for version in 3.11 3.12 3.13 3.14; do
uv run --python "$version" --isolated --resolution lowest --no-project --with dist/*.whl ess-migration-tool --help
done
- name: Smoke test (source distribution)
run: |
for version in 3.11 3.12 3.13 3.14; do
uv run --python "$version" --isolated --resolution lowest --no-project --with dist/*.tar.gz ess-migration-tool --help
done
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ess-migration-tool-dist
path: |
dist/*
retention-days: 1
publish:
needs:
- build
environment:
name: pypi
permissions:
id-token: write
contents: write
packages: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# We are creating a commit changing the chart version for the next version PR
persist-credentials: true
- name: Grab packaged dists
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ess-migration-tool-dist
path: ./dist
- name: Install uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
enable-cache: true
activate-environment: true
- name: Set up UV environment
run: uv sync
- name: Generate changelog
run: |
version=$(find dist -name 'ess_migration_tool-*.tar.gz' | sed 's/.*ess_migration_tool-//;s/.tar.gz//')
# Add changes to CHANGELOG.md
uv run towncrier build --version "$version" --yes --dir packages/ess-migration-tool
echo "CHANGELOG.md will look like:"
cat packages/ess-migration-tool/CHANGELOG.md
echo ""
- name: Bump version for next PR
id: versions
run: |
if [ "$GITHUB_REF_TYPE" = "tag" ]; then
uv --directory packages/ess-migration-tool version "${GITHUB_REF_NAME#ess-migration-tool-v}"
fi
this_version=$(uv --directory packages/ess-migration-tool version --short)
uv --directory packages/ess-migration-tool version --bump patch --bump dev=1
next_version=$(uv --directory packages/ess-migration-tool version --short)
echo "this-version=$this_version" | tee -a "$GITHUB_OUTPUT"
echo "next-version=$next_version" | tee -a "$GITHUB_OUTPUT"
- name: Publish
env:
REF_TYPE: ${{ github.ref_type }}
run: |
if [ "${REF_TYPE}" = "tag" ]; then
uv publish dist/*
else
uv publish --dry-run dist/*
fi
- name: Create PR for next patch version
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
if: github.ref_type == 'tag'
with:
branch: "gha/bump-ess-migration-tool-to-${{ steps.versions.outputs.next-version }}"
base: "main"
commit-message: "Bump ess-migration-tool version to ${{ steps.versions.outputs.next-version }}"
title: "Bump ess-migration-tool version to ${{ steps.versions.outputs.next-version }} after release"
labels: automated,version-bump
body: |
${{ steps.versions.outputs.this-version }} has just been released.
This PR prepares ess-migration-tool package for the next release:
${{ steps.versions.outputs.next-version }}.
The target branch may be wrong. In which case this PR should be taken over and manually adjusted.