Skip to content

Commit da7895b

Browse files
committed
Add a release ci
1 parent 82dffe4 commit da7895b

File tree

4 files changed

+108
-2
lines changed

4 files changed

+108
-2
lines changed

.github/workflows/ci.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- uses: astral-sh/setup-uv@v4
14+
with:
15+
version: "latest"
16+
17+
- run: uv sync
18+
19+
- name: Ruff check
20+
run: uv run ruff check src/ tests/
21+
22+
- name: Ruff format check
23+
run: uv run ruff format --check src/ tests/
24+
25+
test:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: astral-sh/setup-uv@v4
31+
with:
32+
version: "latest"
33+
34+
- run: uv sync
35+
36+
- name: Run unit tests
37+
run: uv run pytest -m "not integration" -v
38+
39+
version-check:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
46+
- name: Check version has been bumped
47+
run: |
48+
PR_VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
49+
LATEST_TAG=$(git tag --sort=-v:refname | head -1 | sed 's/^v//')
50+
51+
if [ -z "$LATEST_TAG" ]; then
52+
echo "No existing tags. Version $PR_VERSION will be the first release."
53+
exit 0
54+
fi
55+
56+
echo "PR version: $PR_VERSION"
57+
echo "Latest release: $LATEST_TAG"
58+
59+
if [ "$PR_VERSION" = "$LATEST_TAG" ]; then
60+
echo ""
61+
echo "Error: Version has not been bumped."
62+
echo "Update the version in pyproject.toml before merging."
63+
exit 1
64+
fi
65+
66+
# Compare versions: PR version must be greater than latest tag
67+
HIGHER=$(printf '%s\n%s' "$LATEST_TAG" "$PR_VERSION" | sort -V | tail -1)
68+
if [ "$HIGHER" != "$PR_VERSION" ]; then
69+
echo ""
70+
echo "Error: PR version ($PR_VERSION) is not higher than latest release ($LATEST_TAG)."
71+
exit 1
72+
fi
73+
74+
echo "Version bump confirmed: $LATEST_TAG -> $PR_VERSION"

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Get version from pyproject.toml
17+
id: version
18+
run: |
19+
VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
20+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
21+
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
22+
23+
- name: Create tag and release
24+
run: |
25+
gh release create "${{ steps.version.outputs.tag }}" \
26+
--title "${{ steps.version.outputs.tag }}" \
27+
--generate-notes
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

src/gds_idea_app_kit/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""GDS IDEA App Kit - CLI tool for scaffolding and maintaining web apps on AWS."""
22

3-
__version__ = "0.1.0"
3+
from importlib.metadata import version
4+
5+
__version__ = version("gds-idea-app-kit")
46

57
# Default Python version for new projects. Update this when a new stable CPython is released.
68
DEFAULT_PYTHON_VERSION = "3.13"

src/gds_idea_app_kit/init.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ def run_init(framework: str, app_name: str, python_version: str) -> None:
301301
click.echo("Installing CDK dependencies...")
302302
_run_command(
303303
[
304-
"uv", "add",
304+
"uv",
305+
"add",
305306
"aws-cdk-lib",
306307
"constructs",
307308
"gds-idea-cdk-constructs @ git+ssh://git@github.com/co-cddo/gds-idea-cdk-constructs.git",

0 commit comments

Comments
 (0)