Skip to content

Commit 9efc8a5

Browse files
committed
Add test release workflow
1 parent 1bde761 commit 9efc8a5

3 files changed

Lines changed: 97 additions & 3 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ name: "CodeQL"
77

88
on:
99
push:
10-
branches: [master]
10+
branches: [main]
1111
pull_request:
1212
# The branches below must be a subset of the branches above
13-
branches: [master]
13+
branches: [main]
1414
schedule:
1515
- cron: '0 21 * * 3'
1616

.github/workflows/test-release.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
name: Test Release to TestPyPI
3+
4+
on:
5+
push:
6+
branches:
7+
- release-dev
8+
paths:
9+
- "setup.py"
10+
- ".github/workflows/test-release.yml"
11+
12+
jobs:
13+
test-release:
14+
name: Build and Publish to TestPyPI
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout source code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.11'
25+
26+
- name: Read version from setup.py
27+
id: getversion
28+
run: |
29+
echo "version=$(python ./setup.py --version)" >> $GITHUB_OUTPUT
30+
echo "Version detected: $(python ./setup.py --version)"
31+
32+
# Fetch tags to check if version tag already exists
33+
- name: Fetch tags
34+
run: git fetch --tags origin
35+
36+
- name: Check if tag already exists
37+
id: tagcheck
38+
run: |
39+
if git rev-parse "v${{ steps.getversion.outputs.version }}" >/dev/null 2>&1; then
40+
echo "Tag v${{ steps.getversion.outputs.version }} already exists"
41+
echo "should_release=false" >> $GITHUB_OUTPUT
42+
else
43+
echo "Tag v${{ steps.getversion.outputs.version }} does not exist - will proceed with release"
44+
echo "should_release=true" >> $GITHUB_OUTPUT
45+
fi
46+
47+
- name: Install build dependencies
48+
if: steps.tagcheck.outputs.should_release == 'true'
49+
run: |
50+
python -m pip install --upgrade pip
51+
pip install build twine
52+
53+
- name: Install package dependencies
54+
if: steps.tagcheck.outputs.should_release == 'true'
55+
run: |
56+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
57+
58+
- name: Build package
59+
if: steps.tagcheck.outputs.should_release == 'true'
60+
run: python -m build
61+
62+
- name: Check package with twine
63+
if: steps.tagcheck.outputs.should_release == 'true'
64+
run: twine check dist/*
65+
66+
- name: Publish to TestPyPI
67+
if: steps.tagcheck.outputs.should_release == 'true'
68+
uses: pypa/gh-action-pypi-publish@release/v1
69+
with:
70+
repository-url: https://test.pypi.org/legacy/
71+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
72+
skip-existing: true
73+
74+
- name: Get wheel filename
75+
if: steps.tagcheck.outputs.should_release == 'true'
76+
id: getwheelfile
77+
run: |
78+
echo "wheelfile=$(find dist -type f -name '*.whl')" >> $GITHUB_OUTPUT
79+
echo "tarfile=$(find dist -type f -name '*.tar.gz')" >> $GITHUB_OUTPUT
80+
81+
- name: Create GitHub Release
82+
if: steps.tagcheck.outputs.should_release == 'true'
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
tag_name: v${{ steps.getversion.outputs.version }}
86+
name: Release v${{ steps.getversion.outputs.version }} (Test)
87+
draft: false
88+
prerelease: true
89+
generate_release_notes: true
90+
files: |
91+
${{ steps.getwheelfile.outputs.wheelfile }}
92+
${{ steps.getwheelfile.outputs.tarfile }}
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
name="pre-commit-macadmin",
77
description="Pre-commit hooks for Mac admins, client engineers, and IT consultants.",
88
url="https://github.com/homebysix/pre-commit-macadmin",
9-
version="1.23.0",
9+
version="1.23.1",
1010
author="Elliot Jordan",
1111
author_email="elliot@elliotjordan.com",
1212
packages=["pre_commit_macadmin_hooks"],

0 commit comments

Comments
 (0)