Skip to content

Commit 89d4912

Browse files
authored
Swap to new build image + upload to s3 (#153)
1 parent 804fc99 commit 89d4912

File tree

1 file changed

+122
-42
lines changed

1 file changed

+122
-42
lines changed

.github/workflows/build-riscv64.yml

+122-42
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,137 @@
1-
name: Build and test riscv64 on ubuntu-latest
1+
name: Build and test riscv64
22

33
on:
44
push:
55
branches:
66
- main
7-
- dev
8-
tags:
9-
- '**'
7+
release:
8+
types: [published]
109
pull_request:
1110
branches:
1211
- '**'
1312

13+
concurrency:
14+
# SHA is added to the end if on `main` to let all main workflows run
15+
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
16+
cancel-in-progress: true
17+
18+
permissions:
19+
contents: read
20+
id-token: write
21+
1422
jobs:
1523
build_wheels:
16-
name: QEMU riscv64 via Debian on ubuntu-latest
17-
runs-on: ${{ matrix.os }}
24+
name: ${{ matrix.os.emoji }} 📦 Build ${{ matrix.python.major-dot-minor }}
25+
runs-on: ${{ matrix.os.runs-on }}
1826
strategy:
27+
fail-fast: false
1928
matrix:
20-
os: [ ubuntu-latest ]
29+
os:
30+
- name: Linux
31+
matrix: linux
32+
emoji: 🐧
33+
runs-on: [ubuntu-latest]
34+
python:
35+
- major-dot-minor: '3.8'
36+
matrix: '3.8'
37+
- major-dot-minor: '3.9'
38+
matrix: '3.9'
39+
- major-dot-minor: '3.10'
40+
matrix: '3.10'
41+
- major-dot-minor: '3.11'
42+
matrix: '3.11'
2143

2244
steps:
23-
- name: Checkout repository
24-
uses: actions/checkout@v3
25-
with:
26-
fetch-depth: 1
27-
28-
- name: Set up QEMU on x86_64
29-
if: startsWith(matrix.os, 'ubuntu-latest')
30-
id: qemu
31-
uses: docker/setup-qemu-action@v2
32-
with:
33-
platforms: riscv64
34-
35-
- name: Build and Test
36-
run: |
37-
docker run --rm --platform linux/riscv64 \
38-
-v ${{ github.workspace }}:/ws --workdir=/ws \
39-
riscv64/debian:rc-buggy \
40-
bash -exc '\
41-
apt-get update && \
42-
apt-get install -y cmake build-essential git python3-full python3-dev python3-pip libgmp-dev libboost-dev && \
43-
cmake --version && \
44-
uname -a && \
45-
export BUILD_VDF_CLIENT=N && \
46-
pip wheel -w dist . && \
47-
python3 -m venv venv && \
48-
./venv/bin/python -m pip install dist/*.whl && \
49-
./venv/bin/python -m pip install pytest && \
50-
./venv/bin/python -m pytest -v tests/
51-
'
52-
53-
- name: Upload artifacts
54-
uses: actions/upload-artifact@v3
55-
with:
56-
name: packages
57-
path: ./dist
45+
- name: Checkout repository
46+
uses: actions/checkout@v3
47+
with:
48+
fetch-depth: 1
49+
50+
- name: Set up QEMU on x86_64
51+
id: qemu
52+
uses: docker/setup-qemu-action@v2
53+
with:
54+
platforms: riscv64
55+
56+
- name: Build and Test
57+
run: |
58+
docker run --rm --platform linux/riscv64 \
59+
-v ${{ github.workspace }}:/ws --workdir=/ws \
60+
chianetwork/ubuntu-22.04-risc-builder:latest \
61+
bash -exc '\
62+
pyenv global ${{ matrix.python.matrix }} && \
63+
python3 -m venv venv && \
64+
source ./venv/bin/activate && \
65+
pip install --upgrade pip && \
66+
cmake --version && \
67+
uname -a && \
68+
export BUILD_VDF_CLIENT=N && \
69+
pip wheel -w dist . && \
70+
./venv/bin/python -m pip install dist/*.whl && \
71+
./venv/bin/python -m pip install pytest && \
72+
./venv/bin/python -m pytest -v tests/
73+
'
74+
75+
- name: Upload artifacts
76+
uses: actions/upload-artifact@v3
77+
with:
78+
name: packages
79+
path: ./dist
80+
if-no-files-found: error
81+
upload:
82+
name: Upload to Chia PyPI
83+
runs-on: ubuntu-latest
84+
needs:
85+
- build_wheels
86+
steps:
87+
- name: Checkout code
88+
uses: actions/checkout@v3
89+
with:
90+
fetch-depth: 0
91+
92+
- name: Set Env
93+
uses: Chia-Network/actions/setjobenv@main
94+
env:
95+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
97+
- name: Download artifacts
98+
if: env.RELEASE == 'true'
99+
uses: actions/download-artifact@v3
100+
with:
101+
name: packages
102+
path: ./dist
103+
104+
- name: Configure AWS credentials
105+
if: env.RELEASE == 'true'
106+
uses: aws-actions/configure-aws-credentials@v2
107+
with:
108+
role-to-assume: arn:aws:iam::${{ secrets.CHIA_AWS_ACCOUNT_ID }}:role/installer-upload
109+
aws-region: us-west-2
110+
111+
- name: List existing wheels
112+
if: env.RELEASE == 'true'
113+
shell: sh
114+
run: |
115+
aws s3 ls s3://download.chia.net/simple/chiavdf/ > existing_wheel_list_raw
116+
cat existing_wheel_list_raw
117+
cat existing_wheel_list_raw | tr -s ' ' | cut -d ' ' -f 4 > existing_wheel_list
118+
119+
- name: List new wheels
120+
if: env.RELEASE == 'true'
121+
shell: sh
122+
run: |
123+
(cd dist/; ls ${{ inputs.package_name }}-*.whl) > new_wheel_list
124+
cat new_wheel_list | xargs -I % sh -c 'ls -l dist/%'
125+
126+
- name: Choose wheels to upload
127+
if: env.RELEASE == 'true'
128+
shell: sh
129+
run: |
130+
grep -F -x -v -f existing_wheel_list new_wheel_list > upload_wheel_list
131+
cat upload_wheel_list
132+
133+
- name: Upload wheels
134+
if: env.RELEASE == 'true'
135+
shell: sh
136+
run: |
137+
cat upload_wheel_list | xargs -I % sh -c 'aws s3 cp dist/% s3://download.chia.net/simple/chiavdf/'

0 commit comments

Comments
 (0)