Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9626e8f

Browse files
authored
Add script to release the SDK along the OpenAPI spec (#16)
1 parentdf18a4f commit9626e8f

File tree

6 files changed

+161
-5
lines changed

6 files changed

+161
-5
lines changed

‎.github/workflows/release.yml‎

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name:Release LocalStack Python Client
2+
3+
on:
4+
repository_dispatch:
5+
types:[release-sdk]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description:The version of the OpenAPI spec to release the client for
10+
required:true
11+
12+
env:
13+
git_user_name:localstack[bot]
14+
git_user_email:localstack-bot@users.noreply.github.com
15+
16+
jobs:
17+
18+
test_python:
19+
runs-on:ubuntu-latest
20+
env:
21+
release:${{ github.event_name == 'workflow_dispatch' && inputs.version || github.event.client_payload.version}}
22+
23+
steps:
24+
-name:"Pull image"
25+
run:|
26+
docker pull localstack/localstack-pro:${{ env.release }}
27+
28+
-name:"Checkout"
29+
uses:actions/checkout@v4
30+
with:
31+
# setuptools_scm requires git history to determine the version
32+
fetch-depth:0
33+
34+
-name:"Set up Python 3.11"
35+
uses:actions/setup-python@v5
36+
with:
37+
python-version:"3.11"
38+
39+
-name:"Install uv"
40+
uses:astral-sh/setup-uv@v3
41+
42+
-name:"Generate code from spec"
43+
run:|
44+
make clean-generated
45+
./bin/generate.sh ${{ env.release }}
46+
47+
-name:"Prepare git config"
48+
run:|
49+
git config user.name ${{ env.git_user_name }}
50+
git config user.email ${{ env.git_user_email }}
51+
52+
-name:"Commit changed code"
53+
run:|
54+
# Code automatically generated goes into the packages directory.
55+
# As we generate code for the version to be released, we commit those changes.
56+
if git status --porcelain packages/ | grep -q '^'; then
57+
git add packages/
58+
git commit -m "Generate code for ${{ env.release }}"
59+
60+
echo "Changes committed successfully"
61+
else
62+
echo "No changes detected after generating the code"
63+
fi
64+
65+
-name:"Install project"
66+
run:|
67+
make install-dev
68+
69+
-name:"Install LocalStack"
70+
run:|
71+
pip install localstack==${{ env.release }}
72+
73+
-name:"Start Localstack"
74+
env:
75+
LOCALSTACK_AUTH_TOKEN:${{ secrets.LOCALSTACK_AUTH_TOKEN }}
76+
run:|
77+
source .venv/bin/activate
78+
DEBUG=1 DISABLE_EVENTS="1" IMAGE_NAME="localstack/localstack-pro:${{ env.release }}" localstack start -d
79+
localstack wait -t 120 || (python -m localstack.cli.main logs && false)
80+
81+
-name:"Run Python Tests"
82+
env:
83+
LOCALSTACK_AUTH_TOKEN:${{ secrets.LOCALSTACK_AUTH_TOKEN }}
84+
run:|
85+
make test
86+
87+
-name:"Stop Localstack"
88+
if:success() || failure()
89+
run:|
90+
source .venv/bin/activate
91+
localstack logs
92+
localstack stop
93+
94+
-name:"Install release helper"
95+
run:|
96+
curl -o bin/release-helper.sh -L https://api.github.com/repos/localstack/localstack/contents/bin/release-helper.sh -H 'Accept: application/vnd.github.v3.raw'
97+
chmod +x bin/release-helper.sh
98+
99+
-name:"Create the release commit and tag"
100+
run:|
101+
bin/release-helper.sh git-commit-release ${{ env.release }}
102+
103+
-name:"Publish release to pypi"
104+
run:|
105+
make install publish
106+
with:
107+
UV_PUBLISH_TOKEN:${{ secrets.UV_PUBLISH_TOKEN }}
108+
109+
-name:"Push the release commit and tag"
110+
run:|
111+
git push --follow-tags
112+
113+
-name:"Create GitHub release"
114+
env:
115+
GITHUB_TOKEN:${{ secrets.LOCALSTACK_GITHUB_TOKEN }}
116+
run:gh release create "${{ env.release }}" --generate-notes --draft
117+
118+
-name:"Commit and push next development version"
119+
run:|
120+
bin/release-helper.sh git-commit-increment
121+
git push
122+
123+
-name:"Publish development version to pypi"
124+
run:|
125+
make install publish
126+
with:
127+
UV_PUBLISH_TOKEN:${{ secrets.UV_PUBLISH_TOKEN }}
128+
129+
-name:"Show git modifications"
130+
run:|
131+
git log --oneline -n 4
132+
git show HEAD~1
133+
git show HEAD

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ localstack-sdk-python-2/.openapi-generator/
6767

6868
# setuptools_scm version.py
6969
**/version.py
70+
71+
# release helper
72+
bin/release-helper.sh

‎Makefile‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,21 @@ clean: ## Clean up the virtual environment
1717
rm -rf$(VENV_DIR)
1818
rm -rf dist/
1919

20+
clean-dist:
21+
rm -rf dist/
22+
2023
clean-generated:## Cleanup generated code
2124
rm -rf packages/localstack-sdk-generated/localstack/
2225

2326
generate:## Generate the code from the OpenAPI specs
2427
./bin/generate.sh
2528

29+
build:
30+
uv build
31+
32+
publish: clean-dist build
33+
uv publish
34+
2635
format:
2736
($(VENV_RUN); python -m ruff format --exclude packages.; python -m ruff check --output-format=full --exclude packages --fix .)
2837

@@ -32,4 +41,4 @@ lint:
3241
test:## Run automated tests
3342
($(VENV_RUN);$(TEST_EXEC) pytest --durations=10 --log-cli-level=$(PYTEST_LOGLEVEL)$(PYTEST_ARGS)$(TEST_PATH))
3443

35-
.PHONY: clean install install-dev
44+
.PHONY: clean install install-dev clean clean-dist clean-generated generate build publish format lint test

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ To run the integration test suite:
4747
maketest
4848
```
4949

50-
Note that LocalStack(pro) should be running in the background to execute the test.
50+
Note that LocalStackPro (with the same version as the SDK) should be running in the background to execute the test.
5151

5252
###Quickstart
5353

‎bin/generate.sh‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
#!/bin/bash
22

3+
# Use the latest spec by default
4+
SPEC_URL="https://raw.githubusercontent.com/localstack/openapi/refs/heads/main/openapi/emulators/localstack-spec-latest.yml"
5+
6+
if [-n"$1" ];then
7+
SPEC_URL="https://github.com/localstack/openapi/releases/download/v$1/localstack-spec.yml"
8+
fi
9+
10+
# Check if the URL is valid
11+
if! wget --spider -q"$SPEC_URL";then
12+
echo"Spec URL seems not accessible:$SPEC_URL"
13+
exit 1
14+
fi
15+
316
docker run --rm -v"${PWD}:/local" openapitools/openapi-generator-cli:v7.10.0 generate \
4-
-ihttps://raw.githubusercontent.com/localstack/openapi/refs/heads/main/openapi/emulators/localstack-spec-latest.yml \
17+
-i"$SPEC_URL" \
518
--skip-validate-spec \
619
-g python \
720
-o /local//packages/localstack-sdk-generated \

‎requirements-spec.txt‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp