-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (166 loc) · 5.81 KB
/
publish.yaml
File metadata and controls
191 lines (166 loc) · 5.81 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Publish new version
on:
workflow_dispatch:
inputs:
version:
description: 'Optional version to use (bypasses version bump and git commits if provided)'
required: false
default: ""
mfd-ref:
description: 'The MFD ref (branch, tag, or SHA) to use for API docs'
required: false
default: ""
permissions:
contents: write
jobs:
generate-api-docs:
name: Update version and build python module
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::048781935247:role/GH-APP-OIDC-CBMyFrontDesk
aws-region: us-west-2
- name: Get app private key from SSM and apply mask
id: app-private-key
shell: bash
run: |
aws ssm get-parameter --name /github/app/CBMyFrontDesk/private-key --output text --with-decryption --query Parameter.Value > private.key
{
echo "key<<EOF"
cat private.key
echo "EOF"
} >> $GITHUB_OUTPUT
while read -r line;
do
if [[ -n "${line}" ]]; then
echo "::add-mask::${line}"
fi
done < private.key
rm private.key
- name: Generate token
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: 391670
private_key: ${{ steps.app-private-key.outputs.key }}
- name: Checkout code
uses: actions/checkout@v6
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Get API docs
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
MFD_REF='${{ inputs.mfd-ref }}'
if [[ -z "${MFD_REF}" ]]; then
MFD_REF=$(gh api /repos/cloudbeds/mfd/releases/latest | jq -r '.tag_name')
fi
echo "Using MFD ref: $MFD_REF"
gh api /repos/cloudbeds/mfd/tarball/$MFD_REF | tar --strip-components=1 --wildcards -zxf - '*/public_accessa/api'
- name: Get next version
run: |
if [ -n "${{ inputs.version }}" ]; then
echo "next_version=${{ inputs.version }}" >> $GITHUB_ENV
echo "Version provided: ${{ inputs.version }}"
else
current_version=$(cat VERSION)
echo "Current version: $current_version"
IFS='.' read -r major minor patch <<< "$current_version"
minor=$((minor + 1))
next_version="$major.$minor.$patch"
echo "Next version: $next_version"
echo "next_version=$next_version" >> $GITHUB_ENV
fi
- name: Setup Java
uses: actions/setup-java@v5
with:
java-version: 23
distribution: corretto
- name: Install OpenAPI generator
run: |
OPENAPI_GENERATOR_VERSION=$(cat .openapi-generator/VERSION)
curl -s https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$OPENAPI_GENERATOR_VERSION/openapi-generator-cli-$OPENAPI_GENERATOR_VERSION.jar -o openapi-generator-cli.jar
- name: Bump version in VERSION and openapitools.json
run: |
echo ${{ env.next_version }} > VERSION
sed -i 's/"packageVersion": "[0-9]*\.[0-9]*\.[0-9]*"/"packageVersion": "${{ env.next_version }}"/' openapitools.json
- name: Generate API docs
run: |
find $(cat PACKAGE) -mindepth 1 ! -name 'py.typed' -delete
java -jar openapi-generator-cli.jar generate -c openapitools.json
- name: Setup Python
if: github.ref_name == 'main'
uses: actions/setup-python@v6
with:
python-version-file: .python-version
- name: Simplify filters parameter
if: github.ref_name == 'main'
run: python simplify_filters_param.py
- name: Git Setup
if: inputs.version == ''
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@users.noreply.github.com"
- name: Update repository with new version
if: inputs.version == ''
run: |
git add VERSION openapitools.json $(cat PACKAGE) README.md .openapi-generator/FILES
git commit -m "Bump version to ${{ env.next_version }}"
git push
build-release:
name: Build release distribution
runs-on: ubuntu-latest
needs: generate-api-docs
env:
UV_VERSION: 0.10.9
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.ref_name }}
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version-file: .python-version
- name: Build release distributions
run: |
pip install "uv==${{ env.UV_VERSION }}"
uv sync --locked --no-dev
uv build
- name: Upload distributions
uses: actions/upload-artifact@v7
with:
name: release-dists
path: dist/
- name: Create Release
if: inputs.version == ''
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create $(cat VERSION)
--notes $(cat VERSION)
--target ${{ github.ref_name }}
--title $(cat VERSION)
pypi-publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build-release
environment:
name: pypi
permissions:
id-token: write
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v8
with:
name: release-dists
path: dist/
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/