|
| 1 | +name: Push to AUR-GIT |
| 2 | +on: |
| 3 | + # workflow_dispatch: |
| 4 | + workflow_run: |
| 5 | + workflows: ["Release"] |
| 6 | + types: [completed] |
| 7 | + |
| 8 | +jobs: |
| 9 | + push_to_aur: |
| 10 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 11 | + runs-on: ubuntu-latest |
| 12 | + environment: astraeditor-bin |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Generate PKGBUILD and .SRCINFO |
| 19 | + run: | |
| 20 | + TAG="${{ github.event.workflow_run.head_branch }}" |
| 21 | + VERSION="${TAG#v}" |
| 22 | + echo "Processing version: $VERSION" |
| 23 | + cat > PKGBUILD << 'EOF' |
| 24 | +# Maintainer: LuoTianyi_arm64 <2153585992@qq.com> |
| 25 | +pkgname=astraeditor-git |
| 26 | +_binname=astraeditor-desktop |
| 27 | +pkgver=REPLACE_ME_VERSION |
| 28 | +pkgrel=1 |
| 29 | +pkgdesc='AstraEditor is a TurboWarp mod used to add more practical features to make your writing lightning fast.' |
| 30 | +arch=('x86_64' 'aarch64' 'armv7h') |
| 31 | +url='https://github.com/AstraEditor/Desktop' |
| 32 | +license=('GPL3') |
| 33 | +makedepends=('nodejs' 'npm' 'git' 'python') |
| 34 | +depends=('alsa-lib' 'gtk3' 'nss' 'libxss' 'libxtst' 'xdg-utils' 'hicolor-icon-theme' 'at-spi2-core' 'libdrm' 'mesa' 'libxcb' 'libnotify') |
| 35 | +provides=('astraeditor') |
| 36 | +conflicts=('astraeditor') |
| 37 | +options=(!strip !debug) |
| 38 | +source=("${pkgname}::git+${url}.git") |
| 39 | +sha256sums=('SKIP') |
| 40 | + |
| 41 | +build() { |
| 42 | + cd "$pkgname" |
| 43 | + rm -f package-lock.json |
| 44 | + npm install --loglevel=info |
| 45 | + npm run fetch |
| 46 | + npm run webpack:prod |
| 47 | + |
| 48 | + local _target_arch="x64" |
| 49 | + [[ "$CARCH" == "aarch64" ]] && _target_arch="arm64" |
| 50 | + [[ "$CARCH" == "armv7h" ]] && _target_arch="armv7l" |
| 51 | + |
| 52 | + npx electron-builder --linux --dir --$_target_arch -c.projectDir=. |
| 53 | +} |
| 54 | + |
| 55 | +package() { |
| 56 | + cd "$pkgname" |
| 57 | + local _unpacked_dir="dist/linux-unpacked" |
| 58 | + [[ "$CARCH" == "aarch64" ]] && _unpacked_dir="dist/linux-arm64-unpacked" |
| 59 | + [[ "$CARCH" == "armv7h" ]] && _unpacked_dir="dist/linux-armv7l-unpacked" |
| 60 | + |
| 61 | + install -d "$pkgdir/opt/astraeditor" |
| 62 | + cp -r "$_unpacked_dir"/* "$pkgdir/opt/astraeditor/" |
| 63 | + |
| 64 | + install -d "$pkgdir/usr/bin" |
| 65 | + ln -s "/opt/astraeditor/$_binname" "$pkgdir/usr/bin/$_binname" |
| 66 | + |
| 67 | + install -d "$pkgdir/usr/share/applications" |
| 68 | + cat > "$pkgdir/usr/share/applications/$_binname.desktop" <<EOT |
| 69 | +[Desktop Entry] |
| 70 | +Name=AstraEditor |
| 71 | +GenericName=Scratch Mod |
| 72 | +Comment=Mod of Scratch with a compiler and more features. |
| 73 | +Exec=$_binname %U |
| 74 | +Terminal=false |
| 75 | +Type=Application |
| 76 | +Icon=astraeditor |
| 77 | +StartupWMClass=$_binname |
| 78 | +Categories=Development;Education; |
| 79 | +Keywords=scratch; |
| 80 | +EOT |
| 81 | + |
| 82 | + local _res |
| 83 | + for _res in 48 64 128 256 512; do |
| 84 | + local _icon_path="build/icons/${_res}x${_res}.png" |
| 85 | + if [ -f "$_icon_path" ]; then |
| 86 | + install -Dm644 "$_icon_path" "$pkgdir/usr/share/icons/hicolor/${_res}x${_res}/apps/astraeditor.png" |
| 87 | + fi |
| 88 | + done |
| 89 | +} |
| 90 | +EOF |
| 91 | + sed -i "s/REPLACE_ME_VERSION/${VERSION}/" PKGBUILD |
| 92 | + |
| 93 | + cat > .SRCINFO << EOF |
| 94 | +pkgbase = astraeditor-git |
| 95 | + pkgdesc = AstraEditor is a TurboWarp mod used to add more practical features to make your writing lightning fast. |
| 96 | + pkgver = ${VERSION} |
| 97 | + pkgrel = 1 |
| 98 | + url = https://github.com/AstraEditor/Desktop |
| 99 | + arch = x86_64 |
| 100 | + arch = aarch64 |
| 101 | + arch = armv7h |
| 102 | + license = GPL3 |
| 103 | + makedepends = nodejs |
| 104 | + makedepends = npm |
| 105 | + makedepends = git |
| 106 | + makedepends = python |
| 107 | + depends = alsa-lib |
| 108 | + depends = gtk3 |
| 109 | + depends = nss |
| 110 | + depends = libxss |
| 111 | + depends = libxtst |
| 112 | + depends = xdg-utils |
| 113 | + depends = hicolor-icon-theme |
| 114 | + depends = at-spi2-core |
| 115 | + depends = libdrm |
| 116 | + depends = mesa |
| 117 | + depends = libxcb |
| 118 | + depends = libnotify |
| 119 | + provides = astraeditor |
| 120 | + conflicts = astraeditor |
| 121 | + options = !strip |
| 122 | + options = !debug |
| 123 | + source = astraeditor-git::git+https://github.com/AstraEditor/Desktop.git |
| 124 | + sha256sums = SKIP |
| 125 | + |
| 126 | +pkgname = astraeditor-git |
| 127 | +EOF |
| 128 | + |
| 129 | + - name: Push to AUR |
| 130 | + uses: KSXGitHub/github-actions-deploy-aur@v4.1.1 |
| 131 | + with: |
| 132 | + pkgname: astraeditor-git |
| 133 | + pkgbuild: ./PKGBUILD |
| 134 | + assets: | |
| 135 | + .SRCINFO |
| 136 | + commit_username: ${{ secrets.AUR_USERNAME }} |
| 137 | + commit_email: ${{ secrets.AUR_EMAIL }} |
| 138 | + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} |
| 139 | + commit_message: "Update AUR package to ${VERSION}" |
| 140 | + ssh_keyscan_types: ed25519 |
0 commit comments