Skip to content

Commit a2279bb

Browse files
committed
v2
0 parents  commit a2279bb

File tree

8 files changed

+205
-0
lines changed

8 files changed

+205
-0
lines changed

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM archlinux/base
2+
3+
RUN pacman -Sy && \
4+
pacman -Sy --noconfirm --needed openssh sudo \
5+
git fakeroot binutils gcc awk binutils xz \
6+
libarchive bzip2 coreutils file findutils \
7+
gettext grep gzip sed ncurses util-linux
8+
9+
COPY entrypoint.sh /entrypoint.sh
10+
COPY build.sh /build.sh
11+
COPY ssh_config /ssh_config
12+
13+
ENTRYPOINT ["/entrypoint.sh"]

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License
2+
3+
Copyright (c) 2020 Hoàng Văn Khải
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Publish AUR packages
2+
3+
GitHub Actions to publish AUR package.
4+
5+
## Inputs
6+
7+
### `pkgname`
8+
9+
**Required** AUR package name.
10+
11+
### `pkgbuild`
12+
13+
**Required** Path to PKGBUILD file.
14+
15+
### `commit_username`
16+
17+
**Required** The username to use when creating the new commit.
18+
19+
### `commit_email`
20+
21+
**Required** The email to use when creating the new commit.
22+
23+
### `ssh_private_key`
24+
25+
**Required** Your private key with access to AUR package.
26+
27+
### `commit_message`
28+
29+
**Optional** Commit message to use when creating the new commit.
30+
31+
### `ssh_keyscan_types`
32+
33+
**Optional** Comma-separated list of types to use when adding aur.archlinux.org to known hosts.
34+
35+
## Example usage
36+
37+
```yaml
38+
name: aur-publish
39+
40+
on:
41+
push:
42+
tags:
43+
- '*'
44+
45+
jobs:
46+
aur-publish:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v2
50+
51+
- name: Publish AUR package
52+
uses: KSXGitHub/github-actions-deploy-aur@master
53+
with:
54+
pkgname: my-awesome-package
55+
pkgbuild: ./PKGBUILD
56+
commit_username: ${{ secrets.AUR_USERNAME }}
57+
commit_email: ${{ secrets.AUR_EMAIL }}
58+
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
59+
commit_message: Update AUR package
60+
ssh_keyscan_types: rsa,dsa,ecdsa,ed25519
61+
```
62+
63+
**Tip:** To create secrets (such as `secrets.AUR_USERNAME`, `secrets.AUR_EMAIL`, and `secrets.AUR_SSH_PRIVATE_KEY` above), go to `$YOUR_GITHUB_REPO_URL/settings/secrets`. [Read this for more information](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets).

action.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# action.yml
2+
name: 'Publish AUR package'
3+
description: 'Publish an AUR package'
4+
author: KSXGitHub
5+
branding:
6+
color: blue
7+
icon: package
8+
inputs:
9+
pkgname:
10+
description: 'AUR package name'
11+
required: true
12+
pkgbuild:
13+
description: 'Path to PKGBUILD file'
14+
required: true
15+
commit_username:
16+
description: 'The username to use when creating the new commit'
17+
required: true
18+
commit_email:
19+
description: 'The email to use when creating the new commit'
20+
required: true
21+
ssh_private_key:
22+
description: 'Your private key with access to AUR package.'
23+
required: true
24+
commit_message:
25+
description: 'Commit message to use when creating the new commit'
26+
required: false
27+
default: 'Update PKGBUILD and .SRCINFO with GitHub Actions'
28+
ssh_keyscan_types:
29+
description: 'Comma-separated list of types to use when adding aur.archlinux.org to known hosts'
30+
required: false
31+
default: 'rsa,dsa,ecdsa,ed25519'
32+
runs:
33+
using: 'docker'
34+
image: 'Dockerfile'

build.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# shellcheck disable=SC2024
3+
4+
set -o errexit -o pipefail -o nounset
5+
6+
pkgname=$INPUT_PKGNAME
7+
commit_username=$INPUT_COMMIT_USERNAME
8+
commit_email=$INPUT_COMMIT_EMAIL
9+
ssh_private_key=$INPUT_SSH_PRIVATE_KEY
10+
commit_message=$INPUT_COMMIT_MESSAGE
11+
ssh_keyscan_types=$INPUT_SSH_KEYSCAN_TYPES
12+
13+
export HOME=/home/builder
14+
15+
echo 'Adding aur.archlinux.org to known hosts...'
16+
ssh-keyscan -v -t "$ssh_keyscan_types" aur.archlinux.org >> ~/.ssh/known_hosts
17+
18+
echo 'Importing private key...'
19+
echo "$ssh_private_key" > ~/.ssh/aur
20+
chmod -vR 600 ~/.ssh/aur*
21+
ssh-keygen -vy -f ~/.ssh/aur > ~/.ssh/aur.pub
22+
23+
echo 'Checksums of SSH keys...'
24+
sha512sum ~/.ssh/aur ~/.ssh/aur.pub
25+
26+
echo 'Configuring git...'
27+
git config --global user.name "$commit_username"
28+
git config --global user.email "$commit_email"
29+
30+
echo 'Cloning AUR package into /tmp/local-repo...'
31+
git clone -v "https://aur.archlinux.org/${pkgname}.git" /tmp/local-repo
32+
cd /tmp/local-repo
33+
34+
echo 'Copying PKGBUILD...'
35+
cp -v /PKGBUILD ./
36+
37+
echo "Updating .SRCINFO"
38+
makepkg --printsrcinfo > .SRCINFO
39+
40+
echo "Publishing..."
41+
git remote add aur "ssh://aur@aur.archlinux.org/${pkgname}.git"
42+
git add -fv PKGBUILD .SRCINFO
43+
git commit --allow-empty -m "$commit_message"
44+
git push -fv aur master

entrypoint.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -o errexit -o pipefail -o nounset
4+
5+
pkgbuild=$INPUT_PKGBUILD
6+
7+
echo 'Creating builder user...'
8+
useradd --create-home --shell /bin/bash builder
9+
passwd --delete builder
10+
11+
echo 'Initializing ssh directory...'
12+
mkdir -pv /home/builder/.ssh
13+
touch /home/builder/.ssh/known_hosts
14+
cp -v /ssh_config /home/builder/.ssh/config
15+
chown -vR builder:builder /home/builder
16+
chmod -vR 600 /home/builder/.ssh/*
17+
18+
echo 'Copying PKGBUILD...'
19+
cp -r "$pkgbuild" /PKGBUILD
20+
21+
echo 'Running build.sh...'
22+
exec runuser builder --command 'bash -l -c /build.sh'

renovate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"config:base"
4+
]
5+
}

ssh_config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Host aur.archlinux.org
2+
IdentityFile ~/.ssh/aur
3+
User aur

0 commit comments

Comments
 (0)