-
Notifications
You must be signed in to change notification settings - Fork 25
115 lines (95 loc) · 3.98 KB
/
build-contracts-and-push-to-r2.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
name: Amplifier wasm contracts - Upload wasm binaries to Cloudflare R2 bucket
on:
push:
branches:
- main
- fix/push-releases-to-r2
workflow_dispatch:
inputs:
branch:
description: Github branch to checkout for compilation
required: true
default: main
type: string
jobs:
compile-and-upload:
name: Compile contracts and push to R2
runs-on: ubuntu-22.04
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Check for release information if present
id: check-release
run: |
commit_message="${{ github.event.head_commit.message }}"
is_release=${{ contains(github.event.head_commit.message, 'chore: release') }}
echo "Does commit belong to a release: $is_release"
echo "is-release=$is_release" >> $GITHUB_OUTPUT
if [ "$is_release" = "true" ]; then
release_info=$(echo "$commit_message" | sed -n 's/chore: release \(.*\) \(.*\)/\1 \2/p')
crate_name=$(echo $release_info | cut -d' ' -f1)
version=$(echo $release_info | cut -d' ' -f2)
echo "Crate Name: $crate_name"
echo "Version: $version"
echo "crate-name=$crate_name" >> $GITHUB_OUTPUT
echo "crate-version=$version" >> $GITHUB_OUTPUT
else
echo "Not a release commit. Skipping crate name and version extraction."
fi
- name: Determine branch
id: get-branch-name
run: |
if [ "${{ github.event_name }}" == "push" ]; then
branch="main"
else
branch="${{ inputs.branch }}"
fi
echo "branch=$branch" >> $GITHUB_OUTPUT
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: "0"
path: axelar-amplifier
submodules: recursive
ref: ${{ steps.get-branch-name.outputs.branch }}
- name: Compile amplifier contracts
id: compile-contracts
run: |
cd axelar-amplifier
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.16.0
commit_hash=$(git rev-parse --short HEAD)
cd ..
mkdir -p ./artifacts/$commit_hash/
cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/
echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT
- name: Prepare release artifacts
if: steps.check-release.outputs.is-release == 'true'
id: prepare-release
run: |
cd ${{ steps.compile-contracts.outputs.wasm-directory }}
crate_name="${{ steps.check-release.outputs.crate-name }}"
crate_version="${{ steps.check-release.outputs.crate-version }}"
wasm_file=$(find . -name "${crate_name//-/_}.wasm")
if [ -z "$wasm_file" ]; then
echo "Error: Could not find .wasm file for $crate_name"
exit 1
fi
mkdir -p "../release-artifacts"
cp "$wasm_file" "../release-artifacts/${crate_name}.wasm"
cp checksums.txt "../release-artifacts/"
echo "release-artifacts-dir=./artifacts/release-artifacts" >> $GITHUB_OUTPUT
echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT
ls -la ../release-artifacts/
# - uses: ryand56/r2-upload-action@latest
# with:
# r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
# r2-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CF }}
# r2-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }}
# r2-bucket: ${{ secrets.R2_BUCKET }}
# source-dir: ${{ steps.compile-contracts.outputs.wasm-directory }}
# destination-dir: ./pre-releases/ampd/contracts/