feat: add in automatic publishing of AUR packages on release

This commit is contained in:
Ryan Dowling 2021-01-30 13:15:11 +11:00
parent 5a25bb5fea
commit 75155d30e2
No known key found for this signature in database
GPG key ID: 5539FCDB88950EFD
36 changed files with 460 additions and 7 deletions

View file

@ -0,0 +1,30 @@
FROM archlinux/base
# makepkg cannot (and should not) be run as root:
RUN useradd -m notroot
# Generally, refreshing without sync'ing is discouraged, but we've a clean
# environment here.
RUN pacman -Sy --noconfirm archlinux-keyring openssh base-devel git pacman-contrib namcap && \
pacman -Syu --noconfirm
# Allow notroot to run stuff as root (to install dependencies):
RUN echo "notroot ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/notroot
# Continue execution (and CMD) as notroot:
USER notroot
# Auto-fetch GPG keys (for checking signatures):
RUN mkdir /home/notroot/.gnupg && \
touch /home/notroot/.gnupg/gpg.conf && \
echo "keyserver-options auto-key-retrieve" > /home/notroot/.gnupg/gpg.conf
# Install yay (for building AUR dependencies):
RUN git clone https://aur.archlinux.org/yay-bin.git /home/notroot/yay-bin && \
cd /home/notroot/yay-bin && \
makepkg --noconfirm --syncdeps --rmdeps --install --clean
COPY entrypoint.sh /entrypoint.sh
USER root
ENTRYPOINT ["/entrypoint.sh"]

View file

@ -0,0 +1,30 @@
name: 'Build & Publish a package to AUR'
description: 'Build & Publish a package to AUR'
branding:
icon: user-check
color: gray-dark
inputs:
version:
description: 'The version'
required: true
workingDir:
description: 'The directory to work in'
required: true
packageName:
description: 'The name of the package to publish to'
required: true
aurUsername:
description: 'The username for the AUR user to publish as'
required: true
aurEmail:
description: 'The email for the AUR user to publish as'
required: true
aurSshPrivateKey:
description: 'The private SSH key for the AUR user to publish as'
required: true
aurCommitMessage:
description: 'The commit message to send to AUR when publishing'
required: true
runs:
using: 'docker'
image: 'Dockerfile'

View file

@ -0,0 +1,148 @@
#!/usr/bin/env bash
# inspired by https://github.com/glitchcrab/action-build-aur-package/blob/main/entrypoint.sh
set -o errexit
set -o pipefail
# base directory
BASEDIR=$(pwd)
# working directory
WORKDIR="$(pwd)/${INPUT_WORKINGDIR}"
main() {
# all further operations are relative to this directory
cd "${WORKDIR}"
# give write access to notroot user
setfacl -R -m 'u:notroot:rwx' ${BASEDIR}
# replace pkgver in PKGBUILD with new version
sed -i "s/pkgver=.*/pkgver=$INPUT_VERSION/g" PKGBUILD
# prepare git config
git config --global user.email "${INPUT_AUREMAIL}"
git config --global user.name "${INPUT_AURUSERNAME}"
# prepare SSH
prepare_ssh
# clone package
clone_package
# build the package
build
# push package
push_package
}
prepare_ssh() {
echo '::group::Preparing SSH'
if [ ! -d $HOME/.ssh ] ; then
mkdir -m 0700 $HOME/.ssh
fi
# pull down the public key(s) from the AUR servers
if ! ssh-keyscan -H aur.archlinux.org > $HOME/.ssh/known_hosts ; then
echo "Couldn't get SSH public key from AUR servers"
exit 1
fi
# write the private SSH key out to disk
if [ ! -z "${INPUT_AURSSHPRIVATEKEY}" ] ; then
# write the key out to disk
echo "${INPUT_AURSSHPRIVATEKEY}" > $HOME/.ssh/ssh_key
# ensure correct permissions
chmod 0400 $HOME/.ssh/ssh_key
fi
echo '::endgroup::'
}
clone_package() {
echo '::group::Cloning package from AUR'
# clone the AUR repo
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=$HOME/.ssh/known_hosts -i $HOME/.ssh/ssh_key"
if ! git clone "ssh://aur@aur.archlinux.org/${INPUT_PACKAGENAME}.git" /aur_repo; then
echo "failed to clone AUR repo"
exit 1
fi
# copy over files before building
cp * /aur_repo
cp ${BASEDIR}/LICENSE /aur_repo/LICENSE
chown -R notroot.notroot /aur_repo
echo '::endgroup::'
}
build() {
echo '::group::Building package'
if ! namcap PKGBUILD ; then
echo "PKGBUILD failed namcap check"
exit 1
fi
# update the package sums
su notroot -c "updpkgsums"
# copy over changed PKGBUILD
cp PKGBUILD /aur_repo
# install dependencies
yay -Sy --noconfirm \
$(pacman --deptest $(source ./PKGBUILD && echo ${depends[@]} ${makedepends[@]}))
# do the actual building
su notroot -c "makepkg -f"
BUILT_PKG_FILE=$(find -name \*pkg.tar.zst)
if ! namcap ${BUILT_PKG_FILE} ; then
echo "${BUILT_PKG_FILE} failed namcap check"
exit 1
fi
echo '::endgroup::'
}
push_package() {
echo '::group::Pushing package to AUR'
# change to where repo is cloned
cd /aur_repo
# update .SRCINFO
su notroot -c "makepkg --printsrcinfo > .SRCINFO"
# add files for committing
if ! git add . ; then
echo "Couldn't add files for committing"
exit 1
fi
# show current repo state
git status
# print out diff
git --no-pager diff master
# # commit changes
git commit -m "${INPUT_AURCOMMITMESSAGE}"
# # push changes to the repo
if ! git push ; then
echo "Couldn't push commit to AUR"
exit 1
fi
echo '::endgroup::'
}
# run
main "$@"

