|
| 1 | +name: AUR Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'Tag to publish (e.g. v1.1.1)' |
| 11 | + required: true |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + publish: |
| 18 | + if: github.server_url == 'https://github.com' |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Resolve version |
| 22 | + id: version |
| 23 | + run: | |
| 24 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 25 | + TAG="${{ inputs.tag }}" |
| 26 | + else |
| 27 | + TAG="${GITHUB_REF_NAME}" |
| 28 | + fi |
| 29 | + PKGVER="${TAG#v}" |
| 30 | + echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
| 31 | + echo "pkgver=$PKGVER" >> "$GITHUB_OUTPUT" |
| 32 | +
|
| 33 | + - name: Wait for tarball & compute sha256 |
| 34 | + id: sha |
| 35 | + run: | |
| 36 | + URL="https://github.com/madLinux7/dstimer/archive/${{ steps.version.outputs.tag }}.tar.gz" |
| 37 | + for i in 1 2 3 4 5; do |
| 38 | + if curl -fsSL "$URL" -o src.tar.gz; then |
| 39 | + break |
| 40 | + fi |
| 41 | + echo "Tarball not ready, retry $i/5..." |
| 42 | + sleep 10 |
| 43 | + done |
| 44 | + SHA=$(sha256sum src.tar.gz | awk '{print $1}') |
| 45 | + echo "sha256=$SHA" >> "$GITHUB_OUTPUT" |
| 46 | +
|
| 47 | + - name: Setup SSH for AUR |
| 48 | + run: | |
| 49 | + mkdir -p ~/.ssh |
| 50 | + chmod 700 ~/.ssh |
| 51 | + printf '%s\n' "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/aur |
| 52 | + chmod 600 ~/.ssh/aur |
| 53 | + ssh-keyscan -t rsa,ecdsa,ed25519 aur.archlinux.org >> ~/.ssh/known_hosts 2>/dev/null |
| 54 | + cat > ~/.ssh/config <<EOF |
| 55 | + Host aur.archlinux.org |
| 56 | + User aur |
| 57 | + IdentityFile ~/.ssh/aur |
| 58 | + IdentitiesOnly yes |
| 59 | + StrictHostKeyChecking yes |
| 60 | + EOF |
| 61 | + chmod 600 ~/.ssh/config |
| 62 | +
|
| 63 | + - name: Clone AUR repo |
| 64 | + run: git -c init.defaultBranch=master clone ssh://aur@aur.archlinux.org/dstimer.git aur-repo |
| 65 | + |
| 66 | + - name: Render PKGBUILD & .SRCINFO |
| 67 | + env: |
| 68 | + PKGVER: ${{ steps.version.outputs.pkgver }} |
| 69 | + SHA256: ${{ steps.sha.outputs.sha256 }} |
| 70 | + run: | |
| 71 | + cat > aur-repo/PKGBUILD <<EOF |
| 72 | + # Maintainer: Linus Grolmes <linus@grolmes.de> |
| 73 | + pkgname=dstimer |
| 74 | + pkgver=${PKGVER} |
| 75 | + pkgrel=1 |
| 76 | + pkgdesc="The Timer for CLI people" |
| 77 | + arch=('x86_64' 'aarch64') |
| 78 | + url="https://github.com/madLinux7/dstimer" |
| 79 | + license=('MIT') |
| 80 | + makedepends=('rust' 'alsa-lib' 'pkgconf') |
| 81 | + depends=('alsa-lib') |
| 82 | + source=("\$pkgname-\$pkgver.tar.gz::https://github.com/madLinux7/dstimer/archive/v\$pkgver.tar.gz") |
| 83 | + sha256sums=('${SHA256}') |
| 84 | +
|
| 85 | + build() { |
| 86 | + cd "\$pkgname-\$pkgver" |
| 87 | + cargo build --release --locked |
| 88 | + } |
| 89 | +
|
| 90 | + package() { |
| 91 | + cd "\$pkgname-\$pkgver" |
| 92 | + install -Dm755 target/release/dstimer "\$pkgdir/usr/bin/dstimer" |
| 93 | + install -Dm644 LICENSE "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE" |
| 94 | + } |
| 95 | + EOF |
| 96 | +
|
| 97 | + cat > aur-repo/.SRCINFO <<EOF |
| 98 | + pkgbase = dstimer |
| 99 | + pkgdesc = The Timer for CLI people |
| 100 | + pkgver = ${PKGVER} |
| 101 | + pkgrel = 1 |
| 102 | + url = https://github.com/madLinux7/dstimer |
| 103 | + arch = x86_64 |
| 104 | + arch = aarch64 |
| 105 | + license = MIT |
| 106 | + makedepends = rust |
| 107 | + makedepends = alsa-lib |
| 108 | + makedepends = pkgconf |
| 109 | + depends = alsa-lib |
| 110 | + source = dstimer-${PKGVER}.tar.gz::https://github.com/madLinux7/dstimer/archive/v${PKGVER}.tar.gz |
| 111 | + sha256sums = ${SHA256} |
| 112 | +
|
| 113 | + pkgname = dstimer |
| 114 | + EOF |
| 115 | +
|
| 116 | + - name: Commit & push |
| 117 | + working-directory: aur-repo |
| 118 | + env: |
| 119 | + TAG: ${{ steps.version.outputs.tag }} |
| 120 | + run: | |
| 121 | + git config user.name "Linus Grolmes" |
| 122 | + git config user.email "linus@grolmes.de" |
| 123 | + git add PKGBUILD .SRCINFO |
| 124 | + if git diff --cached --quiet; then |
| 125 | + echo "No changes to publish" |
| 126 | + exit 0 |
| 127 | + fi |
| 128 | + git commit -m "[ci] Update to ${TAG}" |
| 129 | + git push |
0 commit comments