Skip to content

Commit

Permalink
v2
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed May 7, 2020
0 parents commit a2279bb
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM archlinux/base

RUN pacman -Sy && \
pacman -Sy --noconfirm --needed openssh sudo \
git fakeroot binutils gcc awk binutils xz \
libarchive bzip2 coreutils file findutils \
gettext grep gzip sed ncurses util-linux

COPY entrypoint.sh /entrypoint.sh
COPY build.sh /build.sh
COPY ssh_config /ssh_config

ENTRYPOINT ["/entrypoint.sh"]
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The MIT License

Copyright (c) 2020 Hoàng Văn Khải

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Publish AUR packages

GitHub Actions to publish AUR package.

## Inputs

### `pkgname`

**Required** AUR package name.

### `pkgbuild`

**Required** Path to PKGBUILD file.

### `commit_username`

**Required** The username to use when creating the new commit.

### `commit_email`

**Required** The email to use when creating the new commit.

### `ssh_private_key`

**Required** Your private key with access to AUR package.

### `commit_message`

**Optional** Commit message to use when creating the new commit.

### `ssh_keyscan_types`

**Optional** Comma-separated list of types to use when adding aur.archlinux.org to known hosts.

## Example usage

```yaml
name: aur-publish

on:
push:
tags:
- '*'

jobs:
aur-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Publish AUR package
uses: KSXGitHub/github-actions-deploy-aur@master
with:
pkgname: my-awesome-package
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,dsa,ecdsa,ed25519
```
**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).
34 changes: 34 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# action.yml
name: 'Publish AUR package'
description: 'Publish an AUR package'
author: KSXGitHub
branding:
color: blue
icon: package
inputs:
pkgname:
description: 'AUR package name'
required: true
pkgbuild:
description: 'Path to PKGBUILD file'
required: true
commit_username:
description: 'The username to use when creating the new commit'
required: true
commit_email:
description: 'The email to use when creating the new commit'
required: true
ssh_private_key:
description: 'Your private key with access to AUR package.'
required: true
commit_message:
description: 'Commit message to use when creating the new commit'
required: false
default: 'Update PKGBUILD and .SRCINFO with GitHub Actions'
ssh_keyscan_types:
description: 'Comma-separated list of types to use when adding aur.archlinux.org to known hosts'
required: false
default: 'rsa,dsa,ecdsa,ed25519'
runs:
using: 'docker'
image: 'Dockerfile'
44 changes: 44 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
# shellcheck disable=SC2024

set -o errexit -o pipefail -o nounset

pkgname=$INPUT_PKGNAME
commit_username=$INPUT_COMMIT_USERNAME
commit_email=$INPUT_COMMIT_EMAIL
ssh_private_key=$INPUT_SSH_PRIVATE_KEY
commit_message=$INPUT_COMMIT_MESSAGE
ssh_keyscan_types=$INPUT_SSH_KEYSCAN_TYPES

export HOME=/home/builder

echo 'Adding aur.archlinux.org to known hosts...'
ssh-keyscan -v -t "$ssh_keyscan_types" aur.archlinux.org >> ~/.ssh/known_hosts

echo 'Importing private key...'
echo "$ssh_private_key" > ~/.ssh/aur
chmod -vR 600 ~/.ssh/aur*
ssh-keygen -vy -f ~/.ssh/aur > ~/.ssh/aur.pub

echo 'Checksums of SSH keys...'
sha512sum ~/.ssh/aur ~/.ssh/aur.pub

echo 'Configuring git...'
git config --global user.name "$commit_username"
git config --global user.email "$commit_email"

echo 'Cloning AUR package into /tmp/local-repo...'
git clone -v "https://aur.archlinux.org/${pkgname}.git" /tmp/local-repo
cd /tmp/local-repo

echo 'Copying PKGBUILD...'
cp -v /PKGBUILD ./

echo "Updating .SRCINFO"
makepkg --printsrcinfo > .SRCINFO

echo "Publishing..."
git remote add aur "ssh://[email protected]/${pkgname}.git"
git add -fv PKGBUILD .SRCINFO
git commit --allow-empty -m "$commit_message"
git push -fv aur master
22 changes: 22 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -o errexit -o pipefail -o nounset

pkgbuild=$INPUT_PKGBUILD

echo 'Creating builder user...'
useradd --create-home --shell /bin/bash builder
passwd --delete builder

echo 'Initializing ssh directory...'
mkdir -pv /home/builder/.ssh
touch /home/builder/.ssh/known_hosts
cp -v /ssh_config /home/builder/.ssh/config
chown -vR builder:builder /home/builder
chmod -vR 600 /home/builder/.ssh/*

echo 'Copying PKGBUILD...'
cp -r "$pkgbuild" /PKGBUILD

echo 'Running build.sh...'
exec runuser builder --command 'bash -l -c /build.sh'
5 changes: 5 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"config:base"
]
}
3 changes: 3 additions & 0 deletions ssh_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Host aur.archlinux.org
IdentityFile ~/.ssh/aur
User aur

0 comments on commit a2279bb

Please sign in to comment.