Skip to content

Commit 819797b

Browse files
authored
Merge pull request #2 from cloudbeds/feat/actions-for-publishing
feat: add actions to build and publish pacakge
2 parents fb7dfb6 + 17bcdd5 commit 819797b

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed

.github/workflows/publish.yaml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Publish new version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'The version to release'
8+
required: false
9+
default: ""
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
generate-api-docs:
16+
name: Update version and build python module
17+
runs-on: default
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Get API docs
23+
env:
24+
GITHUB_TOKEN: ${{ github.token }}
25+
run: |
26+
MFD_TAG=$(gh api /repos/cloudbeds/mfd/releases/latest | jq -r '.tag_name')
27+
echo "Latest MFD tag: $MFD_TAG"
28+
gh api /repos/cloudbeds/mfd/tarball/$MFD_TAG | tar --strip-components=1 --wildcards -zxf - '*/public_accessa/api'
29+
30+
- name: Get next version
31+
id: get_next_version
32+
run: |
33+
if [ -n "${{ github.event.inputs.version }}" ]; then
34+
echo "next_version=${{ github.event.inputs.version }}" >> $GITHUB_ENV
35+
echo "Version provided: ${{ github.event.inputs.version }}"
36+
else
37+
current_version=$(cat VERSION)
38+
echo "Current version: $current_version"
39+
40+
IFS='.' read -r major minor patch <<< "$current_version"
41+
minor=$((minor + 1))
42+
next_version="$major.$minor.$patch"
43+
echo "Next version: $next_version"
44+
45+
echo "next_version=$next_version" >> $GITHUB_ENV
46+
fi
47+
48+
- name: Setup Java
49+
uses: actions/setup-java@v4
50+
with:
51+
java-version: 23
52+
distribution: corretto
53+
54+
- name: Install OpenAPI generator
55+
run: |
56+
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-$(cat .openapi-generator/VERSION).jar -O openapi-generator-cli.jar
57+
58+
- name: Bump version in VERSION and openapitools.json
59+
run: |
60+
echo ${{ env.next_version }} > VERSION
61+
sed -i 's/"packageVersion": "[0-9]*\.[0-9]*\.[0-9]*"/"packageVersion": "${{ env.next_version }}"/' openapitools.json
62+
63+
- name: Generate API docs
64+
run: |
65+
java -jar openapi-generator-cli.jar generate -c openapitools.json
66+
67+
- name: Update repository with new version
68+
if: github.event.inputs.version == ''
69+
run: |
70+
git config --global user.name "github-actions"
71+
git config --global user.email "[email protected]"
72+
git add VERSION openapitools.json $(cat PACKAGE) README.md .openapi-generator/FILES
73+
git commit -m "Bump version to ${{ env.next_version }}"
74+
git push
75+
76+
build-release:
77+
name: Build release distribution
78+
runs-on: default
79+
needs: generate-api-docs
80+
env:
81+
UV_VERSION: 0.5.21
82+
steps:
83+
- name: Checkout code
84+
uses: actions/checkout@v4
85+
with:
86+
ref: ${{ github.ref_name }}
87+
88+
- name: Setup Python
89+
uses: actions/setup-python@v5
90+
with:
91+
python-version-file: .python-version
92+
93+
- name: Build release distributions
94+
run: |
95+
pip install "uv==${{ env.UV_VERSION }}"
96+
uv sync --locked --no-dev
97+
uv build
98+
99+
- name: Upload distributions
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: release-dists
103+
path: dist/
104+
105+
- name: Create Release
106+
id: create_release
107+
if: github.event.inputs.version == ''
108+
env:
109+
GITHUB_TOKEN: ${{ github.token }}
110+
run: >-
111+
gh release create $(cat VERSION)
112+
--notes $(cat VERSION)
113+
--target ${{ github.ref_name }}
114+
--title $(cat VERSION)
115+
116+
pypi-publish:
117+
name: Publish to PyPI
118+
runs-on: default
119+
needs: build-release
120+
environment:
121+
name: pypi
122+
permissions:
123+
id-token: write
124+
steps:
125+
- name: Retrieve release distributions
126+
uses: actions/download-artifact@v4
127+
with:
128+
name: release-dists
129+
path: dist/
130+
131+
- name: Publish release distributions to PyPI
132+
uses: pypa/gh-action-pypi-publish@release/v1
133+
with:
134+
packages-dir: dist/

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

0 commit comments

Comments
 (0)