Skip to content

Commit 79f832b

Browse files
authored
improve github actions integration (#604)
* improve github actions integration * make AppImage executable * add depends/packages to cache key * test packaging repo * fix artifact path * refactor * fix makejobs * drop riscv builds get packaging from peercoin/packaging
1 parent 7074616 commit 79f832b

3 files changed

Lines changed: 237 additions & 46 deletions

File tree

.github/workflows/appimage.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 237 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,246 @@
1-
name: Peercoin-artifact
2-
on: [push, pull_request]
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**/*.md'
7+
pull_request:
8+
paths-ignore:
9+
- 'doc/**'
10+
- 'contrib/**'
11+
- '**/*.md'
12+
13+
env:
14+
MAKEJOBS: 3
15+
DOCKER_BUILDKIT: 1
16+
GITIAN_DIR: /opt/gitian-builder
17+
GITIAN_CACHE: /opt/gitian-builder/cache
18+
DEBIAN_FRONTEND: noninteractive
19+
USE_DOCKER: 1
320

4-
# Should do linux, mac and windows.
521
jobs:
6-
linux:
22+
binary:
723
runs-on: ubuntu-latest
24+
container: docker:stable-dind
25+
strategy:
26+
matrix:
27+
name:
28+
- armhf-linux
29+
- aarch64-linux
30+
- x86_64-linux
31+
- x86_64-macos
32+
- x86_64-win
33+
include:
34+
- os: linux
35+
name: armhf-linux
36+
host: arm-linux-gnueabihf
37+
- os: linux
38+
name: aarch64-linux
39+
host: aarch64-linux-gnu
40+
- os: linux
41+
name: x86_64-linux
42+
host: x86_64-linux-gnu
43+
- os: osx
44+
name: x86_64-macos
45+
host: x86_64-apple-darwin16
46+
- os: win
47+
name: x86_64-win
48+
host: x86_64-w64-mingw32
849
steps:
9-
- name: checkout
10-
uses: actions/checkout@v2
11-
12-
- name: dependencies
50+
- name: Set up environment
1351
run: |
14-
sudo apt-get -y install autoconf libprotobuf-dev protobuf-compiler libminiupnpc-dev libzmq3-dev libqrencode-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libtool pkg-config libdb-dev libdb++-dev libboost-all-dev libssl-dev libevent-dev
15-
16-
- name: build
52+
apk add --no-cache curl make ruby wget git sed tar grep
53+
git clone https://github.com/devrandom/gitian-builder.git ${GITIAN_DIR}
54+
mkdir -p ${GITIAN_DIR}/inputs ${GITIAN_DIR}/var
55+
wget https://github.com/mikefarah/yq/releases/download/v4.13.5/yq_linux_amd64.tar.gz -O - |\
56+
tar xz && mv yq_linux_amd64 /usr/bin/yq
57+
58+
- name: Fetch OSX SDK
59+
if: ${{ matrix.os == 'osx' }}
1760
run: |
18-
./autogen.sh
19-
./configure --with-gui=qt5 --disable-bench --disable-tests --disable-ccache --with-incompatible-bdb
20-
make
61+
wget -N https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.14.sdk.tar.xz
62+
tar xf MacOSX10.14.sdk.tar.xz
63+
tar czf ${GITIAN_DIR}/inputs/MacOSX10.14.sdk.tar.gz MacOSX10.14.sdk
64+
rm -rf MacOSX10.14.sdk MacOSX10.14.sdk.tar.xz
65+
66+
- uses: actions/checkout@v2
67+
with:
68+
fetch-depth: 0
69+
70+
- name: Detect suite
71+
id: detect
72+
run: |
73+
DESCRIPTOR=$PWD/contrib/gitian-descriptors/gitian-${{ matrix.os }}.yml
74+
NAME=$(yq e '.name' ${DESCRIPTOR})
75+
echo ::set-output name=descriptor::${DESCRIPTOR}
76+
echo ::set-output name=name::${NAME}
77+
echo ::set-output name=version::$(echo ${NAME} | grep -Eo [0-9.]+)
78+
echo ::set-output name=suite::$(yq e '.suites[0]' ${DESCRIPTOR})
79+
echo ::set-output name=architecture::$(yq e '.architectures[0]' ${DESCRIPTOR})
80+
echo ::set-output name=build-dir::${PWD}
81+
82+
- name: Build gitian base image
83+
run: |
84+
docker build --tag base-${{ steps.detect.outputs.suite }}-${{ steps.detect.outputs.architecture }} -<<EOF
85+
FROM ubuntu:${{ steps.detect.outputs.suite }}
86+
ENV DEBIAN_FRONTEND=noninteractive
87+
RUN apt-get update && apt-get --no-install-recommends -y install pciutils build-essential git subversion language-pack-en wget lsb-release
88+
RUN useradd -ms /bin/bash -U ubuntu
89+
USER ubuntu:ubuntu
90+
WORKDIR /home/ubuntu
91+
CMD ["sleep", "infinity"]
92+
EOF
93+
94+
- name: Cache common
95+
uses: actions/cache@v2
96+
id: gitian-common
97+
env:
98+
cache-name: gitian-common
99+
with:
100+
path: ${{ env.GITIAN_CACHE }}/common
101+
key: ${{ env.cache-name }}-${{ hashFiles('depends/packages/*') }}
21102

103+
- name: Cache arch
104+
uses: actions/cache@v2
105+
env:
106+
cache-name: gitian-host
107+
with:
108+
path: ${{ env.GITIAN_CACHE }}/${{ steps.detect.outputs.name }}/${{ matrix.host }}
109+
key: ${{ matrix.name }}-${{ env.cache-name }}-${{ hashFiles('depends/packages/*') }}
110+
111+
- name: Download common
112+
if: steps.gitian-common.outputs.cache-hit != 'true'
113+
run: |
114+
cd ${GITIAN_DIR}
115+
make -j $MAKEJOBS -C ${{ steps.detect.outputs.build-dir }}/depends download SOURCES_PATH=${GITIAN_CACHE}/common
116+
cd -
117+
118+
- name: Build binary
119+
run: |
120+
cd ${GITIAN_DIR}
121+
sed -i "s/^\ \ \(HOSTS=\"\).*/\ \ \1${{ matrix.host }}\"/g" ${{ steps.detect.outputs.descriptor }}
122+
./bin/gbuild -j $MAKEJOBS --commit peercoin=${{ github.sha }} --url peercoin=${{ steps.detect.outputs.build-dir }} ${{ steps.detect.outputs.descriptor }}
123+
cp -r ${GITIAN_DIR}/build/out/* ${{ steps.detect.outputs.build-dir }}/
124+
cd -
125+
126+
- name: Get short SHA
127+
id: slug
128+
run: echo "::set-output name=sha8::$(echo ${{ github.sha }} | cut -c1-8)"
129+
130+
- uses: actions/upload-artifact@v2
131+
with:
132+
name: peercoin-${{ steps.slug.outputs.sha8 }}-${{ matrix.name }}
133+
path: |
134+
*.tar.gz
135+
*.zip
136+
*.exe
137+
*.dmg
138+
!*-debug*
139+
!*-unsigned.tar.gz
140+
retention-days: 5
141+
docker:
142+
runs-on: ubuntu-latest
143+
needs: [binary]
144+
steps:
145+
- uses: actions/checkout@v2
146+
with:
147+
repository: peercoin/packaging
22148

149+
- uses: actions/download-artifact@v2
150+
with:
151+
path: docker
152+
153+
- name: Place artifacts
154+
working-directory: docker
155+
run: |
156+
mkdir -p linux/amd64 linux/arm64 linux/arm/v7
157+
mv peercoin-*-armhf-linux/peercoin-*-arm-linux-gnueabihf.tar.gz linux/arm/v7/
158+
mv peercoin-*-aarch64-linux/peercoin-*-aarch64-linux-gnu.tar.gz linux/arm64/
159+
mv peercoin-*-x86_64-linux/peercoin-*-x86_64-linux-gnu.tar.gz linux/amd64/
160+
161+
- uses: crazy-max/ghaction-docker-buildx@v1
162+
163+
- uses: docker/login-action@v1
164+
with:
165+
registry: ghcr.io
166+
username: ${{ github.actor }}
167+
password: ${{ github.token }}
168+
169+
- name: Prepare docker build
170+
id: prepare
171+
shell: bash
172+
run: |
173+
PUSH=false
174+
TAG_NAME=blank
175+
if [ $GITHUB_REF == "refs/heads/develop" ]; then
176+
if [ "${{ github.repository }}" == "peercoin/peercoin" ]; then
177+
PUSH=true
178+
fi
179+
TAG_NAME=develop
180+
fi
181+
echo ::set-output name=push::${PUSH}
182+
echo ::set-output name=branch::${TAG_NAME}
183+
184+
- name: Build and push
185+
working-directory: docker
186+
run: |
187+
docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64 \
188+
--output "type=image,push=${{ steps.prepare.outputs.push }}" \
189+
--progress=plain \
190+
--tag ghcr.io/peercoin/peercoin/peercoind:${{ steps.prepare.outputs.branch }} \
191+
.
192+
appimage:
193+
runs-on: ubuntu-latest
194+
container: appimagecrafters/appimage-builder:latest
195+
needs: [binary]
196+
strategy:
197+
matrix:
198+
name:
199+
- armhf
200+
- aarch64
201+
- x86_64
202+
include:
203+
- name: armhf
204+
host: arm-linux-gnueabihf
205+
sources_repo: http://ports.ubuntu.com/ubuntu-ports
206+
apt_arch: armhf
207+
- name: aarch64
208+
host: aarch64-linux-gnu
209+
sources_repo: http://ports.ubuntu.com/ubuntu-ports
210+
apt_arch: arm64
211+
- name: x86_64
212+
host: x86_64-linux-gnu
213+
sources_repo: http://archive.ubuntu.com/ubuntu
214+
apt_arch: amd64
215+
steps:
216+
- uses: actions/checkout@v2
217+
with:
218+
repository: peercoin/packaging
219+
220+
- uses: actions/download-artifact@v2
221+
with:
222+
path: appimage
223+
224+
- name: Set up environment
225+
working-directory: appimage
226+
run: |
227+
apt-get -qq update
228+
apt-get install -qqy git wget ca-certificates
229+
pip3 install --upgrade git+https://www.opencode.net/azubieta/appimagecraft.git
230+
231+
- name: Get short SHA
232+
id: slug
233+
run: echo "::set-output name=sha8::$(echo ${{ github.sha }} | cut -c1-8)"
234+
235+
- name: Build AppImage
236+
working-directory: appimage
237+
run: |
238+
tar xzf peercoin-${{ steps.slug.outputs.sha8 }}-${{ matrix.name }}-linux/peercoin-*-${{ matrix.host }}.tar.gz -C AppDir --strip-components=1
239+
VERSION=${{ steps.slug.outputs.sha8 }} SOURCES_REPO=${{ matrix.sources_repo }} APT_ARCH=${{ matrix.apt_arch }} BUILD_ARCH=${{ matrix.name }} appimage-builder --skip-tests
23240
241+
- uses: actions/upload-artifact@v2
242+
with:
243+
name: peercoin-appimage-${{ steps.slug.outputs.sha8 }}-${{ matrix.name }}
244+
path: |
245+
appimage/*.AppImage*
246+
retention-days: 5

.github/workflows/docker.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)