|
| 1 | +name: Rust |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "master" ] |
| 6 | + |
| 7 | +env: |
| 8 | + CARGO_TERM_COLOR: always |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + - name: Build |
| 18 | + run: |- |
| 19 | + make docker-build |
| 20 | + - name: Generate Tag |
| 21 | + id: tag_step |
| 22 | + run: |- |
| 23 | + program_version="$(echo 1.0.0)" |
| 24 | + tag_name="${program_version}-$(date +%y%m%d%H%M)-$(git rev-parse HEAD | head -c 7)" |
| 25 | + printf "tag_name=${tag_name}\nprogram_version=${program_version}\n" | tee -a "$GITHUB_OUTPUT" |
| 26 | + # https://github.com/ncipollo/release-action. |
| 27 | + - uses: ncipollo/release-action@v1 |
| 28 | + id: release_step |
| 29 | + with: |
| 30 | + artifacts: "dist/raptor-cage.tgz,dist/raptor-cage.sha256" |
| 31 | + tag: ${{ steps.tag_step.outputs.tag_name }} |
| 32 | + makeLatest: true |
| 33 | + - name: Publish to the AUR |
| 34 | + env: |
| 35 | + AUR_PRIVATE_KEY: ${{ secrets.AUR_PRIVATE_KEY }} |
| 36 | + run: |- |
| 37 | + mkdir -p ~/.ssh |
| 38 | + echo "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN" >> ~/.ssh/known_hosts |
| 39 | + git -c init.defaultBranch=master clone https://aur.archlinux.org/raptor-cage-bin.git |
| 40 | + pkgbuild_pkgver=$(grep "^pkgver=" raptor-cage-bin/PKGBUILD | cut -d'=' -f2) |
| 41 | + pkgbuild_pkgrel=$(grep "^pkgrel=" raptor-cage-bin/PKGBUILD | cut -d'=' -f2) |
| 42 | + current_version="${{ steps.tag_step.outputs.program_version }}" |
| 43 | + if [ "$current_version" == "$pkgbuild_pkgver" ]; then |
| 44 | + # Same version, so increase pkgbuild_pkgrel. |
| 45 | + ((pkgbuild_pkgrel++)) |
| 46 | + else |
| 47 | + # Different version, so reset pkgbuild_pkgrel. |
| 48 | + pkgbuild_pkgrel=1 |
| 49 | + fi |
| 50 | + tag_name="${{ steps.tag_step.outputs.tag_name }}" |
| 51 | + tgz_sha256=$(cat dist/raptor-cage.sha256 | awk '{print $1}') |
| 52 | + sed -e "s/{{VERSION}}/${current_version}/" -e "s/{{RELEASE}}/${pkgbuild_pkgrel}/" \ |
| 53 | + -e "s/{{TAG_NAME}}/${tag_name}/" -e "s/{{SHA256SUM}}/${tgz_sha256}/" \ |
| 54 | + packaging/PKGBUILD > raptor-cage-bin/PKGBUILD |
| 55 | + cd raptor-cage-bin |
| 56 | + docker run --rm -v "`pwd`:/data" -w /data --env user_uid=$(id -u) --env user_gid=$(id -g) \ |
| 57 | + archlinux:latest bash \ |
| 58 | + -c 'groupadd -g $user_gid user && useradd -M -s /bin/bash -u $user_uid -g $user_gid user && su user -c "makepkg --printsrcinfo > .SRCINFO"' |
| 59 | + git remote add aur ssh://[email protected]/raptor-cage-bin.git |
| 60 | + git config user.name RX0FA |
| 61 | + git config user.email [email protected] |
| 62 | + git add .SRCINFO PKGBUILD |
| 63 | + git commit -m "Update build files ($tag_name)" |
| 64 | + key_file="${{ github.workspace }}/id_ed25519" |
| 65 | + echo "$AUR_PRIVATE_KEY" > "$key_file" |
| 66 | + chmod 600 "$key_file" |
| 67 | + GIT_SSH_COMMAND="ssh -i \"${key_file}\" -o IdentitiesOnly=yes" git push aur master |
| 68 | + |
| 69 | + |
0 commit comments