Skip to content

Commit 65d7297

Browse files
author
yihuang
authored
Problem: cross-compiling don't work (#874)
* Problem: cross-compiling don't work Solution: - remove some obstacles, now it at least works for linux. - darwin still need some fixes in nixpkgs side, see: NixOS/nixpkgs#216431 update release flow upload build result to check Problem: windows build in CI fails (#868) * Problem: windows build in CI fails Solution: - patch grocksdb to remove binding of not exported apis - add workflow to test windows build in PR * use crypto-org-chain fork update gomod2nix fix mac cross compiling fix cross-compiling tarball windows bundle script support windows tarball add unified job for cross-compiling grocksdb link options configure differnt build machine for different hosts don't fail fast simplify don't run unittest in nix build update grocksdb dependency tidy fix grocksdb grocksdb upstream repo * Update app/versiondb_placeholder.go Signed-off-by: yihuang <huang@crypto.com> * update nixpkgs * temp * cleanup and remove goreleaser * use buildPackages.go * fix workflow * fix workflow * Update scripts/release.sh Signed-off-by: yihuang <huang@crypto.com> * fix default name of GITHUB_REF_NAME * fix ref name * escape ref name to be used as file name * fix escape * fix arm64 * fix darwin cross-compiling * fix darwin cross-compiling --------- Signed-off-by: yihuang <huang@crypto.com>
1 parent bbb8150 commit 65d7297

File tree

17 files changed

+300
-2357
lines changed

17 files changed

+300
-2357
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,40 @@ concurrency:
1313

1414
jobs:
1515
build:
16-
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ubuntu-latest, macos-latest]
20+
runs-on: ${{ matrix.os }}
1721
steps:
1822
- uses: actions/checkout@v3
1923
- uses: cachix/install-nix-action@v18
2024
with:
2125
nix_path: nixpkgs=channel:nixos-22.11
2226
extra_nix_config: |
2327
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
24-
- uses: actions/setup-go@v3
25-
with:
26-
go-version: 1.20.0
2728
- id: changed-files
2829
uses: tj-actions/changed-files@v34
2930
with:
3031
files: |
3132
*.go
3233
*.mod
3334
*.sum
34-
- run: |
35-
# without rocksdb
36-
make build
37-
# with rocksdb and enable versiondb
38-
nix profile install nixpkgs#rocksdb
39-
export PKG_CONFIG_PATH=$HOME/.nix-profile/lib/pkgconfig
40-
export CGO_CFLAGS="$(pkg-config --cflags rocksdb)" CGO_LDFLAGS="$(pkg-config --libs rocksdb)"
41-
COSMOS_BUILD_OPTIONS=rocksdb make build
35+
- uses: cachix/cachix-action@v12
4236
if: steps.changed-files.outputs.any_changed == 'true'
37+
with:
38+
name: cronos
39+
# github don't pass secrets for pull request from fork repos,
40+
# in that case the push is disabled naturally.
41+
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
42+
- name: Run build
43+
run: ./scripts/release.sh
44+
if: steps.changed-files.outputs.any_changed == 'true'
45+
- uses: actions/upload-artifact@v3
46+
with:
47+
name: "cronosd-tarball-${{ matrix.os }}"
48+
path: "*.tar.gz"
49+
if-no-files-found: ignore
4350

4451
unittest:
4552
runs-on: ubuntu-latest
@@ -116,7 +123,7 @@ jobs:
116123
set +e
117124
(git diff --no-ext-diff --exit-code)
118125
echo "name=changed::$?" >> $GITHUB_OUTPUT
119-
- uses: actions/upload-artifact@v2
126+
- uses: actions/upload-artifact@v3
120127
if: steps.changes.outputs.changed == 1
121128
with:
122129
name: gomod2nix.toml
@@ -159,7 +166,7 @@ jobs:
159166
set +e
160167
(git diff --no-ext-diff --exit-code)
161168
echo "name=changed::$?" >> $GITHUB_OUTPUT
162-
- uses: actions/upload-artifact@v2
169+
- uses: actions/upload-artifact@v3
163170
if: steps.changes.outputs.changed == 1
164171
with:
165172
name: contracts_out

.github/workflows/release.yml

Lines changed: 37 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -9,193 +9,91 @@ permissions:
99
contents: write
1010

