add ci workflow #5
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
| # LocalStack specific workflow to implement a fully-integrated continuous integration pipeline for our fork | |
| # - Rebase this fork based on the latest commit on `main` of upstream | |
| # - Build a Python source and wheel distribution of moto-ext with deterministic versioning | |
| # - Publish the distributions to PyPi | |
| # - Tag the commit in this fork with the new version | |
| # - Create a GitHub release for the new version | |
| name: Sync / Release moto-ext | |
| on: | |
| # TODO remove this trigger after testing | |
| push: | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: 'Dry Run?' | |
| default: true | |
| required: true | |
| type: boolean | |
| # limit concurrency to 1 | |
| concurrency: | |
| group: ${{ github.workflow }} | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync-build-release-moto-ext: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/moto-ext/ | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: localstack | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.13' | |
| - name: Rebase localstack branch with latest master from upstream | |
| run: | | |
| # Configure git | |
| git config --global user.name 'LocalStack Bot' | |
| git config --global user.email 'localstack-bot@users.noreply.github.com' | |
| # make sure to switch to the `localstack` branch (default / main branch of this fork) | |
| git switch localstack | |
| # add moto upstream as remote | |
| git remote add upstream https://github.com/get-moto/moto.git | |
| # rebase with latest changes | |
| git pull | |
| git fetch upstream | |
| git rebase upstream/master | |
| - name: Determine new version | |
| run: | | |
| echo "Determining new version..." | |
| cat > setuptools.cfg << EOF | |
| [tool.setuptools_scm] | |
| local_scheme = "no-local-version" | |
| EOF | |
| python3 -m venv .venv | |
| source .venv/bin/activate | |
| python3 -m pip install setuptools_scm build | |
| NEW_VERSION=$(python3 -m setuptools_scm -c setuptools.cfg) | |
| NEW_VERSION="${NEW_VERSION//dev/post}" | |
| echo "New version is: $NEW_VERSION" | |
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
| - name: Build Python distributions | |
| # FYI: Checks in this script only work because the -e flag is enabled by default in GitHub actions | |
| run: | | |
| echo "Setting new version in setup.cfg": | |
| # make sure setup.cfg is not dirty yet | |
| git diff --exit-code setup.cfg | |
| sed -i -E 's/^(version\s*=\s*)("?)[^"]+("?)/\1\2'"$NEW_VERSION"'\3/' setup.cfg | |
| # make sure setup.cfg is dirty now | |
| ! git diff --exit-code setup.cfg | |
| echo "Building new version and tagging commit..." | |
| python3 -m build | |
| - name: Tag successful build | |
| run: | | |
| git tag -a $NEW_VERSION -m $NEW_VERSION | |
| - name: Clean up | |
| run: | | |
| git reset --hard | |
| git clean -df | |
| - name: Store built distributions | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: moto-ext-dists | |
| path: dist/*.* | |
| # publish the package before pushing the tag (this might fail if the version already exists on PyPI) | |
| - name: Publish package distributions to PyPI | |
| if: ${{ github.event.inputs.dry_run == false }} | |
| run: | | |
| echo "Ensure that this is really only triggered if dry run is explicitly set to false" | |
| # uses: pypa/gh-action-pypi-publish@release/v1 | |
| - name: Push & Create Release | |
| if: ${{ github.event.inputs.dry_run == false }} | |
| run: | | |
| echo "Ensure that this is really only triggered if dry run is explicitly set to false" | |
| # git push --force-with-lease | |
| # git push --atomic origin localstack $NEW_VERSION | |
| # gh release create $NEW_VERSION |