Update build.yml #26
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 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" | |
cat raptor-cage-bin/PKGBUILD | |