-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (97 loc) · 4.14 KB
/
ci.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
name: CI
on:
push:
tags:
- v*
pull_request:
jobs:
linux:
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.17.0
- uses: actions/checkout@v2
- name: go build
run: |
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf
sudo dpkg --add-architecture arm64
sudo dpkg --add-architecture armhf
echo '
deb [arch=arm64,armhf] http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe multiverse
deb [arch=arm64,armhf] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe multiverse
' | sudo tee /etc/apt/sources.list.d/arm.list
sudo apt-get update || true
sudo apt-get install libgmp-dev:arm64 libgmp-dev:armhf
go build -v -ldflags '-w -s -extldflags -static' -o redpwnpow-linux-amd64 ./cmd/redpwnpow
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOARCH=arm64 go build -v -ldflags '-w -s -extldflags -static' -o redpwnpow-linux-arm64 ./cmd/redpwnpow
CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOARCH=arm go build -v -ldflags '-w -s -extldflags -static' -o redpwnpow-linux-armv6l ./cmd/redpwnpow
- uses: actions/upload-artifact@v2
with:
name: linux
path: redpwnpow-linux-*
darwin:
runs-on: macos-11
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.17.0
- uses: actions/checkout@v2
- name: go build
run: |
lib_tmp=$(mktemp -d)
cp /usr/local/opt/gmp/lib/libgmp.a "$lib_tmp"
go build -v -ldflags "-w -s -extldflags -L$lib_tmp" -o redpwnpow-darwin-amd64 ./cmd/redpwnpow
oci_tmp=$(mktemp -d)
ghcr_token=$(curl -f 'https://ghcr.io/token?scope=repository:homebrew/core/gmp:pull' | jq -r .token)
curl -fLH "authorization: Bearer $ghcr_token" https://ghcr.io/v2/homebrew/core/gmp/blobs/sha256:ff4ad8d068ba4c14d146abb454991b6c4f246796ec2538593dc5f04ca7593eec | tar xzC "$oci_tmp" --strip-components 2
lib_tmp=$(mktemp -d)
cp "$oci_tmp/lib/libgmp.a" "$lib_tmp"
sdk_path="$(xcrun --show-sdk-path --sdk macosx)"
CGO_ENABLED=1 GOARCH=arm64 CC="$(xcrun -sdk $sdk_path --find clang) -arch arm64 -isysroot $sdk_path" \
CFLAGS="-isysroot $sdk_path -arch arm64 -I$sdk_path/usr/include" LD_LIBRARY_PATH="$sdk_path/usr/lib" \
CGO_LDFLAGS="-isysroot $sdk_path -arch arm64 -L$lib_tmp" CGO_CFLAGS="-isysroot $sdk_path -arch arm64 -I/usr/local/include" \
go build -v -ldflags '-w -s' -o redpwnpow-darwin-arm64 ./cmd/redpwnpow
lipo -create -output redpwnpow-darwin redpwnpow-darwin-amd64 redpwnpow-darwin-arm64
- uses: actions/upload-artifact@v2
with:
name: darwin
path: redpwnpow-darwin
windows:
runs-on: windows-2022
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.17.0
- uses: msys2/setup-msys2@v2
with:
path-type: inherit
install: mingw-w64-x86_64-gcc mingw-w64-x86_64-gmp
- uses: actions/checkout@v2
- name: go build
shell: msys2 {0}
run: go build -v -ldflags '-w -s -extldflags -static' -o redpwnpow-windows-amd64.exe ./cmd/redpwnpow
- uses: actions/upload-artifact@v2
with:
name: windows
path: redpwnpow-windows-*
release:
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/v')
needs:
- linux
- darwin
- windows
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
path: build
- uses: softprops/action-gh-release@v1
with:
files: build/*/redpwnpow-*
- name: cloudflare
run: >
curl -sSXPUT https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT }}/workers/scripts/pow
-H 'authorization:Bearer ${{ secrets.CLOUDFLARE_TOKEN }}' -Hcontent-type:application/javascript
-d "addEventListener('fetch',e=>e.respondWith(new Response(atob('$(sed "s|VERSION|${GITHUB_REF#refs/tags/}|g" cmd/redpwnpow/run.sh | base64 -w0)'))))"