1111
jobs:
12-
goreleaser:
12+
release:
1313
runs-on: ubuntu-latest
1414
environment: release
15-
steps:
16-
- uses: actions/checkout@v3
17-
with:
18-
submodules: true
19-
- name: setup release environment
20-
env:
21-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22-
run: |-
23-
echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env
24-
- name: build and upload goreleaser binaries
25-
run: make release
26-
27-
x86_64:
28-
strategy:
29-
matrix:
30-
os: [ubuntu-latest, macos-latest]
31-
needs: ["goreleaser"]
32-
runs-on: ${{ matrix.os }}
33-
environment: release
3415
steps:
3516
- uses: actions/checkout@v3
3617
- uses: cachix/install-nix-action@v18
3718
with:
3819
nix_path: nixpkgs=channel:nixos-22.11
3920
extra_nix_config: |
4021
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
41-
- uses: apple-actions/import-codesign-certs@v1
42-
if: matrix.os == 'macos-latest'
43-
with:
44-
p12-file-base64: ${{ secrets.MAC_CODE_SIGN_CERT }}
45-
p12-password: ${{ secrets.MAC_CODE_SIGN_CERT_PASS }}
4622
- uses: cachix/cachix-action@v12
4723
with:
4824
name: cronos
4925
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
50-
- name: build linux/mac x86_64 binaries
51-
env:
52-
MAC_CODE_API_KEY: ${{ secrets.MAC_CODE_API_KEY }}
53-
MAC_CODE_API_KEY_ID: ${{ secrets.MAC_CODE_API_KEY_ID }}
54-
MAC_CODE_API_ISSUER_ID: ${{ secrets.MAC_CODE_API_ISSUER_ID }}
55-
MAC_CODE_API_DEVELOPER_ID: ${{ secrets.MAC_CODE_API_DEVELOPER_ID }}
56-
run: |
57-
PLATFORM="$(uname -s)_x86_64"
58-
BUILD_TYPE="tarball"
59-
FLAKE="github:${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}"
60-
61-
build() {
62-
NETWORK=$1
63-
nix build -L "${FLAKE}#cronosd${NETWORK}-${BUILD_TYPE}"
64-
OUTPUT="cronos_${GITHUB_REF_NAME:1}${NETWORK}_${PLATFORM}"
65-
if [ "$(uname -s)" == "Darwin" ]; then
66-
./scripts/codesign_macos.sh ./result
67-
mv signed.tar.gz "$OUTPUT.tar.gz"
68-
else
69-
cp result "$OUTPUT.tar.gz"
70-
fi
71-
}
72-
73-
build ""
74-
build "-testnet"
7526

27+
- name: build binaries
28+
run: |
29+
# install sha256sum
7630
nix-env -i coreutils -f '<nixpkgs>'
77-
sha256sum *.tar.gz > "checksums-$PLATFORM.txt"
7831
32+
# build binaries
33+
./scripts/release.sh
34+
35+
# update checksum and upload
36+
sha256sum *.tar.gz > "checksums.txt"
7937
echo 'FILES<<EOF' >> $GITHUB_ENV
8038
ls -1 *.tar.gz >> $GITHUB_ENV
8139
ls -1 checksums-*.txt >> $GITHUB_ENV
8240
echo 'EOF' >> $GITHUB_ENV
8341
cat $GITHUB_ENV
84-
- name: upload linux/mac x86_64 binaries
42+
- name: upload binaries
8543
uses: softprops/action-gh-release@v1
8644
with:
8745
draft: true
8846
files: "${{ env.FILES }}"
8947

