|
| 1 | +name: "Publish To AUR" |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: |
| 6 | + - published |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: "Package version to publish (e.g. 2.0.2). Leave empty to use the latest release tag." |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + |
| 14 | +jobs: |
| 15 | + publish-to-aur: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + steps: |
| 20 | + - name: "Checkout" |
| 21 | + uses: actions/checkout@v4.1.7 |
| 22 | + |
| 23 | + # ── Resolve version ────────────────────────────────────────────────────── |
| 24 | + - name: "Resolve version" |
| 25 | + id: version |
| 26 | + run: | |
| 27 | + if [[ -n "${{ inputs.version }}" ]]; then |
| 28 | + VERSION="${{ inputs.version }}" |
| 29 | + else |
| 30 | + # Strip leading 'v' from the release tag (e.g. v2.0.2 → 2.0.2) |
| 31 | + VERSION="${GITHUB_REF_NAME#v}" |
| 32 | + fi |
| 33 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 34 | + echo "Resolved version: ${VERSION}" |
| 35 | +
|
| 36 | + # ── Download release assets and compute SHA256 checksums ───────────────── |
| 37 | + - name: "Download Linux x86_64 tar.gz and compute SHA256" |
| 38 | + id: sha256_x86_64 |
| 39 | + run: | |
| 40 | + VERSION="${{ steps.version.outputs.version }}" |
| 41 | + URL="https://github.com/docmirror/dev-sidecar/releases/download/v${VERSION}/DevSidecar-${VERSION}-linux-x86_64.tar.gz" |
| 42 | + echo "Downloading: ${URL}" |
| 43 | + curl -fsSL -o /tmp/dev-sidecar-x86_64.tar.gz "${URL}" |
| 44 | + SHA256=$(sha256sum /tmp/dev-sidecar-x86_64.tar.gz | awk '{print $1}') |
| 45 | + echo "sha256=${SHA256}" >> "$GITHUB_OUTPUT" |
| 46 | + echo "x86_64 SHA256: ${SHA256}" |
| 47 | +
|
| 48 | + - name: "Download Linux aarch64 tar.gz and compute SHA256" |
| 49 | + id: sha256_aarch64 |
| 50 | + run: | |
| 51 | + VERSION="${{ steps.version.outputs.version }}" |
| 52 | + URL="https://github.com/docmirror/dev-sidecar/releases/download/v${VERSION}/DevSidecar-${VERSION}-linux-arm64.tar.gz" |
| 53 | + echo "Downloading: ${URL}" |
| 54 | + curl -fsSL -o /tmp/dev-sidecar-aarch64.tar.gz "${URL}" |
| 55 | + SHA256=$(sha256sum /tmp/dev-sidecar-aarch64.tar.gz | awk '{print $1}') |
| 56 | + echo "sha256=${SHA256}" >> "$GITHUB_OUTPUT" |
| 57 | + echo "aarch64 SHA256: ${SHA256}" |
| 58 | +
|
| 59 | + # ── Update PKGBUILD ─────────────────────────────────────────────────────── |
| 60 | + - name: "Update PKGBUILD with new version and checksums" |
| 61 | + run: | |
| 62 | + VERSION="${{ steps.version.outputs.version }}" |
| 63 | + SHA256_X86_64="${{ steps.sha256_x86_64.outputs.sha256 }}" |
| 64 | + SHA256_AARCH64="${{ steps.sha256_aarch64.outputs.sha256 }}" |
| 65 | +
|
| 66 | + PKGBUILD="packages/aur/PKGBUILD" |
| 67 | +
|
| 68 | + # Update pkgver |
| 69 | + sed -i "s/^pkgver=.*/pkgver=${VERSION}/" "${PKGBUILD}" |
| 70 | +
|
| 71 | + # Reset pkgrel to 1 on every new upstream version |
| 72 | + sed -i "s/^pkgrel=.*/pkgrel=1/" "${PKGBUILD}" |
| 73 | +
|
| 74 | + # Update checksums |
| 75 | + sed -i "s/^sha256sums_x86_64=.*/sha256sums_x86_64=('${SHA256_X86_64}')/" "${PKGBUILD}" |
| 76 | + sed -i "s/^sha256sums_aarch64=.*/sha256sums_aarch64=('${SHA256_AARCH64}')/" "${PKGBUILD}" |
| 77 | +
|
| 78 | + echo "======== Updated PKGBUILD ========" |
| 79 | + cat "${PKGBUILD}" |
| 80 | +
|
| 81 | + # ── Push to AUR via git + SSH ───────────────────────────────────────────── |
| 82 | + - name: "Set up SSH key for AUR" |
| 83 | + run: | |
| 84 | + install -dm700 ~/.ssh |
| 85 | +
|
| 86 | + # Write the private key |
| 87 | + echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/aur_id |
| 88 | + chmod 600 ~/.ssh/aur_id |
| 89 | +
|
| 90 | + # Trust AUR's host key |
| 91 | + ssh-keyscan -t rsa,ecdsa,ed25519 aur.archlinux.org >> ~/.ssh/known_hosts 2>/dev/null |
| 92 | + chmod 644 ~/.ssh/known_hosts |
| 93 | +
|
| 94 | + # SSH config: use this key for AUR (printf avoids heredoc indentation issues) |
| 95 | + printf 'Host aur.archlinux.org\n IdentityFile ~/.ssh/aur_id\n User aur\n' >> ~/.ssh/config |
| 96 | + chmod 600 ~/.ssh/config |
| 97 | +
|
| 98 | + - name: "Clone AUR repository" |
| 99 | + run: | |
| 100 | + git clone ssh://aur@aur.archlinux.org/dev-sidecar-bin.git /tmp/aur-dev-sidecar-bin |
| 101 | +
|
| 102 | + - name: "Copy PKGBUILD and generate .SRCINFO" |
| 103 | + run: | |
| 104 | + cp packages/aur/PKGBUILD /tmp/aur-dev-sidecar-bin/PKGBUILD |
| 105 | +
|
| 106 | + # Generate .SRCINFO via helper script (makepkg is not available on the ubuntu |
| 107 | + # runner since pacman is not installed) |
| 108 | + cd /tmp/aur-dev-sidecar-bin |
| 109 | + python3 "$GITHUB_WORKSPACE/packages/aur/gen_srcinfo.py" |
| 110 | +
|
| 111 | + - name: "Commit and push to AUR" |
| 112 | + run: | |
| 113 | + cd /tmp/aur-dev-sidecar-bin |
| 114 | +
|
| 115 | + git config user.name "${{ vars.AUR_USERNAME }}" |
| 116 | + git config user.email "${{ vars.AUR_EMAIL }}" |
| 117 | +
|
| 118 | + git add PKGBUILD .SRCINFO |
| 119 | +
|
| 120 | + # Only commit if there are actual changes |
| 121 | + if git diff --cached --quiet; then |
| 122 | + echo "No changes to commit – AUR is already up to date." |
| 123 | + else |
| 124 | + git commit -m "Update to v${{ steps.version.outputs.version }}" |
| 125 | + git push |
| 126 | + echo "Successfully pushed to AUR." |
| 127 | + fi |
0 commit comments