View file

@ -167,7 +167,7 @@ jobs:
echo "${NEW_VERSION}.Beta" > src/main/resources/version
- name: Commit new version/CHANGELOG file
uses: EndBug/add-and-commit@v7
uses: EndBug/add-and-commit@v7.0.0
if: ${{ !endsWith(steps.version.outputs.text, '.Beta') }}
with:
add: 'CHANGELOG.md src/main/resources/version'

49
.github/workflows/aur-publish.yml vendored Normal file
View file

@ -0,0 +1,49 @@
name: aur-publish
on:
release:
types: [published]
jobs:
aur-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Remove v from the release
id: clean-version
uses: frabert/replace-string-action@v1.2
with:
string: ${{ env.GITHUB_REF }}
pattern: 'v([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)'
replace-with: '$1'
- name: Publish atlauncher AUR package
uses: ./.github/actions/publish-to-aur
with:
version: ${{ steps.clean-version.outputs.replaced }}
copyFiles: ./packaging/aur/common
workingDir: ./packaging/aur/atlauncher
packageName: atlauncher
aurUsername: ${{ secrets.AUR_USERNAME }}
aurEmail: ${{ secrets.AUR_EMAIL }}
aurSshPrivateKey: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
aurCommitMessage: Update to version ${{ steps.clean-version.outputs.replaced }}
- name: Publish atlauncher-bin AUR package
uses: ./.github/actions/publish-to-aur
with:
version: ${{ steps.clean-version.outputs.replaced }}
copyFiles: ./packaging/aur/common
workingDir: ./packaging/aur/atlauncher-bin
packageName: atlauncher-bin
aurUsername: ${{ secrets.AUR_USERNAME }}
aurEmail: ${{ secrets.AUR_EMAIL }}
aurSshPrivateKey: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
aurCommitMessage: Update to version ${{ steps.clean-version.outputs.replaced }}
- name: Commit changed files
uses: EndBug/add-and-commit@v7.0.0
with:
add: 'packaging/aur/'
message: 'chore: update aur packages'

4
.gitignore vendored
View file

@ -20,6 +20,10 @@ cache/
# OS X
.DS_Store
# ACT
.actrc
.secrets
# Other
java_pid*.hprof
*.log

View file

@ -28,3 +28,4 @@ This changelog only contains the changes that are unreleased. For changes for in
- Some dialogs not showing on top in OSX correctly
### Misc
- Add in automatic publishing of AUR packages on release

View file

