chsrc/.github/workflows/pkg-aur-rel.yml

63 lines
2.2 KiB
YAML
Raw Normal View History

2024-09-08 16:13:27 +08:00
# This workflow will publish the `chsrc` and the `chsrc-bin` packages to the AUR
2024-08-29 20:08:43 +08:00
# when there is a new `released` event.
2024-08-29 20:26:25 +08:00
# Note: only normal version tags like `v1.2.3` will be published.
2024-09-08 16:13:27 +08:00
name: Publish AUR Package (chsrc, chsrc-bin)
2024-08-29 20:08:43 +08:00
on:
release:
types: [ released ]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Get the release tag
id: get_tag
2024-08-29 20:35:44 +08:00
run: |
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
2024-08-29 20:08:43 +08:00
- name: Validate version tag
run: |
2024-08-29 20:35:44 +08:00
if [[ ! $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
2024-08-29 20:41:09 +08:00
echo "Abnormal version tag: $tag"
2024-08-29 20:35:44 +08:00
echo "valid=0" >> $GITHUB_ENV
2024-08-29 20:08:43 +08:00
else
2024-08-29 20:35:44 +08:00
version=$(echo $tag | sed 's/^v//')
echo "version=$version" >> $GITHUB_ENV
echo "valid=1" >> $GITHUB_ENV
2024-08-29 20:08:43 +08:00
fi
2024-09-08 16:13:27 +08:00
- name: Fetch PKGBUILD
run: |
wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD\?h\=chsrc-bin -O ./PKGBUILD_bin
- name: Update PKGBUILD
run: |
sed -i "s/pkgver=.*/pkgver=$version/" PKGBUILD_bin
- name: Publish chsrc-bin to AUR
if: env.valid == '1'
uses: KSXGitHub/github-actions-deploy-aur@v3.0.1
with:
pkgname: chsrc-bin
pkgbuild: ./PKGBUILD_bin
updpkgsums: true
test: true # Check that PKGBUILD could be built, and update pkgver
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
2024-09-08 16:33:58 +08:00
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "github-action-auto-publish v${{ env.version }}"
2024-08-29 20:08:43 +08:00
- name: Fetch PKGBUILD
run: |
wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD\?h\=chsrc -O ./PKGBUILD
- name: Update PKGBUILD
run: |
2024-08-29 20:35:44 +08:00
sed -i "s/pkgver=.*/pkgver=$version/" PKGBUILD
2024-09-08 16:13:27 +08:00
- name: Publish chsrc to AUR
2024-08-29 20:35:44 +08:00
if: env.valid == '1'
2024-08-29 20:08:43 +08:00
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 }}
2024-09-08 16:33:58 +08:00
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "github-action-auto-publish v${{ env.version }}"