Skip to content

Commit

Permalink
Setup a workflow for building release binary
Browse files Browse the repository at this point in the history
  • Loading branch information
HanabishiRecca committed Jun 4, 2023
1 parent a2e0e58 commit 6a0b232
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build release binary

on:
release:
types:
- released

jobs:
build:
runs-on: ubuntu-latest
container:
image: archlinux:base-devel
env:
APP: aur-check-updates
VERSION: ${{ github.event.release.tag_name }}
CARCH: x86_64
RUSTUP_TOOLCHAIN: stable
CARGO_TERM_COLOR: always
UPLOAD_URL: ${{ github.event.release.upload_url }}

steps:
- uses: actions/checkout@v3

- name: Prepare
run: |
DEPS=('rust' 'mold')
pacman -Syu --needed --noconfirm --color always "${DEPS[@]}"
mkdir ".cargo"
cp -pv ".github/workflows/config.toml" -t ".cargo"
cargo fetch -v --locked --target "${CARCH}-unknown-linux-gnu"
- name: Run tests
run: cargo test -v --frozen

- name: Build
run: cargo build -v --frozen --release

- name: Upload archive
run: |
ARCHIVE="${APP}-${VERSION}-${CARCH}.tar.xz"
tar -cvJf "${ARCHIVE}" -C "target/release" "${APP}"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
--fail-with-body --connect-timeout 10 --retry 3 \
--data-binary "@${ARCHIVE}" \
"${UPLOAD_URL%'{'*}?name=${ARCHIVE}"
14 changes: 14 additions & 0 deletions .github/workflows/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[registries.crates-io]
protocol = "sparse"

[profile.release]
opt-level = 2
strip = true
lto = true
codegen-units = 1

[target.x86_64-unknown-linux-gnu]
rustflags = [
"-C", "target-cpu=generic",
"-C", "link-arg=-fuse-ld=mold",
]

0 comments on commit 6a0b232

Please sign in to comment.