Skip to content

Commit e1be44a

Browse files
Merge pull request #157 from Create-Python-App/feat/issue-155-156-homebrew-aur
Merge Homebrew/AUR/Docker distribution parity. Pre-existing lint/test failures on main are unrelated.
2 parents 703850a + 3959219 commit e1be44a

7 files changed

Lines changed: 472 additions & 66 deletions

File tree

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
11
name: Notify Homebrew tap
2+
3+
# Triggers on release tags for the CLI package. Sends a
4+
# repository_dispatch event to Create-Python-App/homebrew-tap so its
5+
# update-formula workflow can bump the formula and push it.
26
on:
37
push:
48
tags:
59
- "create-awesome-python-app@*"
610
workflow_dispatch:
711
inputs:
812
version:
9-
description: "Package version"
13+
description: "Package version (e.g. 0.1.0)"
1014
required: true
15+
16+
permissions:
17+
contents: read
18+
1119
jobs:
1220
notify:
21+
name: Dispatch to homebrew-tap
1322
runs-on: ubuntu-latest
1423
steps:
15-
- name: Dispatch to homebrew-tap
24+
- name: Resolve version
25+
id: version
26+
env:
27+
TAG_REF: ${{ github.ref_name }}
28+
INPUT_VERSION: ${{ github.event.inputs.version }}
1629
run: |
17-
echo "Send repository_dispatch to Create-Python-App/homebrew-tap when it exists"
18-
echo "Secret: HOMEBREW_TAP_TOKEN"
30+
if [ -n "$INPUT_VERSION" ]; then
31+
VERSION="$INPUT_VERSION"
32+
else
33+
VERSION="${TAG_REF#create-awesome-python-app@}"
34+
fi
35+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
36+
37+
- name: Dispatch repository event
38+
env:
39+
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
40+
VERSION: ${{ steps.version.outputs.version }}
41+
run: |
42+
if [ -z "$GH_TOKEN" ]; then
43+
echo "::error::HOMEBREW_TAP_TOKEN secret is not set" >&2
44+
exit 1
45+
fi
46+
gh api \
47+
--method POST \
48+
-H "Accept: application/vnd.github+json" \
49+
/repos/Create-Python-App/homebrew-tap/dispatches \
50+
-f "event_type=new-release" \
51+
-f "client_payload[version]=$VERSION"

