|
1 | 1 | 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. |
2 | 6 | on: |
3 | 7 | push: |
4 | 8 | tags: |
5 | 9 | - "create-awesome-python-app@*" |
6 | 10 | workflow_dispatch: |
7 | 11 | inputs: |
8 | 12 | version: |
9 | | - description: "Package version" |
| 13 | + description: "Package version (e.g. 0.1.0)" |
10 | 14 | required: true |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
11 | 19 | jobs: |
12 | 20 | aur: |
| 21 | + name: Update AUR package |
13 | 22 | runs-on: ubuntu-latest |
14 | 23 | 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 }} |
17 | 29 | 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" |
0 commit comments