-
Notifications
You must be signed in to change notification settings - Fork 50
129 lines (115 loc) · 4.06 KB
/
Copy pathrelease.yml
File metadata and controls
129 lines (115 loc) · 4.06 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
name: Release GQLAlchemy
# Phase 2 of the release process. Run this against main AFTER the
# "Prepare release" PR (prepare-release.yml) has been reviewed and merged.
# The version comes from main's pyproject.toml (set and reviewed in phase 1),
# so there is no version input here. main was already tested in phase 1, so
# this only builds, publishes, tags, deploys the docs, and creates the
# GitHub release.
on:
workflow_dispatch:
inputs:
publish_packages:
description: "Publish packages"
required: false
type: boolean
default: true
publish_docs:
description: "Publish docs (mkdocs gh-deploy)"
required: false
type: boolean
default: true
test:
description: "Publish to Test PyPI instead of PyPI"
required: false
type: boolean
default: true
dry_run:
description: "Dry run (skip creating the release tag, docs deploy and GitHub release)"
required: false
type: boolean
default: false
jobs:
publish-packages:
name: Build and Publish Packages
if: ${{ inputs.publish_packages == true }}
runs-on: ["ubuntu-latest"]
steps:
- name: Checkout Code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
ref: main
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
version: "0.11.3"
- name: Build packages
run: |
uv build
- name: Publish packages
if: ${{ inputs.test == false }}
run: |
uv publish --token ${{ secrets.PYPI_API_TOKEN }}
- name: Publish Packages (Test PyPI)
if: ${{ inputs.test == true }}
continue-on-error: true
run: |
uv publish --token ${{ secrets.TEST_PYPI_API_TOKEN }} --publish-url https://test.pypi.org/legacy/
create-tag:
needs: publish-packages
name: Create Release Tag
# Tag main HEAD only on a real release, after publishing succeeded (or was
# intentionally skipped via publish_packages=false). always() lets this run
# even when publish-packages was skipped.
if: >-
${{ always() && inputs.dry_run == false
&& (needs.publish-packages.result == 'success' || needs.publish-packages.result == 'skipped') }}
runs-on: ["ubuntu-latest"]
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
ref: main
fetch-depth: 0
fetch-tags: true
- name: Read version from pyproject.toml
id: version
run: |
version=$(grep -m1 -E '^version = ' pyproject.toml | sed -E 's/^version = "(.*)"/\1/')
if [ -z "$version" ]; then
echo "::error::Could not read version from pyproject.toml"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Releasing version: $version"
- name: Configure Git
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
- name: Create and push tag
run: |
tag="v${{ steps.version.outputs.version }}"
if git rev-parse "$tag" >/dev/null 2>&1; then
echo "::error::Tag $tag already exists!"
exit 1
fi
git tag -a "$tag" -m "Release $tag"
git push origin "$tag"
publish-docs:
name: Publish Docs
if: ${{ inputs.dry_run == false && inputs.publish_docs == true }}
uses: ./.github/workflows/publish-docs.yml
secrets: inherit
create-github-release:
needs: create-tag
name: Create GitHub Release
uses: ./.github/workflows/create-github-release.yml
with:
version: ${{ needs.create-tag.outputs.version }}
secrets: inherit