Skip to content

Commit 392b6a0

Browse files
committed
add ci workflow
1 parent 18ad010 commit 392b6a0

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

.github/workflows/ci.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# LocalStack specific workflow to implement a fully-integrated continuous integration pipeline for our fork
2+
# - Rebase this fork based on the latest commit on `main` of upstream
3+
# - Build a Python source and wheel distribution of moto-ext with deterministic versioning
4+
# - Publish the distributions to PyPi
5+
# - Tag the commit in this fork with the new version
6+
# - Create a GitHub release for the new version
7+
8+
name: Sync / Release moto-ext
9+
10+
on:
11+
# TODO remove this trigger after testing
12+
push:
13+
workflow_dispatch:
14+
inputs:
15+
dry_run:
16+
description: 'Dry Run?'
17+
default: true
18+
required: true
19+
type: boolean
20+
21+
# limit concurrency to 1
22+
concurrency:
23+
group: ${{ github.workflow }}
24+
25+
permissions:
26+
contents: write
27+
28+
jobs:
29+
sync-build-release-moto-ext:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Setup Python
36+
uses: actions/setup-python@v6
37+
with:
38+
python-version: '3.13'
39+
40+
- name: Rebase localstack branch with latest master from upstream
41+
run: |
42+
# Configure git
43+
git config --global user.name 'LocalStack Bot'
44+
git config --global user.email 'localstack-bot@users.noreply.github.com'
45+
46+
# make sure to switch to the `localstack` branch (default / main branch of this fork)
47+
git switch localstack
48+
# add moto upstream as remote
49+
git remote add upstream git@github.com:getmoto/moto.git
50+
# rebase with latest changes
51+
git pull
52+
git fetch upstream
53+
git rebase upstream/master
54+
55+
- name: Determine new version
56+
run: |
57+
echo "Determining new version..."
58+
cat > setuptools.cfg << EOF
59+
[tool.setuptools_scm]
60+
local_scheme = "no-local-version"
61+
EOF
62+
python3 -m venv .venv
63+
source .venv/bin/activate
64+
python3 -m pip install setuptools_scm build
65+
NEW_VERSION=$(python3 -m setuptools_scm -c setuptools.cfg)
66+
NEW_VERSION="${NEW_VERSION//dev/post}"
67+
echo "New version is: $NEW_VERSION"
68+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
69+
70+
- name: Build Python distributions
71+
# FYI: Checks in this script only work because the -e flag is enabled by default in GitHub actions
72+
run: |
73+
echo "Setting new version in setup.cfg":
74+
# make sure setup.cfg is not dirty yet
75+
git diff --exit-code setup.cfg
76+
sed -i -E 's/^(version\s*=\s*)("?)[^"]+("?)/\1\2'"$NEW_VERSION"'\3/' setup.cfg
77+
# make sure setup.cfg is dirty now
78+
! git diff --exit-code setup.cfg
79+
80+
echo "Building new version and tagging commit..."
81+
python3 -m build
82+
83+
- name: Tag successful build
84+
run: |
85+
git tag -a $NEW_VERSION -m $NEW_VERSION
86+
87+
- name: Clean up
88+
run: |
89+
git reset --hard
90+
git clean -df
91+
92+
- name: Store built distributions
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: moto-ext-dists
96+
path: dist/*.*
97+
98+
# publish the package before pushing the tag (this might fail if the version already exists on PyPI)
99+
- name: Publish package distributions to PyPI
100+
if: ${{ github.event.inputs.dry_run == false }}
101+
run: |
102+
echo "Ensure that this is really only triggered if dry run is explicitly set to false"
103+
# uses: pypa/gh-action-pypi-publish@release/v1
104+
105+
- name: Push & Create Release
106+
if: ${{ github.event.inputs.dry_run == false }}
107+
run: |
108+
echo "Ensure that this is really only triggered if dry run is explicitly set to false"
109+
# git push --force-with-lease
110+
# git push --atomic origin localstack $NEW_VERSION
111+
# gh release create $NEW_VERSION

0 commit comments

Comments
 (0)