Improve details #69
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Upload to AUR | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version (e.g. v3.7.0)' | |
| required: true | |
| type: string | |
| # https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ | |
| jobs: | |
| build: | |
| if: ${{ github.repository_owner == 'siyuan-note' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check tag aka check release type | |
| id: checktag | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| else | |
| VERSION="${{ github.ref }}" | |
| fi | |
| if [[ "$VERSION" == *"dev"* ]]; then | |
| echo "Skip the workflow as the tag contains 'dev'" | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Continue the workflow" | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| shell: bash | |
| - name: Extract tag name | |
| id: get_version | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "TAG_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "TAG_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Extra tag name without v | |
| id: get_version_without_v | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "TAG_VERSION_WITHOUT_V=$(echo '${{ github.event.inputs.version }}' | sed 's/^v//')" >> $GITHUB_OUTPUT | |
| else | |
| echo "TAG_VERSION_WITHOUT_V=$(echo '${{ github.event.release.tag_name }}' | sed 's/^v//')" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create PKGBUILD | |
| run: | | |
| cat << EOF >> PKGBUILD | |
| # maintainer: SiYuan community (https://github.com/siyuan-note/siyuan/issues/new/choose) | |
| # auto running on siyuan official repo | |
| # PKGBUILD is modified from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=siyuan-appimage | |
| # which is made by vvxxp8 <concatenate[g] the characters[x] in square[b] brackets[1] in[5] order[3] at gmail dot com> | |
| # had agreement with the author to use the PKGBUILD | |
| # for change request, PLEASE MAKE A PR ON GITHUB REPO, keep commenting here would be ignored | |
| pkgname=siyuan-bin | |
| pkgver=${{ steps.get_version_without_v.outputs.TAG_VERSION_WITHOUT_V }} | |
| pkgrel=1 | |
| pkgdesc="auto upload to AUR when SiYuan stable release" | |
| arch=("x86_64") | |
| url="https://b3log.org/siyuan" | |
| license=("AGPL-3.0-only") | |
| options=("!strip" "!debug") | |
| depends=("fuse2") | |
| optdepends=('pandoc: docx export') | |
| source=("https://github.com/siyuan-note/siyuan/releases/download/v\${pkgver}/siyuan-\${pkgver}-linux.AppImage") | |
| sha256sums=('SKIP') | |
| _pkgname=siyuan-\${pkgver}-linux.AppImage | |
| noextract=("\${_pkgname}") | |
| prepare() { | |
| chmod +x "\${_pkgname}" | |
| ./"\${_pkgname}" --appimage-extract > /dev/null | |
| } | |
| build() { | |
| _desktop_file=\$(find squashfs-root -maxdepth 1 -name "*.desktop" -print -quit) | |
| # Adjust .desktop so it will work outside of AppImage container | |
| sed -i \\ | |
| -e "s|Exec=AppRun|Exec=/opt/\${pkgname}/\${pkgname}.AppImage|" \\ | |
| -e "s+^Icon=.*+Icon=siyuan-bin+" \\ | |
| "\${_desktop_file}" | |
| # Fix permissions; .AppImage permissions are 700 for all directories | |
| chmod -R a-x+rX squashfs-root/usr | |
| } | |
| package() { | |
| _desktop_file=\$(find squashfs-root -maxdepth 1 -name "*.desktop" -print -quit) | |
| # AppImage | |
| install -Dm755 "\${srcdir}/\${_pkgname}" "\${pkgdir}/opt/\${pkgname}/\${pkgname}.AppImage" | |
| install -Dm644 "\${srcdir}/squashfs-root/LICENSE" "\${pkgdir}/opt/\${pkgname}/LICENSE" | |
| # Desktop file | |
| install -Dm644 "\${srcdir}/\${_desktop_file}" \\ | |
| "\${pkgdir}/usr/share/applications/siyuan.desktop" | |
| # Icon images | |
| install -Dm644 "squashfs-root/resources/stage/icon.png" \\ | |
| "\${pkgdir}/usr/share/icons/hicolor/512x512/apps/siyuan-bin.png" | |
| # Symlink executable | |
| install -dm755 "\${pkgdir}/usr/bin" | |
| ln -s "/opt/\${pkgname}/\${pkgname}.AppImage" "\${pkgdir}/usr/bin/siyuan" | |
| # Symlink license | |
| install -dm755 "\${pkgdir}/usr/share/licenses/\${pkgname}/" | |
| ln -s "/opt/\${pkgname}/LICENSE" "\${pkgdir}/usr/share/licenses/\${pkgname}" | |
| } | |
| EOF | |
| - name: Publish AUR package | |
| uses: KSXGitHub/github-actions-deploy-aur@v4.1.2 | |
| with: | |
| pkgname: siyuan-bin | |
| pkgbuild: ./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,ecdsa,ed25519 |