From efe64f6eda2fefad2cbe8c059e0335eb0318c462 Mon Sep 17 00:00:00 2001 From: Terrasse Date: Thu, 29 Aug 2024 20:08:43 +0800 Subject: [PATCH 1/8] add AUR publish workflows --- .github/workflows/pkg-aur-bin.yml | 42 +++++++++++++++++++++++++++++++ .github/workflows/pkg-aur-git.yml | 26 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 .github/workflows/pkg-aur-bin.yml create mode 100644 .github/workflows/pkg-aur-git.yml diff --git a/.github/workflows/pkg-aur-bin.yml b/.github/workflows/pkg-aur-bin.yml new file mode 100644 index 00000000..3098df7d --- /dev/null +++ b/.github/workflows/pkg-aur-bin.yml @@ -0,0 +1,42 @@ +# This workflow will publish the `chsrc` package to the AUR +# when there is a new `released` event. +name: Publish AUR Package (chsrc) +on: + release: + types: [ released ] + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - name: Get the release tag + id: get_tag + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + - name: Validate version tag + run: | + if [[ ! ${{ steps.get_tag.outputs.tag }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Abnormal version tag: ${{ steps.get_tag.outputs.tag }}" + echo "valid=false" >> $GITHUB_ENV + else + echo "version=${{ steps.get_tag.outputs.tag:1 }}" >> $GITHUB_ENV + echo "valid=true" >> $GITHUB_ENV + fi + - name: Fetch PKGBUILD + run: | + wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD\?h\=chsrc -O ./PKGBUILD + - name: Update PKGBUILD + run: | + sed -i "s/pkgver=.*/pkgver=${{ env.version }}/" PKGBUILD + - name: Publish to AUR + uses: KSXGitHub/github-actions-deploy-aur@v3.0.1 + with: + pkgname: chsrc + pkgbuild: ./PKGBUILD + updpkgsums: true + test: true # Check that PKGBUILD could be built, and update pkgver + commit_username: ${{ secrets.AUR_USERNAME }} + commit_email: ${{ secrets.AUR_EMAIL }} + # ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + ssh_private_key: placeholder + commit_message: github-action-auto-publish diff --git a/.github/workflows/pkg-aur-git.yml b/.github/workflows/pkg-aur-git.yml new file mode 100644 index 00000000..6366b44c --- /dev/null +++ b/.github/workflows/pkg-aur-git.yml @@ -0,0 +1,26 @@ +# This workflow will publish the `chsrc-git` package to the AUR +# when the main branch is updated. +name: Publish AUR Package (chsrc-git) +on: + workflow_dispatch: + push: + branches: [ "main" ] # chsrc-git syncs with main + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - name: Fetch PKGBUILD + run: | + wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD\?h\=chsrc-git -O ./PKGBUILD + - name: Publish to AUR + uses: KSXGitHub/github-actions-deploy-aur@v3.0.1 + with: + pkgname: chsrc-git + pkgbuild: ./PKGBUILD + test: true # Check that PKGBUILD could be built, and update pkgver + commit_username: ${{ secrets.AUR_USERNAME }} + commit_email: ${{ secrets.AUR_EMAIL }} + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + commit_message: github-action-auto-publish From 9d27c29d96872a02060db48ae12d898f09d743f2 Mon Sep 17 00:00:00 2001 From: Terrasse Date: Thu, 29 Aug 2024 20:20:58 +0800 Subject: [PATCH 2/8] fix bug of version tag --- .github/workflows/pkg-aur-bin.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pkg-aur-bin.yml b/.github/workflows/pkg-aur-bin.yml index 3098df7d..51c02d63 100644 --- a/.github/workflows/pkg-aur-bin.yml +++ b/.github/workflows/pkg-aur-bin.yml @@ -17,10 +17,11 @@ jobs: run: | if [[ ! ${{ steps.get_tag.outputs.tag }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "Abnormal version tag: ${{ steps.get_tag.outputs.tag }}" - echo "valid=false" >> $GITHUB_ENV + echo "Exiting..." + exit 0 else - echo "version=${{ steps.get_tag.outputs.tag:1 }}" >> $GITHUB_ENV - echo "valid=true" >> $GITHUB_ENV + tag=$(echo ${{ steps.get_tag.outputs.tag }} | sed 's/^v//') + echo "version=$tag" >> $GITHUB_ENV fi - name: Fetch PKGBUILD run: | From 5c2299fb1e6c87b66af442b35d0d38ae63ecb987 Mon Sep 17 00:00:00 2001 From: Terrasse Date: Thu, 29 Aug 2024 20:26:25 +0800 Subject: [PATCH 3/8] use real publish key --- .github/workflows/pkg-aur-bin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pkg-aur-bin.yml b/.github/workflows/pkg-aur-bin.yml index 51c02d63..26fcaa9a 100644 --- a/.github/workflows/pkg-aur-bin.yml +++ b/.github/workflows/pkg-aur-bin.yml @@ -1,5 +1,6 @@ # This workflow will publish the `chsrc` package to the AUR # when there is a new `released` event. +# Note: only normal version tags like `v1.2.3` will be published. name: Publish AUR Package (chsrc) on: release: @@ -38,6 +39,5 @@ jobs: test: true # Check that PKGBUILD could be built, and update pkgver commit_username: ${{ secrets.AUR_USERNAME }} commit_email: ${{ secrets.AUR_EMAIL }} - # ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} - ssh_private_key: placeholder + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} commit_message: github-action-auto-publish From 9eeeca23d7e6170f7a870f645f4175c23a8ffee4 Mon Sep 17 00:00:00 2001 From: Terrasse Date: Thu, 29 Aug 2024 20:35:44 +0800 Subject: [PATCH 4/8] use new env variable style --- .github/workflows/pkg-aur-bin.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pkg-aur-bin.yml b/.github/workflows/pkg-aur-bin.yml index 26fcaa9a..6f0637be 100644 --- a/.github/workflows/pkg-aur-bin.yml +++ b/.github/workflows/pkg-aur-bin.yml @@ -13,24 +13,27 @@ jobs: steps: - name: Get the release tag id: get_tag - run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + # run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + run: | + echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Validate version tag run: | - if [[ ! ${{ steps.get_tag.outputs.tag }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Abnormal version tag: ${{ steps.get_tag.outputs.tag }}" - echo "Exiting..." - exit 0 + if [[ ! $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Abnormal version tag: $tag"" + echo "valid=0" >> $GITHUB_ENV else - tag=$(echo ${{ steps.get_tag.outputs.tag }} | sed 's/^v//') - echo "version=$tag" >> $GITHUB_ENV + version=$(echo $tag | sed 's/^v//') + echo "version=$version" >> $GITHUB_ENV + echo "valid=1" >> $GITHUB_ENV fi - name: Fetch PKGBUILD run: | wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD\?h\=chsrc -O ./PKGBUILD - name: Update PKGBUILD run: | - sed -i "s/pkgver=.*/pkgver=${{ env.version }}/" PKGBUILD + sed -i "s/pkgver=.*/pkgver=$version/" PKGBUILD - name: Publish to AUR + if: env.valid == '1' uses: KSXGitHub/github-actions-deploy-aur@v3.0.1 with: pkgname: chsrc @@ -39,5 +42,6 @@ jobs: test: true # Check that PKGBUILD could be built, and update pkgver commit_username: ${{ secrets.AUR_USERNAME }} commit_email: ${{ secrets.AUR_EMAIL }} - ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + # ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + ssh_private_key: placeholder commit_message: github-action-auto-publish From 8cd4fa0d1a7508d3dc107057aa89b613d229939f Mon Sep 17 00:00:00 2001 From: Terrasse Date: Thu, 29 Aug 2024 20:38:57 +0800 Subject: [PATCH 5/8] fix checking valid --- .github/workflows/pkg-aur-bin.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pkg-aur-bin.yml b/.github/workflows/pkg-aur-bin.yml index 6f0637be..afa7adcc 100644 --- a/.github/workflows/pkg-aur-bin.yml +++ b/.github/workflows/pkg-aur-bin.yml @@ -27,9 +27,11 @@ jobs: echo "valid=1" >> $GITHUB_ENV fi - name: Fetch PKGBUILD + if: env.valid == '1' run: | wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD\?h\=chsrc -O ./PKGBUILD - name: Update PKGBUILD + if: env.valid == '1' run: | sed -i "s/pkgver=.*/pkgver=$version/" PKGBUILD - name: Publish to AUR From 5659a0b3c885151ad3043b00eff4cfbabf5f7060 Mon Sep 17 00:00:00 2001 From: Terrasse Date: Thu, 29 Aug 2024 20:41:09 +0800 Subject: [PATCH 6/8] fix syntax error --- .github/workflows/pkg-aur-bin.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pkg-aur-bin.yml b/.github/workflows/pkg-aur-bin.yml index afa7adcc..50de2c7a 100644 --- a/.github/workflows/pkg-aur-bin.yml +++ b/.github/workflows/pkg-aur-bin.yml @@ -19,7 +19,7 @@ jobs: - name: Validate version tag run: | if [[ ! $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Abnormal version tag: $tag"" + echo "Abnormal version tag: $tag" echo "valid=0" >> $GITHUB_ENV else version=$(echo $tag | sed 's/^v//') @@ -27,11 +27,9 @@ jobs: echo "valid=1" >> $GITHUB_ENV fi - name: Fetch PKGBUILD - if: env.valid == '1' run: | wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD\?h\=chsrc -O ./PKGBUILD - name: Update PKGBUILD - if: env.valid == '1' run: | sed -i "s/pkgver=.*/pkgver=$version/" PKGBUILD - name: Publish to AUR From 4074338410edcac7873ebe7f6bbff0c243473287 Mon Sep 17 00:00:00 2001 From: Terrasse Date: Thu, 29 Aug 2024 20:43:46 +0800 Subject: [PATCH 7/8] use real publish key --- .github/workflows/pkg-aur-bin.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pkg-aur-bin.yml b/.github/workflows/pkg-aur-bin.yml index 50de2c7a..054bb988 100644 --- a/.github/workflows/pkg-aur-bin.yml +++ b/.github/workflows/pkg-aur-bin.yml @@ -42,6 +42,5 @@ jobs: test: true # Check that PKGBUILD could be built, and update pkgver commit_username: ${{ secrets.AUR_USERNAME }} commit_email: ${{ secrets.AUR_EMAIL }} - # ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} - ssh_private_key: placeholder + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} commit_message: github-action-auto-publish From 79a0b619f00e843a349db56a965ce1d3ad17b920 Mon Sep 17 00:00:00 2001 From: Terrasse Date: Thu, 29 Aug 2024 20:53:35 +0800 Subject: [PATCH 8/8] remove trash --- .github/workflows/pkg-aur-bin.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pkg-aur-bin.yml b/.github/workflows/pkg-aur-bin.yml index 054bb988..b76b3430 100644 --- a/.github/workflows/pkg-aur-bin.yml +++ b/.github/workflows/pkg-aur-bin.yml @@ -13,7 +13,6 @@ jobs: steps: - name: Get the release tag id: get_tag - # run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} run: | echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Validate version tag