Skip to content

Commit

Permalink
ci(aur): refactor it
Browse files Browse the repository at this point in the history
  • Loading branch information
saying121 committed May 19, 2024
1 parent 0b981c9 commit 7144706
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 49 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/aur.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: AUR Publish

permissions:
contents: write

on:
release:
types:
- published

jobs:
aur-publish:
runs-on: ubuntu-latest
steps:
- name: Fetch Repository
uses: actions/checkout@v4

- name: Build PKGBUILD
run: |
url="https://github.com/saying121/lcode/releases/download/%s/lcode-%s-%s-unknown-linux-gnu.sha256"
# shellcheck disable=SC2059
wget -O x86_64.txt "$(printf $url "$GITHUB_REF_NAME" "$GITHUB_REF_NAME" x86_64)"
# shellcheck disable=SC2059
wget -O aarch64.txt "$(printf $url "$GITHUB_REF_NAME" "$GITHUB_REF_NAME" aarch64)"
sha_x86_64=$(cut -d' ' -f1 <(cat x86_64.txt))
sha_aarch64=$(cut -d' ' -f1 <(cat aarch64.txt))
sed -i "s/^sha256sums_x86_64=.*/sha256sums_x86_64=\(\'$sha_x86_64\'\)/g" ./aur/PKGBUILD
sed -i "s/^sha256sums_aarch64=.*/sha256sums_aarch64=\(\'$sha_aarch64\'\)/g" ./aur/PKGBUILD
sed -i "s/^pkgver=.*/pkgver=$GITHUB_REF_NAME/g" ./aur/PKGBUILD
- name: Publish AUR lcode
uses: KSXGitHub/github-actions-deploy-aur@v2
with:
pkgname: lcode-bin
pkgbuild: ./aur/PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Update lcode ${{ github.ref_name }}
ssh_keyscan_types: rsa,dsa,ecdsa,ed25519
37 changes: 0 additions & 37 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ permissions:
contents: write

on:
# release:
# types:
# - published
# - prereleased
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
Expand Down Expand Up @@ -178,36 +174,3 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
# ref: refs/tags/${{ needs.get-version.outputs.tag_version }}
checksum: sha256

aur-publish:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Fetch Repository
uses: actions/checkout@v4

- name: Build PKGBUILD
run: |
url="https://github.com/saying121/lcode/releases/download/%s/lcode-%s-%s-unknown-linux-gnu.sha256"
# shellcheck disable=SC2059
wget -O x86_64.txt "$(printf $url v0.9.1 v0.9.1 x86_64)"
# shellcheck disable=SC2059
wget -O aarch64.txt "$(printf $url v0.9.1 v0.9.1 aarch64)"
sha_x86_64=$(cut -d' ' -f1 <(cat x86_64.txt))
sha_aarch64=$(cut -d' ' -f1 <(cat aarch64.txt))
sed -i "s/^sha256sums_x86_64=.*/sha256sums_x86_64=\(\'$sha_x86_64\'\)/g" ./aur/PKGBUILD
sed -i "s/^sha256sums_aarch64=.*/sha256sums_aarch64=\(\'$sha_aarch64\'\)/g" ./aur/PKGBUILD
- name: Publish AUR package
uses: KSXGitHub/github-actions-deploy-aur@<TAG>
with:
pkgname: lcode-bin
pkgbuild: ./aur/PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Update AUR package
ssh_keyscan_types: rsa,dsa,ecdsa,ed25519
19 changes: 7 additions & 12 deletions aur/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
pkgname=lcode-bin
_binname=lcode
_repository=lcode
pkgver=v0.9.1
pkgver=
pkgrel=1
epoch=
pkgdesc="An application of terminal write leetcode."
arch=('x86_64' 'aarch64')
url="https://github.com/saying121/lcode"
Expand All @@ -20,22 +19,18 @@ groups=()
backup=()
options=()
install=
changelog=

source_x86_64=("https://github.com/saying121/${_repository}/releases/download/${pkgver}/${_binname}-${pkgver}-x86_64-unknown-linux-gnu.tar.gz")
sha256sums_x86_64=('ed6aab2b66d72ec65a15e1d6d1782d2eab47447d99d17d05cc11a1a5986a0aba')
sha256sums_x86_64=('')
source_aarch64=("https://github.com/saying121/${_repository}/releases/download/${pkgver}/${_binname}-${pkgver}-aarch64-unknown-linux-gnu.tar.gz")
sha256sums_aarch64=('9d56dcb687ef5beb89702365be419ea8fe45de6b9d7ea9c28506c81e940059fa')

noextract=()
validpgpkeys=()
sha256sums_aarch64=('')

# pkgver() {
# curl -s "https://api.github.com/repos/saying121/lcode/releases/latest" | jq '.tag_name'
# }

build() {
install -dm755 "completions"
install -dm755 "completions"
./lcode --generate=zsh >completions/_${_binname}
./lcode --generate=bash >completions/${_binname}.bash
./lcode --generate=fish >completions/${_binname}.fish
Expand All @@ -44,7 +39,7 @@ build() {
package() {
install -Dm755 "./${_binname}" "${pkgdir}/usr/bin/${_binname}"

install -Dm644 completions/_${_binname} "${pkgdir}/usr/share/zsh/site-functions/_${_binname}"
install -Dm644 completions/${_binname}.bash "${pkgdir}/usr/share/bash-completion/completions/${_binname}"
install -Dm644 completions/${_binname}.fish "${pkgdir}/usr/share/fish/vendor_completions.d/${_binname}.fish"
install -Dm644 completions/_${_binname} "${pkgdir}/usr/share/zsh/site-functions/_${_binname}"
install -Dm644 completions/${_binname}.bash "${pkgdir}/usr/share/bash-completion/completions/${_binname}"
install -Dm644 completions/${_binname}.fish "${pkgdir}/usr/share/fish/vendor_completions.d/${_binname}.fish"
}

0 comments on commit 7144706

Please sign in to comment.