-
Notifications
You must be signed in to change notification settings - Fork 52
116 lines (99 loc) · 3.39 KB
/
release.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'The type of version bump. Use the blank option for no change. Use the "release" option to promote prerelease. See docs for details: https://hatch.pypa.io/latest/version/#supported-segments'
type: choice
required: true
default: ""
options:
- major
- minor
- patch
- release
- ""
prerelease:
description: "If this is a prerelease and which type. See docs for details: https://hatch.pypa.io/latest/version/#supported-segments"
type: choice
required: false
options:
- ""
- "alpha"
- "beta"
- "rc"
jobs:
prepare:
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Setup Python
run: uv python install 3.12
- name: Install Package
run: uv sync --all-extras
- name: Clean Format Test
run: uv run make clean format typecheck test
- name: Bump Version
shell: bash
if: inputs.version != '-s' && inputs.prerelease != ''
run: uvx hatch version ${{ inputs.version }},${{ inputs.prerelease }}
- name: Bump Version
shell: bash
if: inputs.version != '-s' && inputs.prerelease == ''
run: uvx hatch version ${{ inputs.version }}
- name: Set Version
id: set_version
run: |
echo "SDK_VERSION=$(uvx hatch version)" >> $GITHUB_ENV
echo "version=$(uvx hatch version)" >> $GITHUB_OUTPUT
- name: Check if release exists
uses: cardinalby/[email protected]
id: release_exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseName: v${{ env.SDK_VERSION }}
doNotFailIfNotFound: "true"
- name: Cancelling - release already exists
uses: andymckay/[email protected]
if: |
steps.release_exists.outputs.id != ''
- name: Add + Commit
uses: EndBug/add-and-commit@v9
with:
new_branch: release/v${{ env.SDK_VERSION }}
message: Bump version to ${{ env.SDK_VERSION }}
- name: Open PR
run: |
gh pr create -t "release/v${{ env.SDK_VERSION }}" -b "This is an auto-generated PR to merge the release branch back into main upon successful release" -B "main" -H "release/v${{ env.SDK_VERSION }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
uses: ./.github/workflows/build-wheels.yml
with:
branch: release/v${{ needs.prepare.outputs.version }}
needs: prepare
if: github.repository_owner == 'viamrobotics'
release:
needs: [prepare, build]
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.prepare.outputs.version }}
files: dist/**
draft: true
prerelease: false
fail_on_unmatched_files: true
target_commitish: release/v${{ needs.prepare.outputs.version }}