@ -0,0 +1,5 @@
pkg/*
src/*
atlauncher-*.pkg.tar.*
atlauncher-*.jar
jar

View file

@ -0,0 +1,50 @@
# Maintainer: Alan Jenkins <alan.james.jenkins at gmail dot com>
# Maintainer: Ryan Dowling <ryan at ryandowling dot me>
# Contributor: Maximilian Berger <snowdragon92 at gmail dot com>
pkgname=atlauncher-bin
_upstreamname=ATLauncher
pkgrel=1
pkgver=3.4.2.6
pkgdesc="A Launcher for Minecraft which integrates multiple different ModPacks to allow you to download and install
ModPacks easily and quickly."
arch=('any')
url="https://atlauncher.com/"
license=('GPL3')
depends=('java-runtime=8' 'openal')
makedepends=('unzip')
provides=('atlauncher')
conflicts=('atlauncher')
source=("atlauncher-${pkgver}-${pkgrel}.jar::https://github.com/ATLauncher/ATLauncher/releases/download/v$pkgver/$_upstreamname-$pkgver.jar"
"atlauncher"
"atlauncher.desktop"
"atlauncher.png")
noextract=("atlauncher-${pkgver}-${pkgrel}.jar")
sha256sums=('83e6a91f3172cd6a888a9e37bc12538b79a90c41e27d1e61a5bcfb1b9def7a0d'
'a1184d3b8ed125b6a182871bb19851c0635806c29f3d392660ae716a61174a89'
'bc8052811b1bd96c7b24963f11168ddba5e2769faa135a0e5680d6d1cc7b802a'
'dd370888c78fdb652d656d97e4a7f7e8c90aa8d75d4f4d01d0bd32e95c327c47')
package() {
cd "$srcdir"
# create folder for the main jar executable
mkdir -p "$pkgdir/usr/share/java/atlauncher/"
chmod -R 755 "$pkgdir/usr/share/java/atlauncher/"
# create folder for other files
mkdir -p "$pkgdir/usr/share/atlauncher/Downloads"
chmod 777 "$pkgdir/usr/share/atlauncher/Downloads"
# install shell wrapper script
install -D -m755 "$srcdir/atlauncher" "$pkgdir/usr/bin/atlauncher"
# install jar
install -D -m644 "$srcdir/atlauncher-${pkgver}-${pkgrel}.jar" "$pkgdir/usr/share/java/atlauncher/ATLauncher.jar"
# install desktop launcher with icon
install -D -m644 "$srcdir/atlauncher.desktop" "$pkgdir/usr/share/applications/atlauncher.desktop"
install -D -m644 "$srcdir/atlauncher.png" "$pkgdir/usr/share/pixmaps/atlauncher.png"
}

View file

@ -0,0 +1,12 @@
#!/bin/bash
set -euo pipefail
# fix for users of special IM modules
unset XMODIFIERS GTK_IM_MODULE QT_IM_MODULE
mkdir -p "${HOME}/.local/share/atlauncher"
cd "${HOME}/.local/share/atlauncher"
cp -u /usr/share/java/atlauncher/ATLauncher.jar .
# disable launcher updates since we're managing updates through AUR
exec java -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -jar ATLauncher.jar --no-launcher-update "$@" >/dev/null

View file

@ -0,0 +1,10 @@
[Desktop Entry]
Name=ATLauncher
GenericName=ATLauncher
Comment=A Launcher for Minecraft which integrates multiple different ModPacks to allow you to download and install ModPacks easily and quickly.
Exec=atlauncher
Icon=/usr/share/pixmaps/atlauncher.png
Terminal=false
Type=Application
Categories=Game;
Keywords=game;Minecraft;

View file

@ -0,0 +1,16 @@
# This is a default template for a post-install scriptlet.
# Uncomment only required functions and remove any functions
# you don't need (and this header).
## arg 1: the new package version
post_install() {
echo ">>> PACKAGES NOTES"
echo ">>> --------------"
echo ">>> This launcher requires you to login with a valid minecraft.net account to be"
echo ">>> able to install mod packs and play minecraft."
echo ">>> To create an account, connect to https://www.minecraft.net/store/minecraft-java-edition"
echo ">>> and buy the full game. You should then be able to log in and play."
echo ">>> --------------"
}
# vim:set ts=2 sw=2 et:

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

4
packaging/aur/atlauncher/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
pkg/*
src/*
ATLauncher-*.tar.gz
atlauncher-*.pkg.tar.*

View file

@ -0,0 +1,55 @@
# Maintainer: Alan Jenkins <alan.james.jenkins at gmail dot com>
# Maintainer: Ryan Dowling <ryan at ryandowling dot me>
# Contributor: Maximilian Berger <snowdragon92 at gmail dot com>
# Contributor: Cobalt Space <cobaltspace at protonmail dot com>
pkgname=atlauncher
_upstreamname=ATLauncher
pkgrel=1
pkgver=3.4.2.6
pkgdesc="A Launcher for Minecraft which integrates multiple different ModPacks to allow you to download and install
ModPacks easily and quickly."
arch=('any')
url="https://github.com/ATLauncher/ATLauncher"
license=('GPL3')
depends=('java-runtime=8' 'openal')
makedepends=('java-environment=8' 'gradle')
provides=('atlauncher')
conflicts=('atlauncher-bin')
source=("$_upstreamname-$pkgver.tar.gz::https://github.com/ATLauncher/ATLauncher/archive/v$pkgver.tar.gz"
"atlauncher"
"atlauncher.desktop"
"atlauncher.png")
sha256sums=('6a5303a2f15f473409c7cfd46c30fb10791ba996a432fb7b66052ebe74a3a5a1'
'a1184d3b8ed125b6a182871bb19851c0635806c29f3d392660ae716a61174a89'
'bc8052811b1bd96c7b24963f11168ddba5e2769faa135a0e5680d6d1cc7b802a'
'dd370888c78fdb652d656d97e4a7f7e8c90aa8d75d4f4d01d0bd32e95c327c47')
build() {
cd "$_upstreamname-$pkgver"
gradle build -x test
}
package() {
cd "$srcdir"
# create folder for the main jar executable
mkdir -p "$pkgdir/usr/share/java/atlauncher/"
chmod -R 755 "$pkgdir/usr/share/java/atlauncher/"
# create folder for other files
mkdir -p "$pkgdir/usr/share/atlauncher/Downloads"
chmod 777 "$pkgdir/usr/share/atlauncher/Downloads"
# install shell wrapper script
install -D -m755 "$srcdir/atlauncher" "$pkgdir/usr/bin/atlauncher"
# install jar
install -D -m644 "$srcdir/$_upstreamname-$pkgver/dist/$_upstreamname-$pkgver.jar" "$pkgdir/usr/share/java/atlauncher/ATLauncher.jar"
# install desktop launcher with icon
install -D -m644 "$srcdir/atlauncher.desktop" "$pkgdir/usr/share/applications/atlauncher.desktop"
install -D -m644 "$srcdir/atlauncher.png" "$pkgdir/usr/share/pixmaps/atlauncher.png"
}

View file

@ -0,0 +1,12 @@
#!/bin/bash
set -euo pipefail
# fix for users of special IM modules
unset XMODIFIERS GTK_IM_MODULE QT_IM_MODULE
mkdir -p "${HOME}/.local/share/atlauncher"
cd "${HOME}/.local/share/atlauncher"
cp -u /usr/share/java/atlauncher/ATLauncher.jar .
# disable launcher updates since we're managing updates through AUR
exec java -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -jar ATLauncher.jar --no-launcher-update "$@" >/dev/null

View file

@ -0,0 +1,10 @@
[Desktop Entry]
Name=ATLauncher
GenericName=ATLauncher
Comment=A Launcher for Minecraft which integrates multiple different ModPacks to allow you to download and install ModPacks easily and quickly.
Exec=atlauncher
Icon=/usr/share/pixmaps/atlauncher.png
Terminal=false
Type=Application
Categories=Game;
Keywords=game;Minecraft;

View file

@ -0,0 +1,16 @@
# This is a default template for a post-install scriptlet.
# Uncomment only required functions and remove any functions
# you don't need (and this header).
## arg 1: the new package version
post_install() {
echo ">>> PACKAGES NOTES"
echo ">>> --------------"
echo ">>> This launcher requires you to login with a valid minecraft.net account to be"
echo ">>> able to install mod packs and play minecraft."
echo ">>> To create an account, connect to https://www.minecraft.net/store/minecraft-java-edition"
echo ">>> and buy the full game. You should then be able to log in and play."
echo ">>> --------------"
}
# vim:set ts=2 sw=2 et:

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

Before

Width:  |  Height:  |  Size: 951 B

After

Width:  |  Height:  |  Size: 951 B

View file

@ -5,6 +5,7 @@ Icon=/opt/atlauncher/icon.svg
Keywords=game;Minecraft;
MimeType=
Name=ATLauncher
Comment=A Launcher for Minecraft which integrates multiple different ModPacks to allow you to download and install ModPacks easily and quickly.
Path=
StartupNotify=true
Terminal=false

View file

@ -0,0 +1,3 @@
cd ../../
docker run --rm -i -v %cd%:/work -w /work/packaging/windows-setup amake/innosetup installer.iss
cd packaging/windows-setup

View file

@ -0,0 +1,3 @@
cd ../../
docker run --rm -i -v $PWD:/work -w /work/packaging/windows-setup amake/innosetup installer.iss
cd packaging/windows-setup

View file

Before

Width:  |  Height:  |  Size: 580 KiB

After

Width:  |  Height:  |  Size: 580 KiB

View file

@ -1,3 +0,0 @@
cd ../../
docker run --rm -i -v %cd%:/work -w /work/scripts/windows-setup amake/innosetup installer.iss
cd scripts/windows-setup

View file

@ -1,3 +0,0 @@
cd ../../
docker run --rm -i -v $PWD:/work -w /work/scripts/windows-setup amake/innosetup installer.iss
cd scripts/windows-setup