Skip to content

Commit 9ad5d13

Browse files
authored
Update GHAs workflows (#17)
* Update GHAs workflows This PR updates the GHA workflows. It mostly matches nutechsoftware/alarmdecoder#79. * rm cache option I think it only supports `requirements.txt` and `pyproject.toml` files * rm unnecessary dependency * use python `3.12` this was the version being used before these changes * enable PyPI attestation * revert release testing changes
1 parent 13d0888 commit 9ad5d13

9 files changed

Lines changed: 123 additions & 78 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: build-and-test
2+
description: |
3+
Set up Python and run the build and test steps.
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Set up Python
9+
uses: ./.github/actions/setup-python
10+
# TODO: move dependencies to a separate file (e.g. a requirements.txt file)
11+
- name: Install dependencies
12+
shell: bash
13+
run: |
14+
python -m pip install pytest build
15+
- name: Run build
16+
shell: bash
17+
run: python -m build
18+
- name: Show dist files
19+
shell: bash
20+
run: |
21+
echo "Dist files:"
22+
ls -lh dist/
23+
- name: Run pytest
24+
shell: bash
25+
run: |
26+
python -m pip install -e .
27+
pytest
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: build-and-test
2+
description: |
3+
This action lets the Python version for CI be specified in a single place.
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Set up Python
9+
uses: actions/setup-python@v5
10+
with:
11+
python-version: "3.12"

.github/release-drafter.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/merge.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This workflow builds and tests code that is pushed to the `master` branch.
2+
3+
name: merge
4+
5+
on:
6+
push:
7+
branches:
8+
- master
9+
10+
jobs:
11+
merge:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-tags: true
18+
fetch-depth: 0
19+
- name: Build and test
20+
uses: ./.github/actions/build-and-test

.github/workflows/pr.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This workflow builds and tests code in pull requests.
2+
3+
name: pr
4+
5+
on: pull_request
6+
7+
jobs:
8+
pr:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repo
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-tags: true
15+
fetch-depth: 0
16+
- name: Build and test
17+
uses: ./.github/actions/build-and-test

.github/workflows/pulls.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/pypi-upload.yaml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/release-drafter.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This workflow initiates a release of the project.
2+
3+
name: release
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: Release version (e.g. `v0.4.5`)
10+
type: string
11+
required: true
12+
13+
jobs:
14+
release:
15+
permissions:
16+
# `contents: write` is required to create tags and create releases
17+
# `id-token: write` is required for PyPI attestations
18+
contents: write
19+
id-token: write
20+
runs-on: ubuntu-latest
21+
env:
22+
RELEASE_VERSION: ${{ inputs.version }}
23+
steps:
24+
- name: Checkout repo
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-tags: true
28+
fetch-depth: 0
29+
- name: Create local lightweight tag
30+
run: git tag "${RELEASE_VERSION}"
31+
- name: Build and test
32+
uses: ./.github/actions/build-and-test
33+
- name: Push tag
34+
run: git push origin "${RELEASE_VERSION}"
35+
- name: Create release from tag
36+
env:
37+
GH_TOKEN: ${{ github.token }}
38+
run: |
39+
gh api \
40+
--method POST \
41+
"/repos/${GITHUB_REPOSITORY}/releases" \
42+
-f "tag_name=${RELEASE_VERSION}" \
43+
-f "name=${RELEASE_VERSION}" \
44+
-F "draft=false" \
45+
-F "prerelease=false" \
46+
-F "generate_release_notes=true"
47+
- name: Publish package distributions to PyPI
48+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)