forked from facebook/buck2
-
Notifications
You must be signed in to change notification settings - Fork 1
137 lines (132 loc) · 4.98 KB
/
upload_buck2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Build, upload, and tag `buck2`
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
strategy:
fail-fast: false
matrix:
target:
- os: 'ubuntu-24.04-arm'
triple: 'aarch64-unknown-linux-gnu'
- os: 'ubuntu-24.04-arm'
triple: 'aarch64-unknown-linux-musl'
- os: 'ubuntu-24.04'
triple: 'x86_64-unknown-linux-gnu'
- os: 'ubuntu-24.04'
triple: 'x86_64-unknown-linux-musl'
- os: 'macos-13'
triple: 'aarch64-apple-darwin'
cross: true
- os: 'macos-13'
triple: 'x86_64-apple-darwin'
- os: 'windows-2022'
triple: 'x86_64-pc-windows-msvc'
is_windows: true
runs-on: ${{ matrix.target.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install packages (Ubuntu)
if: matrix.os == 'ubuntu-24.04' || matrix.os == 'ubuntu-24.04-arm'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends xz-utils liblz4-tool musl-tools
- uses: SebRollen/toml-action@v1.0.2
id: read_rust_toolchain
with:
file: 'rust-toolchain'
field: 'toolchain.channel'
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ steps.read_rust_toolchain.outputs.value }}
targets: ${{ matrix.target.triple }}
- uses: Swatinem/rust-cache@v2
with:
prefix-key: buck2-upload
key: ${{ matrix.target.triple }}
- uses: actions-rs/install@v0.1
if: matrix.target.cross
with:
crate: cross
version: latest
- name: Set variables
id: set_variables
shell: bash
run: |
if [ -n "${{ matrix.target.is_windows }}" ]; then
echo "buck2_out=target/${{ matrix.target.triple }}/release/buck2.exe" >> "$GITHUB_OUTPUT"
echo "buck2_zst=artifacts/buck2-${{ matrix.target.triple }}.exe.zst" >> "$GITHUB_OUTPUT"
echo "buck2_rust_project_out=target/${{ matrix.target.triple }}/release/rust-project.exe" >> "$GITHUB_OUTPUT"
echo "buck2_rust_project_zst=artifacts/rust-project-${{ matrix.target.triple }}.exe.zst" >> "$GITHUB_OUTPUT"
else
echo "buck2_out=target/${{ matrix.target.triple }}/release/buck2" >> "$GITHUB_OUTPUT"
echo "buck2_zst=artifacts/buck2-${{ matrix.target.triple }}.zst" >> "$GITHUB_OUTPUT"
echo "buck2_rust_project_out=target/${{ matrix.target.triple }}/release/rust-project" >> "$GITHUB_OUTPUT"
echo "buck2_rust_project_zst=artifacts/rust-project-${{ matrix.target.triple }}.zst" >> "$GITHUB_OUTPUT"
fi
- name: Build
shell: bash
env:
RUSTFLAGS: "-C strip=debuginfo -C codegen-units=1"
run: |
# aarch64-linux builds need JEMALLOC_SYS_WITH_LG_PAGE=16
# this is for e.g. linux running on apple silicon with native 16k pages
if [[ "${{ matrix.target.triple }}" == aarch64-unknown-linux* ]]; then
export JEMALLOC_SYS_WITH_LG_PAGE=16
fi
if [ -n "${{ matrix.target.cross }}" ]; then
CARGO=cross
else
CARGO=cargo
fi
$CARGO build --release --bin buck2 --bin rust-project --target ${{ matrix.target.triple }}
- name: Sanity check with examples/with_prelude
if: ${{ !matrix.target.cross }}
shell: bash
run: |
BUCK2="$(pwd)/${{ steps.set_variables.outputs.buck2_out }}"
cd examples/with_prelude
"$BUCK2" build //rust/... //cpp/... //python/... -v=2
- name: Move binary to artifacts/
shell: bash
run: |
mkdir artifacts
zstd -z ${{ steps.set_variables.outputs.buck2_out }} -o ${{ steps.set_variables.outputs.buck2_zst }}
zstd -z ${{ steps.set_variables.outputs.buck2_rust_project_out }} -o ${{ steps.set_variables.outputs.buck2_rust_project_zst }}
- name: Upload
uses: actions/upload-artifact@v4
with:
name: buck2-${{ matrix.target.triple }}
path: artifacts/
release_latest_snapshot:
name: Release latest push snapshot
needs:
- build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Get snapshot tag (YYYYMMDD-HHMMSS)
id: get_tag
run: |
TAG=snapshot-$(date +'%Y%m%d-%H%M%S')
echo "tag_name=$TAG" >> "$GITHUB_OUTPUT"
echo "Release tag: $TAG"
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/publish_tag
with:
tag: "${{ steps.get_tag.outputs.tag_name }}"
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: facebook/dotslash-publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
config: .github/dotslash-config.json
tag: "${{ steps.get_tag.outputs.tag_name }}"