Skip to content

Commit 604b471

Browse files
authored
Merge pull request #503 from sadsfae/master
feat: rework/refactor GHA and CI/CD.
2 parents 5479168 + 60db761 commit 604b471

File tree

7 files changed

+232
-78
lines changed

7 files changed

+232
-78
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Development Build
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- master
7+
8+
concurrency:
9+
group: dev-build-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
quay_dev:
14+
name: Push Quay (Dev)
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
19+
steps:
20+
- name: Checkout Code
21+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
23+
- name: Podman Login
24+
env:
25+
QUAY_USER: ${{ secrets.QUAY_USERNAME }}
26+
QUAY_TOKEN: ${{ secrets.QUAY_API_TOKEN }}
27+
run: echo "$QUAY_TOKEN" | podman login -u="$QUAY_USER" --password-stdin quay.io
28+
29+
- name: Clean Old Development Tag
30+
env:
31+
QUAY_USER: ${{ secrets.QUAY_USERNAME }}
32+
QUAY_TOKEN: ${{ secrets.QUAY_API_TOKEN }}
33+
run: |
34+
REPO="quay.io/quads/badfish"
35+
echo "$QUAY_TOKEN" | skopeo login -u="$QUAY_USER" --password-stdin quay.io
36+
37+
echo "Attempting to delete old development tag..."
38+
skopeo delete "docker://$REPO:development" || echo "Tag development not found or already deleted."
39+
40+
- name: Build and Push Dev
41+
run: |
42+
# Added --no-cache to ensure fresh layers
43+
podman build --no-cache -t quay.io/quads/badfish:development .
44+
podman push quay.io/quads/badfish:development
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Production Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
concurrency:
9+
group: production-release
10+
cancel-in-progress: true
11+
12+
jobs:
13+
# ------------------------------------------------------------------
14+
# JOB 1: RELEASE (Calculate Version, Tag, Push to PyPI)
15+
# ------------------------------------------------------------------
16+
release:
17+
name: Semantic Release
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write # Needed to create releases/tags
21+
id-token: write # Needed for PyPI trusted publishing
22+
outputs:
23+
released: ${{ steps.semantic.outputs.released }}
24+
tag: ${{ steps.semantic.outputs.tag }}
25+
version: ${{ steps.semantic.outputs.version }}
26+
27+
steps:
28+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Python Semantic Release
33+
id: semantic
34+
uses: python-semantic-release/python-semantic-release@7f12e960334860b29ce37894a485596489438914 # v9.15.0
35+
with:
36+
github_token: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Publish to PyPI
39+
if: steps.semantic.outputs.released == 'true'
40+
uses: pypa/gh-action-pypi-publish@67339c736fd9352e5f1a7421053be3d68444052f # release/v1
41+
with:
42+
password: ${{ secrets.PYPI_API_TOKEN }}
43+
44+
# ------------------------------------------------------------------
45+
# JOB 2: COPR BUILD (Fedora SRPM)
46+
# ------------------------------------------------------------------
47+
copr_build:
48+
name: Submit to COPR
49+
needs: release
50+
if: needs.release.outputs.released == 'true'
51+
runs-on: ubuntu-latest
52+
container: fedora:latest
53+
permissions:
54+
contents: read
55+
56+
steps:
57+
- name: Install Git
58+
run: dnf -y install git
59+
60+
- name: Checkout Tagged Release
61+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
62+
with:
63+
ref: ${{ needs.release.outputs.tag }}
64+
65+
- name: Install tooling
66+
run: |
67+
dnf -y install @development-tools @rpm-development-tools copr-cli make zlib-devel
68+
69+
- name: Work around GHA permission issue
70+
run: git config --global --add safe.directory /__w/badfish/badfish
71+
72+
- name: Setup COPR Config
73+
env:
74+
API_TOKEN_CONTENT: ${{ secrets.COPR_API_TOKEN }}
75+
run: |
76+
mkdir -p "$HOME/.config"
77+
echo "$API_TOKEN_CONTENT" > "$HOME/.config/copr"
78+
79+
- name: Sync Spec Version and Build
80+
env:
81+
RELEASE_VERSION: ${{ needs.release.outputs.version }}
82+
run: |
83+
cd rpm
84+
sed -i "s/^Version:.*/Version: ${RELEASE_VERSION}/" python3-badfish.spec
85+
make srpm
86+
SRPM_FILE=$(find . -name "*.src.rpm" -type f | head -n 1)
87+
if [ -z "$SRPM_FILE" ]; then
88+
echo "Error: No .src.rpm file found in $(pwd) or subdirectories."
89+
echo "Ensure your Makefile outputs the SRPM locally or defines _topdir."
90+
exit 1
91+
fi
92+
echo "Found SRPM: $SRPM_FILE"
93+
copr build quadsdev/badfish "$SRPM_FILE"
94+
# ------------------------------------------------------------------
95+
# JOB 3: QUAY PUBLISH (Master & Latest)
96+
# ------------------------------------------------------------------
97+
quay_master:
98+
name: Push Quay (Master)
99+
needs: release
100+
if: needs.release.outputs.released == 'true'
101+
runs-on: ubuntu-latest
102+
permissions:
103+
contents: read
104+
105+
steps:
106+
- name: Checkout Tagged Release
107+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
108+
with:
109+
ref: ${{ needs.release.outputs.tag }}
110+
111+
- name: Podman Login
112+
env:
113+
QUAY_USER: ${{ secrets.QUAY_USERNAME }}
114+
QUAY_TOKEN: ${{ secrets.QUAY_API_TOKEN }}
115+
run: echo "$QUAY_TOKEN" | podman login -u="$QUAY_USER" --password-stdin quay.io
116+
117+
- name: Clean Old Tags
118+
env:
119+
QUAY_USER: ${{ secrets.QUAY_USERNAME }}
120+
QUAY_TOKEN: ${{ secrets.QUAY_API_TOKEN }}
121+
run: |
122+
REPO="quay.io/quads/badfish"
123+
echo "$QUAY_TOKEN" | skopeo login -u="$QUAY_USER" --password-stdin quay.io
124+
125+
# Delete 'master' and 'latest' if they exist
126+
for tag in master latest; do
127+
echo "Attempting to delete old tag: $tag"
128+
skopeo delete "docker://$REPO:$tag" || echo "Tag $tag not found or already deleted."
129+
done
130+
131+
- name: Build and Push
132+
run: |
133+
# Added --no-cache to ensure fresh layers
134+
podman build --no-cache -t quay.io/quads/badfish:master .
135+
podman tag quay.io/quads/badfish:master quay.io/quads/badfish:latest
136+
podman push quay.io/quads/badfish:master
137+
podman push quay.io/quads/badfish:latest