90-
aarch64-linux:
91-
needs: ["goreleaser"]
92-
runs-on: ubuntu-latest
48+
release-macos:
49+
# runs sequentially to avoid creating duplicated release
50+
needs: ["release"]
51+
runs-on: macos-latest
9352
environment: release
9453
steps:
54+
- uses: actions/checkout@v3
9555
- uses: cachix/install-nix-action@v18
9656
with:
9757
nix_path: nixpkgs=channel:nixos-22.11
9858
extra_nix_config: |
9959
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
100-
- run: |
101-
DEBIAN_FRONTEND=noninteractive
102-
sudo apt-get update -q -y && sudo apt-get install -q -y qemu-system-aarch64 qemu-efi binfmt-support qemu-user-static
103-
mkdir -p ~/.config/nix
104-
sudo bash -c "echo system-features = aarch64-linux arm-linux >> /etc/nix/nix.conf"
60+
- uses: apple-actions/import-codesign-certs@v1
61+
with:
62+
p12-file-base64: ${{ secrets.MAC_CODE_SIGN_CERT }}
63+
p12-password: ${{ secrets.MAC_CODE_SIGN_CERT_PASS }}
10564
- uses: cachix/cachix-action@v12
10665
with:
10766
name: cronos
10867
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
109-
- name: build linux arm64 binaries
68+
- name: build binaries
11069
env:
111-
PLATFORM: Linux_arm64
70+
MAC_CODE_API_KEY: ${{ secrets.MAC_CODE_API_KEY }}
71+
MAC_CODE_API_KEY_ID: ${{ secrets.MAC_CODE_API_KEY_ID }}
72+
MAC_CODE_API_ISSUER_ID: ${{ secrets.MAC_CODE_API_ISSUER_ID }}
73+
MAC_CODE_API_DEVELOPER_ID: ${{ secrets.MAC_CODE_API_DEVELOPER_ID }}
11274
run: |
113-
BUILD_TYPE="tarball"
114-
FLAKE="github:${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}"
115-
116-
nix build -L --extra-platforms aarch64-linux ${FLAKE}#packages.aarch64-linux.cronosd-$BUILD_TYPE
117-
cp result cronos_${GITHUB_REF_NAME:1}_${PLATFORM}.tar.gz
75+
# install sha256sum
76+
nix-env -i coreutils -f '<nixpkgs>'
11877
119-
nix build -L --extra-platforms aarch64-linux ${FLAKE}#packages.aarch64-linux.cronosd-testnet-$BUILD_TYPE
120-
cp result cronos_${GITHUB_REF_NAME:1}-testnet_${PLATFORM}.tar.gz
78+
# build binaries
79+
./scripts/release.sh
12180
122-
sha256sum *.tar.gz > checksums-$PLATFORM.txt
81+
# codesign
82+
for tarball in *.tar.gz;
83+
do
84+
./scripts/codesign_macos.sh $tarball
85+
mv signed.tar.gz $tarball
86+
done
12387
88+
# update checksum and upload
89+
sha256sum *.tar.gz > "checksums-macos.txt"
12490
echo 'FILES<<EOF' >> $GITHUB_ENV
12591
ls -1 *.tar.gz >> $GITHUB_ENV
12692
ls -1 checksums-*.txt >> $GITHUB_ENV
12793
echo 'EOF' >> $GITHUB_ENV
12894
cat $GITHUB_ENV
129-
- name: upload linux arm64 binaries
95+
- name: upload binaries
13096
uses: softprops/action-gh-release@v1
13197
with:
13298
draft: true
13399
files: "${{ env.FILES }}"
134-
135-
x86_64-windows:
136-
needs: ["goreleaser"]
137-
runs-on: windows-latest
138-
environment: release
139-
steps:
140-
- name: get source
141-
uses: actions/checkout@v3
142-
with:
143-
submodules: true
144-
- name: setup msys2
145-
uses: msys2/setup-msys2@v2
146-
with:
147-
msystem: MINGW64
148-
update: false
149-
install: git msys2-devel base-devel mingw-w64-x86_64-gcc mingw-w64-x86_64-rocksdb mingw-w64-x86_64-go mingw-w64-x86_64-jq mingw-w64-x86_64-dlfcn
150-
- name: get rocksdb & build
151-
env:
152-
PLATFORM: Windows_x86_64
153-
shell: msys2 {0}
154-
run: |
155-
uname -a
156-
export GOROOT=/mingw64/lib/go
157-
export GOPATH=$HOME/go
158-
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
159-
export CGO_CFLAGS="-I/mingw64/include/rocksdb"
160-
export CGO_LDFLAGS="-L/mingw64/lib -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd"
161-
echo $PATH
162-
go version
163-
wget https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-rocksdb-6.26.1-1-any.pkg.tar.zst
164-
pacman -U mingw-w64-x86_64-rocksdb-6.26.1-1-any.pkg.tar.zst --noconfirm
165-
COSMOS_BUILD_OPTIONS=rocksdb make build
166-
ls -la ./build/
167-
mv ./build/cronosd ./build/cronosd.exe
168-
cp /mingw64/bin/libbz2-1.dll ./build
169-
cp /mingw64/bin/libgcc_s_seh-1.dll ./build
170-
cp /mingw64/bin/liblz4.dll ./build
171-
cp /mingw64/bin/librocksdb.dll ./build
172-
cp /mingw64/bin/libsnappy.dll ./build
173-
cp /mingw64/bin/libstdc++-6.dll ./build
174-
cp /mingw64/bin/libwinpthread-1.dll ./build
175-
cp /mingw64/bin/libzstd.dll ./build
176-
cp /mingw64/bin/zlib1.dll ./build
177-
cd ./build
178-
tar cvfz ../cronos.tar.gz *
179-
cd ..
180-
mv ./cronos.tar.gz cronos_${GITHUB_REF_NAME:1}_${PLATFORM}.tar.gz
181-
NETWORK=testnet COSMOS_BUILD_OPTIONS=rocksdb make build
182-
mv ./build/cronosd ./build/cronosd.exe
183-
cd ./build
184-
tar cvfz ../cronos.tar.gz *
185-
cd ..
186-
mv ./cronos.tar.gz cronos_${GITHUB_REF_NAME:1}-testnet_${PLATFORM}.tar.gz
187-
ls -la cronos_*.tar.gz
188-
sha256sum cronos_*.tar.gz > "checksums-$PLATFORM.txt"
189-
echo "OK"
190-
echo 'FILES<<EOF' >> $GITHUB_ENV
191-
ls -1 *.tar.gz >> $GITHUB_ENV
192-
ls -1 checksums-*.txt >> $GITHUB_ENV
193-
echo 'EOF' >> $GITHUB_ENV
194-
cat $GITHUB_ENV
195-
- name: upload
196-
env:
197-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
198-
uses: softprops/action-gh-release@v1
199-
with:
200-
draft: true
201-
files: "${{ env.FILES }}"

