-
Notifications
You must be signed in to change notification settings - Fork 16
146 lines (128 loc) · 4.15 KB
/
cd.yaml
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
name: Continuous Delivery of Python package
on:
workflow_dispatch:
inputs:
compiler_wheel:
description: "Include compiler wheel?"
type: boolean
required: true
default: true
stubs_wheel:
description: "Include stubs wheel?"
type: boolean
required: true
default: true
bump_version:
description: "Bump version, set to false to re-publish with current version"
type: boolean
required: true
default: true
publish_github:
description: "Publish to Github?"
type: boolean
required: true
default: true
publish_pypi:
description: "Publish to PyPi?"
type: boolean
required: true
default: true
publish_docs:
description: "Publish Docs?"
type: boolean
required: true
default: true
run_checks:
description: "Run checks?"
type: boolean
required: true
default: true
dry_run:
description: "Dry Run? If true, won't commit or publish anything"
type: boolean
required: true
default: false
concurrency: release
permissions:
contents: write
packages: read
jobs:
release:
name: Release Library
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
contents: write
packages: read
env:
DRY_RUN: ${{ inputs.dry_run && '--noop' || '' }}
steps:
- uses: actions/checkout@v4
with:
# Fetch entire repository history so we can determine version number from it
fetch-depth: 0
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"
- name: Install dependencies
run: poetry install --no-interaction --with cicd
- name: pre-commit and pytest
if: inputs.run_checks
run: |
set -o pipefail
source $(poetry env info --path)/bin/activate
pre-commit run --all-files && git diff --exit-code
algokit localnet start
pytest
- name: Get branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: get_branch
- name: Set Git user as GitHub actions
run: git config --global user.email "[email protected]" && git config --global user.name "github-actions"
- name: Update release
if: inputs.bump_version
run: poetry run semantic-release $DRY_RUN --strict version
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
- name: Create Compiler Wheel
if: inputs.compiler_wheel
run: poetry build --format wheel
- name: Create Stubs Wheel
if: inputs.stubs_wheel
run: |
pushd stubs
poetry build --format wheel
popd
- uses: actions/upload-artifact@v4 # upload artifacts so they are retained on the job
with:
path: |
dist
stubs/dist
- name: Publish to GitHub
if: steps.get_branch.outputs.branch == 'main' && !inputs.dry_run && inputs.publish_github
run: poetry run semantic-release $DRY_RUN publish
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
- name: Publish to PyPI - Compiler
if: steps.get_branch.outputs.branch == 'main' && !inputs.dry_run && inputs.publish_pypi && inputs.compiler_wheel
uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish to PyPI - Stubs
if: steps.get_branch.outputs.branch == 'main' && !inputs.dry_run && inputs.publish_pypi && inputs.stubs_wheel
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: stubs/dist
publish-docs:
name: Publish Docs
if: ${{ !inputs.dry_run && inputs.publish_docs }}
uses: ./.github/workflows/gh-pages.yaml
permissions:
contents: read
pages: write
id-token: write