.github/workflows/push-copr-build.yml

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

.github/workflows/source-tarball.yml

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

.github/workflows/sync-back.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Sync Back to Development
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Production Release"]
6+
types:
7+
- completed
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
sync-branches:
14+
runs-on: ubuntu-latest
15+
# Only run if the Production Release actually succeeded
16+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
17+
18+
steps:
19+
- name: Checkout Source Code
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
# Fetch full history to ensure merge works
23+
fetch-depth: 0
24+
# We need to checkout development, but the context starts at the default branch (usually master)
25+
ref: development
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Merge Master into Development
29+
run: |
30+
git config --global user.name 'github-actions[bot]'
31+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
32+
33+
# Fetch latest updates from origin
34+
git fetch origin
35+
36+
# Merge origin/master (which holds the new version commit) into the current branch (development)
37+
# We use --no-ff to create a merge commit, or plain merge is fine too.
38+
# If there are no changes in dev, this is a fast-forward.
39+
echo "Merging master back into development..."
40+
git merge origin/master --no-edit
41+
42+
# Push the update back to development
43+
git push origin development

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ build-backend = "setuptools.build_meta"
44

55
[tool.black]
66
line-length = 120
7+
8+
[tool.semantic_release]
9+
version_variables = [
10+
"src/badfish/__init__.py:__version__"
11+
]
12+
branch = "master"
13+
build_command = "pip install build && python -m build"

src/badfish/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "1.0.7"

0 commit comments

Comments
 (0)