|
| 1 | +name: Publish to AUR |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [released] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version: |
| 9 | + description: "Version to publish (e.g. 2.9.2 — no v prefix)" |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + dry_run: |
| 13 | + description: "Skip the AUR push (safe test)" |
| 14 | + type: boolean |
| 15 | + default: true |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +jobs: |
| 21 | + get-release-info: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + outputs: |
| 24 | + version: ${{ steps.info.outputs.version }} |
| 25 | + deb_sha256: ${{ steps.hashes.outputs.deb_sha256 }} |
| 26 | + jar_sha256: ${{ steps.hashes.outputs.jar_sha256 }} |
| 27 | + steps: |
| 28 | + - name: Harden Runner |
| 29 | + uses: step-security/harden-runner@6c3c2f2c1c457b00c10c4848d6f5491db3b629df # v2.18.0 |
| 30 | + with: |
| 31 | + egress-policy: audit |
| 32 | + |
| 33 | + - name: Extract version from tag or manual input |
| 34 | + id: info |
| 35 | + env: |
| 36 | + DISPATCH_VERSION: ${{ inputs.version }} |
| 37 | + RELEASE_TAG: ${{ github.event.release.tag_name }} |
| 38 | + run: | |
| 39 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 40 | + VERSION="$DISPATCH_VERSION" |
| 41 | + else |
| 42 | + VERSION="$RELEASE_TAG" |
| 43 | + fi |
| 44 | + VERSION="${VERSION#v}" |
| 45 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 46 | +
|
| 47 | + - name: Download release assets and compute SHA256 |
| 48 | + id: hashes |
| 49 | + env: |
| 50 | + VERSION: ${{ steps.info.outputs.version }} |
| 51 | + run: | |
| 52 | + BASE="https://github.com/Stirling-Tools/Stirling-PDF/releases/download/v${VERSION}" |
| 53 | +
|
| 54 | + download_sha256() { |
| 55 | + local url="$1" |
| 56 | + local file |
| 57 | + file=$(basename "$url") |
| 58 | + curl -fsSL --retry 3 -o "$file" "$url" |
| 59 | + sha256sum "$file" | awk '{print $1}' |
| 60 | + } |
| 61 | +
|
| 62 | + DEB_SHA=$(download_sha256 "${BASE}/Stirling-PDF-linux-x86_64.deb") |
| 63 | + JAR_SHA=$(download_sha256 "${BASE}/Stirling-PDF-with-login.jar") |
| 64 | +
|
| 65 | + echo "deb_sha256=$DEB_SHA" >> "$GITHUB_OUTPUT" |
| 66 | + echo "jar_sha256=$JAR_SHA" >> "$GITHUB_OUTPUT" |
| 67 | +
|
| 68 | + publish-aur: |
| 69 | + needs: get-release-info |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - name: Harden Runner |
| 73 | + uses: step-security/harden-runner@v2 |
| 74 | + with: |
| 75 | + egress-policy: audit |
| 76 | + |
| 77 | + - name: Checkout repository (for PKGBUILD templates) |
| 78 | + uses: actions/checkout@v4 |
| 79 | + |
| 80 | + - name: Update stirling-pdf-bin PKGBUILD |
| 81 | + env: |
| 82 | + VERSION: ${{ needs.get-release-info.outputs.version }} |
| 83 | + DEB_SHA: ${{ needs.get-release-info.outputs.deb_sha256 }} |
| 84 | + run: | |
| 85 | + PKGBUILD=".github/aur/stirling-pdf-bin/PKGBUILD" |
| 86 | + sed -i "s/^pkgver=.*/pkgver=${VERSION}/" "$PKGBUILD" |
| 87 | + sed -i "s/^pkgrel=.*/pkgrel=1/" "$PKGBUILD" |
| 88 | + sed -i "s/'PLACEHOLDER_DEB_SHA256'/'${DEB_SHA}'/" "$PKGBUILD" |
| 89 | +
|
| 90 | + - name: Update stirling-pdf-server-bin PKGBUILD |
| 91 | + env: |
| 92 | + VERSION: ${{ needs.get-release-info.outputs.version }} |
| 93 | + JAR_SHA: ${{ needs.get-release-info.outputs.jar_sha256 }} |
| 94 | + run: | |
| 95 | + PKGBUILD=".github/aur/stirling-pdf-server-bin/PKGBUILD" |
| 96 | + sed -i "s/^pkgver=.*/pkgver=${VERSION}/" "$PKGBUILD" |
| 97 | + sed -i "s/^pkgrel=.*/pkgrel=1/" "$PKGBUILD" |
| 98 | + sed -i "s/'PLACEHOLDER_JAR_SHA256'/'${JAR_SHA}'/" "$PKGBUILD" |
| 99 | +
|
| 100 | + - name: Show updated PKGBUILDs (for dry-run visibility) |
| 101 | + run: | |
| 102 | + echo "--- stirling-pdf-bin PKGBUILD ---" |
| 103 | + cat .github/aur/stirling-pdf-bin/PKGBUILD |
| 104 | + echo "" |
| 105 | + echo "--- stirling-pdf-server-bin PKGBUILD ---" |
| 106 | + cat .github/aur/stirling-pdf-server-bin/PKGBUILD |
| 107 | +
|
| 108 | + - name: Publish stirling-pdf-bin to AUR |
| 109 | + if: ${{ github.event_name == 'release' || inputs.dry_run == false }} |
| 110 | + uses: KSXGitHub/github-actions-deploy-aur@2ac5a4c1d7035885d46b10e3193393be8460b6f1 # v4.1.1 |
| 111 | + with: |
| 112 | + pkgname: stirling-pdf-bin |
| 113 | + pkgbuild: .github/aur/stirling-pdf-bin/PKGBUILD |
| 114 | + commit_username: Stirling PDF Inc |
| 115 | + commit_email: contact@stirlingpdf.com |
| 116 | + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} |
| 117 | + commit_message: "Update to v${{ needs.get-release-info.outputs.version }}" |
| 118 | + |
| 119 | + - name: Publish stirling-pdf-server-bin to AUR |
| 120 | + if: ${{ github.event_name == 'release' || inputs.dry_run == false }} |
| 121 | + uses: KSXGitHub/github-actions-deploy-aur@v4.1.1 |
| 122 | + with: |
| 123 | + pkgname: stirling-pdf-server-bin |
| 124 | + pkgbuild: .github/aur/stirling-pdf-server-bin/PKGBUILD |
| 125 | + commit_username: Stirling PDF Inc |
| 126 | + commit_email: contact@stirlingpdf.com |
| 127 | + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} |
| 128 | + commit_message: "Update to v${{ needs.get-release-info.outputs.version }}" |
0 commit comments