Skip to content

Commit 524b5f3

Browse files
committed
Update GHAs workflows
This PR updates the GHA workflows. It mostly matches nutechsoftware/alarmdecoder#79.
1 parent 13d0888 commit 524b5f3

9 files changed

Lines changed: 130 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 mock 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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.10"
12+
cache: pip

.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: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
on: pull_request
14+
15+
jobs:
16+
release:
17+
permissions:
18+
# `contents: write` is required to create tags and create releases
19+
contents: write
20+
runs-on: ubuntu-latest
21+
env:
22+
# RELEASE_VERSION: ${{ inputs.version }}
23+
RELEASE_VERSION: v0.4.5
24+
steps:
25+
- name: Checkout repo
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-tags: true
29+
fetch-depth: 0
30+
- name: Create local lightweight tag
31+
run: git tag "${RELEASE_VERSION}"
32+
- name: Build and test
33+
uses: ./.github/actions/build-and-test
34+
# - name: Push tag
35+
# run: git push origin "${RELEASE_VERSION}"
36+
# - name: Create release from tag
37+
# env:
38+
# GH_TOKEN: ${{ github.token }}
39+
# run: |
40+
# gh api \
41+
# --method POST \
42+
# "/repos/${GITHUB_REPOSITORY}/releases" \
43+
# -f "tag_name=${RELEASE_VERSION}" \
44+
# -f "name=${RELEASE_VERSION}" \
45+
# -F "draft=false" \
46+
# -F "prerelease=false" \
47+
# -F "generate_release_notes=true"
48+
# - name: Publish package distributions to PyPI
49+
# # TODO: setup attestations and trusted publishing.
50+
# uses: pypa/gh-action-pypi-publish@release/v1
51+
# with:
52+
# # attestations require trusted publishing which isn't setup yet
53+
# attestations: false
54+
# password: ${{ secrets.PYPI_TOKEN }}

0 commit comments

Comments
 (0)