-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (146 loc) · 5.54 KB
/
build_binary_nop_x86_64.yaml
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Build and Upload AirDao Nop Binary
on:
push:
branches:
- main
paths:
- 'Cargo.toml'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Get version from Cargo.toml
id: create_release_tag_name
run: |
version=$(curl -s https://raw.githubusercontent.com/ambrosus/airdao-nop-rs/main/Cargo.toml | grep '^version' | sed -E 's/version = "(.*)"/\1/')
echo "version=$version" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.version }}
release_name: Release v${{ env.version }}
draft: false
prerelease: false
build-latest:
runs-on: ubuntu-latest
needs: create-release
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.81
override: true
components: rustfmt, clippy
target: x86_64-unknown-linux-gnu
- name: Update discordWebhookUrl in config/default.json
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
jq '.discordWebhookUrl = env.DISCORD_WEBHOOK' config/default.json > tmp.json && mv tmp.json config/default.json
- name: Cache cargo registry and git dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install Cosign
run: |
curl -sSL https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64 -o /usr/local/bin/cosign
chmod +x /usr/local/bin/cosign
- name: Build binary
run: |
git submodule update --init --recursive
RUSTFLAGS='-C link-arg=-s' cargo build --release --target x86_64-unknown-linux-gnu
- name: Sign the binary with Cosign
env:
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
COSIGN_PUBLIC_KEY: ${{ secrets.COSIGN_PUBLIC_KEY }}
COSIGN_EXPERIMENTAL: "true"
run: |
echo "${{ secrets.COSIGN_PRIVATE_KEY }}" > cosign.key
echo "${{ secrets.COSIGN_PUBLIC_KEY }}" > airdao-nop-rs.pub
cosign sign-blob --key cosign.key --output-signature airdao-nop-rs.sig --yes target/x86_64-unknown-linux-gnu/release/airdao-nop-rs
- name: Archive
run: |
mkdir airdao-nop-rs
cp target/x86_64-unknown-linux-gnu/release/airdao-nop-rs airdao-nop-rs/
cp -r setup_templates/ config/ airdao-nop-rs/
cp airdao-nop-rs.sig airdao-nop-rs.pub airdao-nop-rs/
cp -r config/ airdao-nop-rs/
cp update.sh airdao-nop-rs/
zip -r airdao-nop-rs-x86-64.zip airdao-nop-rs/
- name: Upload to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./airdao-nop-rs-x86-64.zip
asset_name: airdao-nop-rs-x86-64.zip
asset_content_type: application/zip
build_20_04:
runs-on: ubuntu-20.04
needs: create-release
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.81
override: true
components: rustfmt, clippy
target: x86_64-unknown-linux-gnu
- name: Update discordWebhookUrl in config/default.json
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
jq '.discordWebhookUrl = env.DISCORD_WEBHOOK' config/default.json > tmp.json && mv tmp.json config/default.json
- name: Install Cosign
run: |
curl -sSL https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64 -o /usr/local/bin/cosign
chmod +x /usr/local/bin/cosign
- name: Build binary
run: |
git submodule update --init --recursive
RUSTFLAGS='-C link-arg=-s' cargo build --release --target x86_64-unknown-linux-gnu
- name: Sign the binary with Cosign
env:
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
COSIGN_PUBLIC_KEY: ${{ secrets.COSIGN_PUBLIC_KEY }}
COSIGN_EXPERIMENTAL: "true"
run: |
echo "${{ secrets.COSIGN_PRIVATE_KEY }}" > cosign.key
echo "${{ secrets.COSIGN_PUBLIC_KEY }}" > airdao-nop-rs.pub
cosign sign-blob --key cosign.key --output-signature airdao-nop-rs.sig --yes target/x86_64-unknown-linux-gnu/release/airdao-nop-rs
- name: Archive
run: |
mkdir airdao-nop-rs
cp target/x86_64-unknown-linux-gnu/release/airdao-nop-rs airdao-nop-rs/
cp -r setup_templates/ config/ airdao-nop-rs/
cp airdao-nop-rs.sig airdao-nop-rs.pub airdao-nop-rs/
cp -r config/ airdao-nop-rs/
cp update.sh airdao-nop-rs/
zip -r airdao-nop-rs-x86-64-old.zip airdao-nop-rs/
- name: Upload to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./airdao-nop-rs-x86-64-old.zip
asset_name: airdao-nop-rs-x86-64-old.zip
asset_content_type: application/zip