-
Notifications
You must be signed in to change notification settings - Fork 219
130 lines (109 loc) · 3.74 KB
/
auto-pr-rebuild-script.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
name: Rebuild ACIR artifacts
on:
pull_request:
push:
branches:
- master
jobs:
check-artifacts-requested:
name: Check if artifacts should be published
runs-on: ubuntu-22.04
outputs:
publish: ${{ steps.check.outputs.result }}
steps:
- name: Check if artifacts should be published
id: check
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { REF_NAME } = process.env;
if (REF_NAME == "master") {
console.log(`publish = true`)
return true;
}
const labels = context.payload.pull_request.labels.map(label => label.name);
const publish = labels.includes('publish-acir');
console.log(`publish = ${publish}`)
return publish;
result-encoding: string
env:
REF_NAME: ${{ github.ref_name }}
build-nargo:
name: Build nargo binary
if: ${{ needs.check-artifacts-requested.outputs.publish == 'true' }}
runs-on: ubuntu-22.04
needs: [check-artifacts-requested]
strategy:
matrix:
target: [x86_64-unknown-linux-gnu]
steps:
- name: Checkout Noir repo
uses: actions/checkout@v4
- name: Setup toolchain
uses: dtolnay/rust-toolchain@1.71.1
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
cache-on-failure: true
save-if: ${{ github.event_name != 'merge_group' }}
- name: Build Nargo
run: cargo build --package nargo_cli --release
- name: Package artifacts
run: |
mkdir dist
cp ./target/release/nargo ./dist/nargo
7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: nargo
path: ./dist/*
retention-days: 3
auto-pr-rebuild-script:
name: Rebuild ACIR artifacts
needs: [build-nargo]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Download nargo binary
uses: actions/download-artifact@v3
with:
name: nargo
path: ./nargo
- name: Add Nargo to $PATH
run: |
chmod +x ${{ github.workspace }}/nargo/nargo
echo "${{ github.workspace }}/nargo" >> $GITHUB_PATH
- name: Set up Git user (Github Action)
run: |
git config --local user.name kevaundray
git config --local user.email kevtheappdev@gmail.com
- name: Run rebuild script
working-directory: tooling/nargo_cli/tests
run: |
chmod +x ./rebuild.sh
./rebuild.sh
- name: Upload ACIR artifacts
uses: actions/upload-artifact@v3
with:
name: acir-artifacts
path: ./tooling/nargo_cli/tests/acir_artifacts
retention-days: 10
- name: Check for changes in acir_artifacts directory
id: check_changes
if: ${{ github.ref_name }} == "master"
run: |
git diff --quiet tooling/nargo_cli/tests/acir_artifacts/ || echo "::set-output name=changes::true"
- name: Create or Update PR
if: steps.check_changes.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.NOIR_REPO_TOKEN }}
commit-message: "chore: update acir artifacts"
title: "chore: Update ACIR artifacts"
body: "Automatic PR to update acir artifacts"
add-paths: tooling/nargo_cli/tests/acir_artifacts/*.gz
labels: "auto-pr"
branch: "auto-pr-rebuild-script-branch"