Skip to content

Commit

Permalink
add a github action job for the main branch to build and upload binaries
Browse files Browse the repository at this point in the history
Summary:
* add a basic github action job that runs on push to `main`.
  * inspired by the workflow from a reddit thread: https://www.reddit.com/r/rust/comments/12dphrq/comment/jf89urm/
* build a bunch of buck2 and upload as artifacts, they are by default retained for 90 days
* good
  * binaries uploaded and marked with target triple
* could be improved
  * users will have to go to the latest action page to find the artifact. trying to figure out how to best point users to it (there should be a link to the latest job off of main)
  * on macos getting the binary to run was a bit clunky (had to chmod, open and confirm it's safe etc)
* note for myself: I can't tell if the rust cache is working properly so trying to read up on it / monitor

Reviewed By: ndmitchell

Differential Revision: D44791506

fbshipit-source-id: b94d4d22b2ba14938f160a1fc1f04733366ea32a
  • Loading branch information
themarwhal authored and facebook-github-bot committed Apr 7, 2023
1 parent b86ab38 commit 798d6cc
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/upload_buck2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build and upload Buck2 binaries

on:
push:
branches:
- main

jobs:
build:
strategy:
fail-fast: false
matrix:
target:
- os: 'ubuntu-22.04'
triple: 'aarch64-unknown-linux-gnu'
cross: true
- os: 'ubuntu-22.04'
triple: 'aarch64-unknown-linux-musl'
cross: true
- os: 'ubuntu-22.04'
triple: 'x86_64-unknown-linux-gnu'
# - os: 'ubuntu-22.04'
# triple: 'x86_64-unknown-linux-musl' # Doesn't build
- os: 'macos-12'
triple: 'aarch64-apple-darwin'
- os: 'macos-12'
triple: 'x86_64-apple-darwin'
- os: 'windows-2022'
triple: 'x86_64-pc-windows-msvc'
runs-on: ${{ matrix.target.os }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target.os }}

- uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly-2023-01-24
targets: ${{ matrix.target.triple }}

- uses: actions-rs/[email protected]
if: matrix.target.cross
with:
crate: cross
version: latest

- name: Build
shell: bash
run: |
if [ -n "${{ matrix.target.cross }}" ]; then
CARGO=cross
else
CARGO=cargo
fi
$CARGO build --release --bin buck2 --target ${{ matrix.target.triple }}
mkdir upload
cp target/${{ matrix.target.triple }}/release/buck2* upload/
- name: Upload (non-Windows)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v3
with:
name: buck2-${{ matrix.target.triple }}
path: upload/buck2

- name: Upload (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: buck2-${{ matrix.target.triple }}
path: upload/buck2.exe

0 comments on commit 798d6cc

Please sign in to comment.