-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (70 loc) · 2.57 KB
/
cd.yml
File metadata and controls
81 lines (70 loc) · 2.57 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
name: CD
run-name: CD - ${{ github.event_name == 'workflow_run' && format('{0} (from CI)', github.event.workflow_run.head_commit.message) || format('{0}{1}', github.event.inputs.environment != '' && github.event.inputs.environment || 'dev', github.event.inputs.version != '' && format(' (v{0})', github.event.inputs.version) || '') }}
on:
workflow_dispatch:
inputs:
version:
description: "Release version"
default: "None"
required: false
workflow_run:
workflows: ["CI"]
branches: [main]
types:
- completed
env:
CD: ${{ vars.CONTINUOUS_DEPLOYMENT }}
VERSION: ${{ github.event.inputs.version != '' && github.event.inputs.version || 'None' }}
jobs:
# Continuous Deployment (CD) pipeline
cd:
if: ${{ vars.CONTINUOUS_DEPLOYMENT == 'true' && github.ref_name == 'main' && (github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')) }}
permissions:
contents: write
id-token: write
timeout-minutes: 15
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
platforms: [linux/amd64]
steps:
- name: Checkout Git repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v7
- name: Install dependencies
shell: bash
run: uvx uvtask dev-install
- name: Set version
shell: bash
run: |
if [ -z "${VERSION}" ] || [ "${VERSION}" = "None" ]; then
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
uv version ${LAST_TAG}
uv version --bump minor
VERSION=$(uv version --short)
echo "VERSION=${VERSION}" >> "${GITHUB_ENV:-/dev/null}"
else
uv version ${VERSION}
fi
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
git tag -a "${VERSION}" -m "Release ${VERSION}"
git push origin "${VERSION}"
- name: Build package
shell: bash
run: uv build
- name: Upload package to artifact registry
uses: actions/upload-artifact@v6
with:
name: uvtask-${{ env.VERSION }}
path: dist/
- name: Publish package
shell: bash
run: uv publish --token "${{ secrets.UV_PUBLISH_TOKEN }}"
- name: Clean
shell: bash
run: uvx uvtask clean