-
Notifications
You must be signed in to change notification settings - Fork 119
102 lines (91 loc) · 3.54 KB
/
Copy pathrelease.yml
File metadata and controls
102 lines (91 loc) · 3.54 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
name: Auto-release and publish to PyPI
# Stable release stream: on every push to main, validate, cut a CalVer release,
# publish it to PyPI, and run live release e2e. Staging pre-releases (rc) live in
# publish-staging.yml so each stream keeps its own run tree, permissions,
# notifications, and publishing identity.
#
# The publish job MUST live in this top-level workflow — PyPI Trusted Publishing
# does not support reusable workflows and matches the OIDC claim on THIS
# filename. Register release.yml as a trusted publisher (environment `pypi`) at
# https://pypi.org/manage/project/anton-agent/settings/publishing/
#
# No workflow-level `permissions:` block: only the release job needs
# `contents: write`; every other job declares its own, so the repo default
# (read) applies to the rest.
#
# run-tree-ok: PyPI Trusted Publishing binds to this top-level workflow file.
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: auto-release-${{ github.ref }}
cancel-in-progress: false
jobs:
unit-tests:
permissions:
contents: read
uses: ./.github/workflows/tests.yml
auto-release:
needs: unit-tests
# workflow_dispatch can be pointed at any ref; only main cuts a stable release.
if: github.ref == 'refs/heads/main'
permissions:
contents: write # tag push + release creation
uses: mindsdb/github-actions/.github/workflows/calver-release.yml@main
with:
calver-major: "2"
runs-on: ubuntu-latest
publish:
name: Publish to PyPI
needs: auto-release
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write # required for trusted publisher (OIDC)
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.auto-release.outputs.tag }}
fetch-depth: 0 # hatch-vcs needs tags to derive version
- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
- name: Build package
env:
# A re-run or re-dispatch on an already-tagged head leaves two CalVer
# tags on one commit and `git describe` resolves the older one; build
# exactly the version the release job minted.
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.auto-release.outputs.version }}
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# Trusted publisher (OIDC) — release.yml must be registered at the
# anton-agent PyPI project's publishing settings (environment: pypi).
e2e:
needs: auto-release
permissions:
contents: read
uses: ./.github/workflows/tests_e2e_release.yml
with:
tag: ${{ needs.auto-release.outputs.tag }}
secrets: inherit
notify:
# Alert the eng channel if ANY job in the release pipeline fails (tests, tag,
# PyPI publish, or release e2e).
# One job covers both outcomes: a `uses:` job cannot branch on status, so
# the aggregate result picks the failed or recovered message, and a
# cancelled run stays silent.
needs: [unit-tests, auto-release, publish, e2e]
if: ${{ github.ref == 'refs/heads/main' && !cancelled() && !contains(needs.*.result, 'cancelled') }}
permissions:
contents: read
actions: read # the prior-run lookup behind the recovery message
uses: mindsdb/github-actions/.github/workflows/notify-main-failure.yml@main
with:
env-name: "release"
status: ${{ contains(needs.*.result, 'failure') && 'failed' || 'recovered' }}
runs-on: ubuntu-latest
secrets: inherit