Skip to content

Commit 9b90154

Browse files
committed
feat: move some config to files
feat: split building package to a separate step
1 parent df42fa2 commit 9b90154

File tree

1 file changed

+40
-37
lines changed

1 file changed

+40
-37
lines changed

.github/workflows/publish.yaml

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: Publish new version
22

3-
env:
4-
UV_VERSION: 0.5.21
5-
63
on:
74
workflow_dispatch:
85
inputs:
@@ -15,7 +12,7 @@ permissions:
1512
contents: write
1613

1714
jobs:
18-
release-build:
15+
generate-api-docs:
1916
name: Update version and build python module
2017
runs-on: default
2118
steps:
@@ -30,29 +27,6 @@ jobs:
3027
echo "Latest MFD tag: $MFD_TAG"
3128
gh api /repos/cloudbeds/mfd/tarball/$MFD_TAG | tar --strip-components=1 --wildcards -zxf - '*/public_accessa'
3229
33-
- name: Set path to yaml file
34-
id: set-path-to-yaml
35-
run: |
36-
if [ "${{ github.ref_name }}" == "release/v1" ]; then
37-
echo "yaml_path=public_accessa/api/v1.2/docs/cb-v1.2-openapi-3.0.1.yaml" >> $GITHUB_ENV
38-
else
39-
echo "yaml_path=public_accessa/api/v2/docs/cb-v2-openapi-3.0.0.yaml" >> $GITHUB_ENV
40-
fi
41-
42-
- name: Setup Java
43-
uses: actions/setup-java@v4
44-
with:
45-
java-version: 21
46-
distribution: corretto
47-
48-
- name: Install OpenAPI generator
49-
run: |
50-
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
51-
52-
- name: Generate API docs
53-
run: |
54-
java -jar openapi-generator-cli.jar generate -i ${{ env.yaml_path }} -c openapitools.json
55-
5630
- name: Get next version
5731
id: get_next_version
5832
run: |
@@ -71,25 +45,54 @@ jobs:
7145
echo "next_version=$next_version" >> $GITHUB_ENV
7246
fi
7347
74-
- name: Bump version in files
75-
if: github.event.inputs.version == ''
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
7659
run: |
7760
echo ${{ env.next_version }} > VERSION
7861
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: |
7970
git config --global user.name "github-actions"
8071
git config --global user.email "[email protected]"
81-
git add VERSION openapitools.json
72+
git add VERSION openapitools.json $(cat PACKAGE) README.md .openapi-generator/FILES
8273
git commit -m "Bump version to ${{ env.next_version }}"
8374
git push
8475
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+
8588
- name: Setup Python
8689
uses: actions/setup-python@v5
8790
with:
8891
python-version-file: .python-version
8992

9093
- name: Build release distributions
9194
run: |
92-
pip install "uv==$UV_VERSION"
95+
pip install "uv==${{ env.UV_VERSION }}"
9396
uv sync --locked --no-dev
9497
uv build
9598
@@ -101,19 +104,19 @@ jobs:
101104

102105
- name: Create Release
103106
id: create_release
107+
if: github.event.inputs.version == ''
104108
env:
105109
GITHUB_TOKEN: ${{ github.token }}
106110
run: >-
107-
gh release create '${{ env.next_version }}'
108-
--notes '${{ env.next_version }}'
109-
--target '${{ github.ref_name }}'
110-
--title '${{ env.next_version }}'
111+
gh release create $(cat VERSION)
112+
--notes $(cat VERSION)
113+
--target ${{ github.ref_name }}
114+
--title $(cat VERSION)
111115
112116
pypi-publish:
113117
name: Publish to PyPI
114118
runs-on: default
115-
needs:
116-
- release-build
119+
needs: build-release
117120
environment:
118121
name: pypi
119122
permissions:

0 commit comments

Comments
 (0)