.github/workflows/publish-aur.yml

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,91 @@
11
name: Publish to AUR
2+
3+
# Triggers on release tags for the CLI package.
4+
# Publishes the updated PKGBUILD to aur.archlinux.org and keeps the
5+
# Create-Python-App/aur-package GitHub mirror in sync.
26
on:
37
push:
48
tags:
59
- "create-awesome-python-app@*"
610
workflow_dispatch:
711
inputs:
812
version:
9-
description: "Package version"
13+
description: "Package version (e.g. 0.1.0)"
1014
required: true
15+
16+
permissions:
17+
contents: read
18+
1119
jobs:
1220
aur:
21+
name: Update AUR package
1322
runs-on: ubuntu-latest
1423
steps:
15-
- uses: actions/checkout@v4
16-
- name: Placeholder
24+
- name: Resolve version
25+
id: version
26+
env:
27+
TAG_REF: ${{ github.ref_name }}
28+
INPUT_VERSION: ${{ github.event.inputs.version }}
1729
run: |
18-
echo "AUR publish requires AUR_SSH_PRIVATE_KEY + optional Create-Python-App/aur-package mirror"
19-
echo "See docs/DISTRIBUTION_SETUP.md"
30+
if [ -n "$INPUT_VERSION" ]; then
31+
VERSION="$INPUT_VERSION"
32+
else
33+
VERSION="${TAG_REF#create-awesome-python-app@}"
34+
fi
35+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
36+
37+
- name: Checkout aur-package mirror repo
38+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
39+
with:
40+
repository: Create-Python-App/aur-package
41+
token: ${{ secrets.AUR_REPO_TOKEN }}
42+
path: aur-package
43+
44+
- name: Update PKGBUILD (version + sha256 from PyPI)
45+
working-directory: aur-package
46+
env:
47+
NEW_VERSION: ${{ steps.version.outputs.version }}
48+
run: |
49+
set -euo pipefail
50+
# Reset pkgver and pkgrel; source URL already interpolates ${pkgver}.
51+
sed -i "s/^pkgver=.*/pkgver=${NEW_VERSION}/" PKGBUILD
52+
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
53+
54+
META=$(curl -sfL "https://pypi.org/pypi/create-awesome-python-app/${NEW_VERSION}/json")
55+
SHA=$(echo "$META" | jq -r '.urls[] | select(.packagetype=="sdist") | .digests.sha256')
56+
if [ -z "$SHA" ] || [ "$SHA" = "null" ]; then
57+
echo "::error::Failed to resolve PyPI sdist sha256 for v${NEW_VERSION}" >&2
58+
exit 1
59+
fi
60+
sed -i "s/^sha256sums=.*/sha256sums=('${SHA}')/" PKGBUILD
61+
62+
echo "----- Updated PKGBUILD -----"
63+
cat PKGBUILD
64+
65+
- name: Publish to AUR
66+
# Pushes to aur.archlinux.org via SSH. The action reads the
67+
# updated PKGBUILD, regenerates .SRCINFO, and pushes.
68+
uses: ulises-jeremias/github-actions-aur-publish@217e4e2abbbee9ecc942bdc0681302e233656d9f # v1
69+
with:
70+
pkgname: create-awesome-python-app
71+
pkgbuild: aur-package/PKGBUILD
72+
commit_username: "Create Python App Bot"
73+
commit_email: "ulisescf.24@gmail.com"
74+
commit_message: "Update to version ${{ steps.version.outputs.version }}"
75+
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
76+
allow_empty_commits: "false"
77+
# dsa is no longer supported in modern OpenSSH; omit it to
78+
# avoid "Unknown key type" errors during keyscan.
79+
ssh_keyscan_types: "rsa,ecdsa,ed25519"
80+
81+
- name: Sync updated PKGBUILD to GitHub mirror
82+
# Keep the aur-package GitHub mirror in sync with what's live
83+
# on AUR. Only PKGBUILD needs to be committed here — .SRCINFO
84+
# is regenerated automatically by AUR from PKGBUILD.
85+
uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0
86+
with:
87+
repository: aur-package
88+
commit_message: "chore: sync PKGBUILD for v${{ steps.version.outputs.version }}"
89+
commit_user_name: "Create Python App Bot"
90+
commit_user_email: "ulisescf.24@gmail.com"
91+
file_pattern: "PKGBUILD"
Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,96 @@
11
name: Publish Docker image
2+
3+
# Triggers on release tags for the CLI package. Version comes directly
4+
# from the tag ref (create-awesome-python-app@X.Y.Z).
25
on:
36
push:
47
tags:
58
- "create-awesome-python-app@*"
9+
# Manual trigger to rebuild an image for an existing version.
610
workflow_dispatch:
711
inputs:
812
version:
9-
description: "Package version"
13+
description: "Package version (e.g. 0.1.0)"
1014
required: true
15+
16+
permissions:
17+
contents: read
18+
1119
jobs:
1220
docker:
21+
name: Build and push Docker image
1322
runs-on: ubuntu-latest
1423
steps:
15-
- uses: actions/checkout@v4
16-
- name: Login to Docker Hub
17-
uses: docker/login-action@v3
24+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
25+
with:
26+
persist-credentials: false
27+
28+
- name: Resolve version
29+
id: version
30+
env:
31+
TAG_REF: ${{ github.ref_name }}
32+
INPUT_VERSION: ${{ github.event.inputs.version }}
33+
run: |
34+
if [ -n "$INPUT_VERSION" ]; then
35+
VERSION="$INPUT_VERSION"
36+
else
37+
# Tag format: create-awesome-python-app@X.Y.Z
38+
VERSION="${TAG_REF#create-awesome-python-app@}"
39+
fi
40+
MAJOR=$(echo "$VERSION" | cut -d. -f1)
41+
MINOR=$(echo "$VERSION" | cut -d. -f2)
42+
{
43+
echo "version=$VERSION"
44+
echo "major=$MAJOR"
45+
echo "minor=$MINOR"
46+
} >> "$GITHUB_OUTPUT"
47+
48+
- name: Set up QEMU
49+
# Required so buildx can cross-build linux/arm64 on the x86_64
50+
# ubuntu-latest runner.
51+
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
52+
with:
53+
platforms: linux/arm64
54+
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
57+
58+
- name: Log in to Docker Hub
59+
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
1860
with:
1961
username: ${{ secrets.DOCKERHUB_USERNAME }}
2062
password: ${{ secrets.DOCKERHUB_TOKEN }}
63+
64+
- name: Extract Docker metadata
65+
id: meta
66+
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
67+
with:
68+
images: ulisesjeremias/create-awesome-python-app
69+
# `latest` is pushed on tag pushes AND on explicit workflow_dispatch
70+
# runs (which always execute against main, so they represent the
71+
# current release).
72+
tags: |
73+
type=raw,value=latest
74+
type=raw,value=${{ steps.version.outputs.version }}
75+
type=raw,value=${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}
76+
type=raw,value=v${{ steps.version.outputs.major }}
77+
labels: |
78+
org.opencontainers.image.title=create-awesome-python-app
79+
org.opencontainers.image.description=Composable scaffolding CLI for production-ready Python apps
80+
org.opencontainers.image.url=https://github.com/Create-Python-App/create-python-app
81+
org.opencontainers.image.source=https://github.com/Create-Python-App/create-python-app
82+
org.opencontainers.image.licenses=MIT
83+
org.opencontainers.image.version=${{ steps.version.outputs.version }}
84+
2185
- name: Build and push
22-
uses: docker/build-push-action@v6
86+
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
2387
with:
2488
context: .
2589
push: true
26-
tags: |
27-
${{ secrets.DOCKERHUB_USERNAME }}/create-awesome-python-app:latest
90+
platforms: linux/amd64,linux/arm64
91+
tags: ${{ steps.meta.outputs.tags }}
92+
labels: ${{ steps.meta.outputs.labels }}
93+
build-args: |
94+
VERSION=${{ steps.version.outputs.version }}
95+
cache-from: type=gha
96+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)