CI: run LocalStack via lstk instead of the localstack PyPI package #36
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release LocalStack Python Client | ||
| on: | ||
| repository_dispatch: | ||
| types: [release-sdk] | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: The version of the OpenAPI spec to release the client for | ||
| required: true | ||
| env: | ||
| GIT_AUTHOR_NAME: localstack[bot] | ||
| GIT_AUTHOR_EMAIL: localstack-bot@users.noreply.github.com | ||
| GIT_COMMITTER_NAME: localstack[bot] | ||
| GIT_COMMITTER_EMAIL: localstack-bot@users.noreply.github.com | ||
| jobs: | ||
| test_python: | ||
| runs-on: ubuntu-latest | ||
| environment: pypi | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
| env: | ||
| RELEASE_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.version || github.event.client_payload.version}} | ||
| LSTK_CONFIG_FILE: ${{ runner.temp }}/lstk-config.toml | ||
| steps: | ||
| - name: "Pull Image (localstack/localstack-pro:${{ env.RELEASE_VERSION }})" | ||
| run: docker pull "localstack/localstack-pro:${RELEASE_VERSION}" | ||
| - name: "Checkout" | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| # setuptools_scm requires git history to determine the version | ||
| fetch-depth: 0 | ||
| - name: "Set up Python 3.13" | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.13" | ||
| - name: "Install uv" | ||
| uses: astral-sh/setup-uv@v8.2.0 | ||
| - name: "Generate Code from Spec" | ||
| run: | | ||
| make clean-generated | ||
| ./bin/generate.sh ${RELEASE_VERSION} | ||
| - name: "Commit Changed Code" | ||
| run: | | ||
| # Code automatically generated goes into the packages directory. | ||
| # As we generate code for the version to be released, we commit those changes. | ||
| if git status --porcelain packages/ | grep -q '^'; then | ||
| git add packages/ | ||
| git commit -m "Generate code for ${RELEASE_VERSION}" | ||
| echo "Changes committed successfully" | ||
| else | ||
| echo "No changes detected after generating the code" | ||
| fi | ||
| - name: "Install Project" | ||
| run: make install-dev | ||
| - name: "Install lstk" | ||
| run: npm install -g @localstack/lstk | ||
| - name: "Configure lstk" | ||
| # The config pins the emulator image to the release version. It lives outside | ||
| # the workspace so the "Check Uncommitted Changes" step stays clean. | ||
| run: | | ||
| cat > "${LSTK_CONFIG_FILE}" <<EOF | ||
| [[containers]] | ||
| type = "aws" | ||
| tag = "${RELEASE_VERSION}" | ||
| port = "4566" | ||
| EOF | ||
| - name: "Start Localstack" | ||
| env: | ||
| LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} | ||
| LOCALSTACK_DEBUG: "1" | ||
| LOCALSTACK_DISABLE_EVENTS: "1" | ||
| run: lstk --config "${LSTK_CONFIG_FILE}" start --timeout 2m | ||
| - name: "Run Python Tests" | ||
| env: | ||
| LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} | ||
| run: make test | ||
| - name: "Stop Localstack" | ||
| if: success() || failure() | ||
| run: | | ||
| lstk --config "${LSTK_CONFIG_FILE}" logs | ||
| lstk --config "${LSTK_CONFIG_FILE}" stop | ||
| - name: "Check Uncommitted Changes" | ||
| run: | | ||
| if [ -n "$(git status --porcelain)" ]; then | ||
| echo "Uncommitted changes detected." | ||
| git diff | ||
| exit 1 | ||
| fi | ||
| - name: "Create the Release Commit and Tag" | ||
| run: | | ||
| git commit --allow-empty -m "Release: v${RELEASE_VERSION}" | ||
| git tag -a "v${RELEASE_VERSION}" -m "Release: v${RELEASE_VERSION}" | ||
| - name: "Push the release commit and tag" | ||
| run: git push --follow-tags | ||
| - name: "Publish Release to PyPi" | ||
| env: | ||
| UV_PUBLISH_TRUSTED_PUBLISHING: always | ||
| run: make publish | ||
| - name: "Create GitHub Release" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.LOCALSTACK_GITHUB_TOKEN }} | ||
| run: gh release create "v${RELEASE_VERSION}" --generate-notes | ||
| - name: "Show Git Modifications" | ||
| run: | | ||
| git log --oneline -n 4 | ||
| git show HEAD~1 | ||
| git show HEAD | ||