Skip to content

Commit 7f357bb

Browse files
ci: update github actions workflows and release management (#17)
1 parent cda2ec1 commit 7f357bb

14 files changed

Lines changed: 508 additions & 83 deletions

.github/release-drafter.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name-template: "$RESOLVED_VERSION"
2+
tag-template: "$RESOLVED_VERSION"
3+
4+
categories:
5+
- title: Breaking Changes
6+
labels: [breaking]
7+
- title: Features
8+
labels: [feat]
9+
- title: Bug Fixes
10+
labels: [fix]
11+
- title: Refactoring
12+
labels: [refactor]
13+
- title: Documentation
14+
labels: [docs]
15+
- title: Testing
16+
labels: [test]
17+
- title: Build
18+
labels: [build]
19+
20+
version-resolver:
21+
minor:
22+
labels: [breaking]
23+
default: patch
24+
25+
template: |
26+
$CHANGES
27+
change-template: "- $TITLE (#$NUMBER)"
28+
change-title-escapes: '\<*_&@'
29+
no-changes-template: "No changes"
30+
category-template: "### $TITLE"
31+
32+
exclude-labels:
33+
- release
34+
35+
replacers:
36+
- search: '/- (feat|fix|refactor|docs|ci|chore|test|build|release)(\(.+?\))?!?:\s*/g'
37+
replace: "- "
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Publish Coverage Badge
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish-coverage-badge:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- name: Trigger transformplan-static to update coverage badge
13+
uses: peter-evans/repository-dispatch@v2
14+
with:
15+
token: ${{ secrets.TRANSFORMPLAN_STATIC_TOKEN }}
16+
repository: limebit/transformplan-static
17+
event-type: publish-coverage-badge

.github/workflows/coverage.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Check Python Coverage
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
coverage:
10+
runs-on: ubuntu-22.04
11+
permissions:
12+
pull-requests: write
13+
14+
steps:
15+
- uses: actions/checkout@v5
16+
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v5
19+
with:
20+
enable-cache: true
21+
cache-dependency-glob: pyproject.toml
22+
python-version: "3.10"
23+
24+
- name: Install dependencies
25+
run: |
26+
uv sync --group tests
27+
28+
- name: Create coverage report
29+
run: |
30+
uv run coverage run -m pytest
31+
uv run coverage report -m --fail-under=99

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ concurrency:
1616

1717
jobs:
1818
build:
19-
runs-on: ubuntu-latest
19+
runs-on: ubuntu-22.04
2020
steps:
2121
- uses: actions/checkout@v5
2222

@@ -40,7 +40,7 @@ jobs:
4040

4141
deploy:
4242
needs: build
43-
runs-on: ubuntu-latest
43+
runs-on: ubuntu-22.04
4444
environment:
4545
name: github-pages
4646
url: ${{ steps.deployment.outputs.page_url }}

.github/workflows/formatting.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
format:
8-
runs-on: ubuntu-latest
8+
runs-on: ubuntu-22.04
99

1010
steps:
1111
- uses: actions/checkout@v5
@@ -18,7 +18,8 @@ jobs:
1818
python-version: "3.10"
1919

2020
- name: Install dependencies
21-
run: uv sync --group dev
21+
run: |
22+
uv sync --group dev
2223
2324
- name: Format with ruff
2425
run: uv run ruff format --check

.github/workflows/linting.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
lint:
8-
runs-on: ubuntu-latest
8+
runs-on: ubuntu-22.04
99

1010
steps:
1111
- uses: actions/checkout@v5
@@ -18,7 +18,8 @@ jobs:
1818
python-version: "3.10"
1919

2020
- name: Install dependencies
21-
run: uv sync --group dev
21+
run: |
22+
uv sync --group dev
2223
2324
- name: Lint with ruff
2425
run: uv run ruff check --output-format=github .

.github/workflows/pr-comment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
comment:
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-22.04
1010
permissions:
1111
pull-requests: write
1212

@@ -25,7 +25,7 @@ jobs:
2525
* Documentation is updated if necessary.
2626
`;
2727
28-
github.rest.issues.createComment({
28+
await github.rest.issues.createComment({
2929
issue_number: context.issue.number,
3030
owner: context.repo.owner,
3131
repo: context.repo.repo,

.github/workflows/pr-title.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: PR Title
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
validate-title:
13+
runs-on: ubuntu-22.04
14+
15+
steps:
16+
- name: Validate PR title
17+
uses: amannn/action-semantic-pull-request@v5
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
types: |
22+
feat
23+
fix
24+
refactor
25+
docs
26+
ci
27+
chore
28+
test
29+
build
30+
release
31+
requireScope: false
32+
33+
label-pr:
34+
needs: validate-title
35+
runs-on: ubuntu-22.04
36+
37+
steps:
38+
- name: Label PR by type
39+
uses: actions/github-script@v7
40+
with:
41+
script: |
42+
const title = context.payload.pull_request.title;
43+
const prNumber = context.payload.pull_request.number;
44+
45+
const typeMatch = title.match(/^(\w+)/);
46+
const labelsToAdd = [];
47+
const type = typeMatch ? typeMatch[1] : '';
48+
49+
const changelogTypes = ['feat', 'fix', 'refactor', 'docs', 'test', 'build'];
50+
if (changelogTypes.includes(type)) {
51+
labelsToAdd.push(type);
52+
}
53+
54+
if (type === 'release') {
55+
labelsToAdd.push('release');
56+
}
57+
58+
if (labelsToAdd.length > 0) {
59+
await github.rest.issues.addLabels({
60+
owner: context.repo.owner,
61+
repo: context.repo.repo,
62+
issue_number: prNumber,
63+
labels: labelsToAdd,
64+
});
65+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version override (leave empty to use release-drafter's resolved version)"
8+
required: false
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
prepare-release:
17+
runs-on: ubuntu-22.04
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v5
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v5
25+
26+
- name: Get draft release
27+
id: draft
28+
uses: release-drafter/release-drafter@v6
29+
with:
30+
disable-autolabeler: true
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Determine version
35+
id: version
36+
env:
37+
VERSION_OVERRIDE: ${{ inputs.version }}
38+
RESOLVED_VERSION: ${{ steps.draft.outputs.resolved_version }}
39+
run: |
40+
if [ -n "$VERSION_OVERRIDE" ]; then
41+
VERSION="$VERSION_OVERRIDE"
42+
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
43+
echo "::error::Version must be in semver format (e.g., 0.2.0)"
44+
exit 1
45+
fi
46+
else
47+
VERSION="$RESOLVED_VERSION"
48+
fi
49+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
50+
51+
- name: Update changelog
52+
uses: stefanzweifel/changelog-updater-action@v1
53+
with:
54+
latest-version: ${{ steps.version.outputs.version }}
55+
release-notes: ${{ steps.draft.outputs.body }}
56+
path-to-changelog: CHANGELOG.md
57+
heading-text: "[${{ steps.version.outputs.version }}]"
58+
59+
- name: Bump version
60+
env:
61+
VERSION: ${{ steps.version.outputs.version }}
62+
run: sed -i '0,/^version = ".*"/s//version = "'"$VERSION"'"/' pyproject.toml
63+
64+
- name: Update uv.lock
65+
run: uv lock
66+
67+
- name: Stage files
68+
run: git add CHANGELOG.md pyproject.toml uv.lock
69+
70+
- name: Create release PR
71+
env:
72+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
VERSION: ${{ steps.version.outputs.version }}
74+
run: |
75+
BRANCH="release/${VERSION}"
76+
77+
git checkout -b "$BRANCH"
78+
git -c user.name="github-actions[bot]" \
79+
-c user.email="github-actions[bot]@users.noreply.github.com" \
80+
commit -m "release: ${VERSION}"
81+
git push origin "$BRANCH"
82+
83+
BODY="## Release ${VERSION}
84+
85+
This PR was automatically generated by the release workflow.
86+
87+
### Checklist
88+
- [ ] Changelog looks correct
89+
- [ ] Version numbers are correct"
90+
91+
gh pr create \
92+
--title "release: ${VERSION}" \
93+
--body "$BODY" \
94+
--base main \
95+
--head "$BRANCH"

0 commit comments

Comments
 (0)