Skip to content

Commit c5eb17b

Browse files
committed
ci: add publish.yaml to v1 as well
1 parent b354584 commit c5eb17b

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed

.github/workflows/publish.yaml

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

0 commit comments

Comments
 (0)