Skip to content

Refactor tgz name

Refactor tgz name #39

Workflow file for this run

name: Rust
on:
push:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Build
run: |-
make docker-build
- name: Generate Tag
id: tag_step
run: |-
program_version=$(./dist/raptor-cage -V | awk '{print $2}')
tag_name="${program_version}-$(date +%y%m%d%H%M)-$(git rev-parse HEAD | head -c 7)"
printf "tag_name=${tag_name}\nprogram_version=${program_version}\n" | tee -a "$GITHUB_OUTPUT"
mv dist/raptor-cage.tgz dist/raptor-cage-${tag_name}.tgz
mv dist/raptor-cage.sha256 dist/raptor-cage-${tag_name}.sha256
# https://github.com/ncipollo/release-action.
- uses: ncipollo/release-action@v1
id: release_step
with:
artifacts: "dist/raptor-cage-${tag_name}.tgz,dist/raptor-cage-${tag_name}.sha256"
tag: ${{ steps.tag_step.outputs.tag_name }}
makeLatest: true
- name: Publish to the AUR
env:
AUR_PRIVATE_KEY: ${{ secrets.AUR_PRIVATE_KEY }}
run: |-
mkdir -p ~/.ssh
echo "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN" >> ~/.ssh/known_hosts
git -c init.defaultBranch=master clone https://aur.archlinux.org/raptor-cage-bin.git
pkgbuild_pkgver=$(grep "^pkgver=" raptor-cage-bin/PKGBUILD | cut -d'=' -f2)
pkgbuild_pkgrel=$(grep "^pkgrel=" raptor-cage-bin/PKGBUILD | cut -d'=' -f2)
current_version="${{ steps.tag_step.outputs.program_version }}"
if [ "$current_version" == "$pkgbuild_pkgver" ]; then
# Same version, so increase pkgbuild_pkgrel.
((pkgbuild_pkgrel++))
else
# Different version, so reset pkgbuild_pkgrel.
pkgbuild_pkgrel=1
fi
tag_name="${{ steps.tag_step.outputs.tag_name }}"
tgz_sha256=$(cat dist/raptor-cage-${tag_name}.sha256 | awk '{print $1}')
sed -e "s/{{VERSION}}/${current_version}/" -e "s/{{RELEASE}}/${pkgbuild_pkgrel}/" \
-e "s/{{TAG_NAME}}/${tag_name}/g" -e "s/{{SHA256SUM}}/${tgz_sha256}/" \
packaging/PKGBUILD > raptor-cage-bin/PKGBUILD
cd raptor-cage-bin
docker run --rm -v "`pwd`:/data" -w /data --env user_uid=$(id -u) --env user_gid=$(id -g) \
archlinux:latest bash \
-c 'groupadd -g $user_gid user && useradd -M -s /bin/bash -u $user_uid -g $user_gid user && su user -c "makepkg --printsrcinfo > .SRCINFO"'
git remote add aur ssh://aur@aur.archlinux.org/raptor-cage-bin.git
git config user.name RX0FA
git config user.email 174369883+RX0FA@users.noreply.github.com
git add .SRCINFO PKGBUILD
git commit -m "Update build files ($tag_name)"
key_file="${{ github.workspace }}/id_ed25519"
echo "$AUR_PRIVATE_KEY" > "$key_file"
chmod 600 "$key_file"
GIT_SSH_COMMAND="ssh -i \"${key_file}\" -o IdentitiesOnly=yes" git push aur master