Skip to content

Commit b9c7472

Browse files
authored
feat: draft releases, version verification, and reusable workflows (#287)
* feat: draft releases, version verification, and reusable workflows * fix: address comment
1 parent 42cb963 commit b9c7472

3 files changed

Lines changed: 32 additions & 23 deletions

File tree

.github/workflows/main.yaml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,37 @@ jobs:
6060
token: ${{ secrets.CODECOV_TOKEN }}
6161
slug: openfga/python-sdk
6262

63-
publish:
63+
verify-version:
6464
runs-on: ubuntu-latest
6565
if: startsWith(github.ref, 'refs/tags/v')
6666
needs: [test]
6767

68+
steps:
69+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
70+
71+
- name: Verify versions match
72+
run: |
73+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
74+
MANIFEST_VERSION=$(jq -r '.["."]' .release-please-manifest.json)
75+
PYPROJECT_VERSION=$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')
76+
77+
echo "Tag: $TAG_VERSION | Manifest: $MANIFEST_VERSION | pyproject.toml: $PYPROJECT_VERSION"
78+
79+
if [[ "$TAG_VERSION" != "$MANIFEST_VERSION" ]]; then
80+
echo "ERROR: Tag version does not match manifest version"
81+
exit 1
82+
fi
83+
if [[ "$PYPROJECT_VERSION" != "$MANIFEST_VERSION" ]]; then
84+
echo "ERROR: pyproject.toml version does not match manifest version"
85+
exit 1
86+
fi
87+
echo "All versions verified: $TAG_VERSION"
88+
89+
publish:
90+
runs-on: ubuntu-latest
91+
if: startsWith(github.ref, 'refs/tags/v')
92+
needs: [verify-version]
93+
6894
permissions:
6995
id-token: write # Required for PyPI trusted publishing
7096

@@ -91,20 +117,9 @@ jobs:
91117
- name: Publish package
92118
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
93119

94-
create-release:
95-
runs-on: ubuntu-latest
120+
undraft-release:
96121
if: startsWith(github.ref, 'refs/tags/v')
97122
needs: [publish]
98123
permissions:
99124
contents: write
100-
101-
steps:
102-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
103-
with:
104-
fetch-depth: 0
105-
106-
- uses: Roang-zero1/github-create-release-action@57eb9bdce7a964e48788b9e78b5ac766cb684803 # v3.0.1
107-
with:
108-
version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+
109-
env:
110-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125+
uses: openfga/sdk-generator/.github/workflows/undraft-release.yml@main

.github/workflows/pr-title-conventional-commit.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,8 @@ on:
77
- main
88

99
jobs:
10-
validate-pr-title:
11-
name: Validate PR Title
12-
runs-on: ubuntu-latest
10+
pr-title-check:
1311
permissions:
1412
pull-requests: read
15-
steps:
16-
- name: PR Conventional Commit Validation
17-
uses: ytanikin/pr-conventional-commits@639145d78959c53c43112365837e3abd21ed67c1 # v1.5.2
18-
with:
19-
task_types: '["feat","fix","docs","test","refactor","ci","perf","chore","revert","release"]'
20-
add_label: 'false'
13+
uses: openfga/sdk-generator/.github/workflows/pr-title-check.yml@main
2114

release-please-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
33
"release-type": "python",
44
"pull-request-title-pattern": "release: v${version}",
5+
"draft": true,
56
"packages": {
67
".": {
78
"package-name": "",

0 commit comments

Comments
 (0)