Skip to content

Commit 962a63f

Browse files
authored
ci: Automate release process with release please (#2)
1 parent 06a3701 commit 962a63f

File tree

14 files changed

+231
-4
lines changed

14 files changed

+231
-4
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Bug report
33
about: Create a report to help us improve
44
title: ''
5-
labels: ''
5+
labels: 'bug'
66
assignees: ''
77

88
---

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Feature request
33
about: Suggest an idea for this project
44
title: ''
5-
labels: ''
5+
labels: 'feature'
66
assignees: ''
77

88
---
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Build Documentation
2+
description: 'Build Documentation.'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Build Documentation
8+
shell: bash
9+
run: make docs

.github/actions/build/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Build distribution files
2+
description: 'Build distribution files'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Build distribution files
8+
shell: bash
9+
run: poetry build

.github/actions/publish/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Publish Package
2+
description: 'Publish the package to PyPI'
3+
inputs:
4+
token:
5+
description: 'Token to use for publishing.'
6+
required: true
7+
dry_run:
8+
description: 'Is this a dry run. If so no package will be published.'
9+
required: true
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Publish package distributions to PyPI
15+
uses: pypa/gh-action-pypi-publish@release/v1
16+
if: ${{ inputs.dry_run == 'false' }}
17+
with:
18+
password: ${{inputs.token}}

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Quality control checks
2+
3+
on:
4+
push:
5+
branches: [ main, 'feat/**' ]
6+
paths-ignore:
7+
- '**.md' # Do not need to run CI for markdown changes.
8+
pull_request:
9+
branches: [ main, 'feat/**' ]
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
linux:
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install poetry
29+
run: pipx install poetry
30+
31+
- uses: ./.github/actions/build
32+
- uses: ./.github/actions/build-docs
33+
34+
- name: Run tests
35+
run: make test
36+
37+
- name: Verify typehints
38+
run: make lint
39+
40+
windows:
41+
runs-on: windows-latest
42+
43+
defaults:
44+
run:
45+
shell: powershell
46+
47+
strategy:
48+
matrix:
49+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
- name: Set up Python ${{ matrix.python-version }}
54+
uses: actions/setup-python@v4
55+
with:
56+
python-version: ${{ matrix.python-version }}
57+
58+
- name: Install requirements
59+
run: |
60+
pipx install poetry
61+
poetry install --all-extras
62+
63+
- name: Run tests
64+
run: make test
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Lint PR title
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
lint-pr-title:
12+
uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish Package
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
dry_run:
6+
description: 'Is this a dry run? If so no package will be published.'
7+
type: boolean
8+
required: true
9+
10+
jobs:
11+
build-publish:
12+
runs-on: ubuntu-latest
13+
# Needed to get tokens during publishing.
14+
permissions:
15+
id-token: write
16+
contents: read
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: actions/setup-python@v4
21+
with:
22+
python-version: 3.8
23+
24+
- name: Install poetry
25+
run: pipx install poetry
26+
27+
- uses: launchdarkly/gh-actions/actions/[email protected]
28+
name: 'Get PyPI token'
29+
with:
30+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
31+
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
32+
33+
- uses: ./.github/actions/build
34+
35+
- uses: ./.github/actions/publish
36+
with:
37+
token: ${{env.PYPI_AUTH_TOKEN}}
38+
dry_run: ${{ inputs.dry_run }}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Run Release Please
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
release-package:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
id-token: write # Needed if using OIDC to get release secrets.
12+
contents: write # Contents and pull-requests are for release-please to make releases.
13+
pull-requests: write
14+
steps:
15+
- uses: google-github-actions/release-please-action@v3
16+
id: release
17+
with:
18+
command: manifest
19+
token: ${{secrets.GITHUB_TOKEN}}
20+
default-branch: main
21+
22+
- uses: actions/checkout@v4
23+
if: ${{ steps.release.outputs.releases_created }}
24+
with:
25+
fetch-depth: 0 # If you only need the current version keep this.
26+
27+
- uses: actions/setup-python@v4
28+
if: ${{ steps.release.outputs.releases_created }}
29+
with:
30+
python-version: 3.8
31+
32+
- name: Install poetry
33+
if: ${{ steps.release.outputs.releases_created }}
34+
run: pipx install poetry
35+
36+
- uses: launchdarkly/gh-actions/actions/[email protected]
37+
if: ${{ steps.release.outputs.releases_created }}
38+
name: 'Get PyPI token'
39+
with:
40+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
41+
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
42+
43+
- uses: ./.github/actions/build
44+
if: ${{ steps.release.outputs.releases_created }}
45+
46+
- uses: ./.github/actions/build-docs
47+
if: ${{ steps.release.outputs.releases_created }}
48+
49+
- uses: ./.github/actions/publish
50+
if: ${{ steps.release.outputs.releases_created }}
51+
with:
52+
token: ${{env.PYPI_AUTH_TOKEN}}
53+
dry_run: false

.github/workflows/stale.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: 'Close stale issues and PRs'
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
# Happen once per day at 1:30 AM
6+
- cron: '30 1 * * *'
7+
8+
jobs:
9+
sdk-close-stale:
10+
uses: launchdarkly/gh-actions/.github/workflows/sdk-stale.yml@main

0 commit comments

Comments
 (0)