Skip to content

Update build.yml

Update build.yml #29

Workflow file for this run

name: Rust
on:
push:
# branches: [ "master", "dev" ]
branches: [ '*' ] # test
pull_request:
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
# Tag that will be automatically picked by ncipollo/release-action.
- name: Generate Tag
id: tag_step
run: |-
program_version="$(echo 1.0.0)"
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"
# https://github.com/ncipollo/release-action.
- uses: ncipollo/release-action@v1
id: release_step
with:
artifacts: "dist/raptor-cage.tgz,dist/raptor-cage.sha256"
tag: ${{ steps.tag_step.outputs.tag_name }}
makeLatest: true
- name: Publish to the AUR
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.sha256 | awk '{print $1}')
sed -e "s/{{VERSION}}/${current_version}/" -e "s/{{RELEASE}}/${pkgbuild_pkgrel}/" \
-e "s/{{TAG_NAME}}/${tag_name}/" -e "s/{{SHA256SUM}}/${tgz_sha256}/" \
packaging/PKGBUILD > raptor-cage-bin/PKGBUILD
echo "---> PKGBUILD"
cd raptor-cage-bin
id
docker run --rm -v "`pwd`:/data" -w /data archlinux:latest bash \
-c 'useradd -M -s /bin/bash user && su user -c "makepkg --printsrcinfo > .SRCINFO"'
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'
cat .SRCINFO