.github/workflows/sims.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jobs:
120120
echo ${{ job.status }} > status_build.txt
121121
- name: Upload file status_build.txt as an artifact
122122
if: github.event_name == 'issue_comment'
123-
uses: actions/upload-artifact@v1
123+
uses: actions/upload-artifact@v3
124124
with:
125125
name: pass_status_build
126126
path: status_build.txt
@@ -146,7 +146,7 @@ jobs:
146146
echo ${{ job.status }} > status_install.txt
147147
- name: Upload file status_install.txt as an artifact
148148
if: github.event_name == 'issue_comment'
149-
uses: actions/upload-artifact@v1
149+
uses: actions/upload-artifact@v3
150150
with:
151151
name: pass_status_install
152152
path: status_install.txt
@@ -201,7 +201,7 @@ jobs:
201201
echo ${{ job.status }} > status_sim1.txt
202202
- name: Upload file status_sim1.txt as an artifact
203203
if: github.event_name == 'issue_comment'
204-
uses: actions/upload-artifact@v1
204+
uses: actions/upload-artifact@v3
205205
with:
206206
name: pass_status_sim1
207207
path: status_sim1.txt
@@ -256,7 +256,7 @@ jobs:
256256
echo ${{ job.status }} > status_sim2.txt
257257
- name: Upload file status_sim2.txt as an artifact
258258
if: github.event_name == 'issue_comment'
259-
uses: actions/upload-artifact@v1
259+
uses: actions/upload-artifact@v3
260260
with:
261261
name: pass_status_sim2
262262
path: status_sim2.txt
@@ -311,7 +311,7 @@ jobs:
311311
echo ${{ job.status }} > status_sim3.txt
312312
- name: Upload file status_sim3.txt as an artifact
313313
if: github.event_name == 'issue_comment'
314-
uses: actions/upload-artifact@v1
314+
uses: actions/upload-artifact@v3
315315
with:
316316
name: pass_status_sim3
317317
path: status_sim3.txt
@@ -366,7 +366,7 @@ jobs:
366366
echo ${{ job.status }} > status_sim4.txt
367367
- name: Upload file status_sim4.txt as an artifact
368368
if: github.event_name == 'issue_comment'
369-
uses: actions/upload-artifact@v1
369+
uses: actions/upload-artifact@v3
370370
with:
371371
name: pass_status_sim4
372372
path: status_sim4.txt

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- name: 'Tar debug files'
4949
if: failure()
5050
run: tar cfz debug_files.tar.gz -C "${TMPDIR-/tmp}/pytest-of-runner" .
51-
- uses: actions/upload-artifact@v2
51+
- uses: actions/upload-artifact@v3
5252
if: failure()
5353
with:
5454
name: debug-files

0 commit comments

Comments
 (0)