4
4
push :
5
5
branches :
6
6
- main
7
+ tags :
8
+ - ' *-v[0-9]+.[0-9]+.[0-9]+'
7
9
workflow_dispatch :
8
10
inputs :
9
11
branch :
@@ -22,40 +24,126 @@ jobs:
22
24
packages : write
23
25
id-token : write
24
26
steps :
25
- - name : Determine branch
26
- id : get-branch-name
27
+ - name : Get tag
28
+ id : get-tag
27
29
run : |
28
- if [ "${{ github.event_name }}" == "push" ]; then
29
- branch="main"
30
+ echo "github_ref=$GITHUB_REF"
31
+ if [[ $GITHUB_REF == refs/tags/* ]]; then
32
+ echo "tag=${GITHUB_REF#refs/tags/}"
33
+ echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
30
34
else
31
- branch="${{ inputs.branch }}"
35
+ echo "tag=" >> $GITHUB_OUTPUT
32
36
fi
33
- echo "branch=$branch" >> $GITHUB_OUTPUT
37
+
38
+ - name : Check for release information from tag
39
+ id : check-release
40
+ run : |
41
+ tag="${{ steps.get-tag.outputs.tag }}"
42
+ is_release="false"
43
+
44
+ if [[ $tag =~ ^([a-zA-Z-]+)-v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
45
+ is_release="true"
46
+ crate_name="${BASH_REMATCH[1]}"
47
+ crate_version="${BASH_REMATCH[2]}"
48
+
49
+ echo "Is release: $is_release"
50
+ echo "Crate Name: $crate_name"
51
+ echo "Crate Version: $crate_version"
52
+
53
+ echo "is-release=$is_release" >> $GITHUB_OUTPUT
54
+ echo "crate-name=$crate_name" >> $GITHUB_OUTPUT
55
+ echo "crate-version=$crate_version" >> $GITHUB_OUTPUT
56
+ else
57
+ echo "Is release: $is_release"
58
+ echo "Not a release tag. Skipping crate name and version extraction."
59
+ echo "is-release=$is_release" >> $GITHUB_OUTPUT
60
+ fi
61
+
62
+
63
+ - name : Determine checkout ref
64
+ id : get-checkout-ref
65
+ run : |
66
+ if [[ $GITHUB_REF == refs/tags/* ]]; then
67
+ echo "ref=$GITHUB_REF" >> $GITHUB_OUTPUT
68
+ elif [ "${{ github.event_name }}" == "push" ]; then
69
+ echo "ref=main" >> $GITHUB_OUTPUT
70
+ else
71
+ echo "ref=${{ inputs.branch }}" >> $GITHUB_OUTPUT
72
+ fi
73
+
34
74
35
75
- name : Checkout code
36
76
uses : actions/checkout@v4
37
77
with :
38
78
fetch-depth : " 0"
39
79
path : axelar-amplifier
40
80
submodules : recursive
41
- ref : ${{ steps.get-branch-name.outputs.branch }}
81
+ ref : ${{ steps.get-checkout-ref.outputs.ref }}
82
+
42
83
43
- - name : Compile amplifier contracts
84
+ - name : Import GPG key
85
+ id : import_gpg
86
+ uses : crazy-max/ghaction-import-gpg@v4
87
+ with :
88
+ gpg_private_key : ${{ secrets.GPG_PRIVATE_KEY }}
89
+ passphrase : ${{ secrets.GPG_PASSPHRASE }}
90
+
91
+
92
+ - name : Compile all amplifier contracts
44
93
id : compile-contracts
45
94
run : |
46
95
cd axelar-amplifier
47
96
docker run --rm -v "$(pwd)":/code \
48
97
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
49
98
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
50
99
cosmwasm/optimizer:0.16.0
51
-
100
+
52
101
commit_hash=$(git rev-parse --short HEAD)
53
102
cd ..
54
103
mkdir -p ./artifacts/$commit_hash/
55
104
cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/
56
105
echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT
57
106
107
+
108
+ - name : Prepare and sign release artifacts
109
+ if : steps.check-release.outputs.is-release == 'true'
110
+ id : prepare-release
111
+ run : |
112
+ cd ${{ steps.compile-contracts.outputs.wasm-directory }}
113
+ crate_name="${{ steps.check-release.outputs.crate-name }}"
114
+ crate_version="${{ steps.check-release.outputs.crate-version }}"
115
+ wasm_file=$(find . -name "${crate_name//-/_}.wasm")
116
+ checksum_file=$(find . -name "checksums.txt")
117
+
118
+ if [ -z "$wasm_file" ]; then
119
+ echo "Error: Could not find .wasm file for $crate_name"
120
+ exit 1
121
+ fi
122
+
123
+ mkdir -p "../release-artifacts"
124
+ cp "$wasm_file" "../release-artifacts/${crate_name}.wasm"
125
+ cp "$checksum_file" "../release-artifacts/"
126
+
127
+ gpg --armor --detach-sign ../release-artifacts/${crate_name}.wasm
128
+ gpg --armor --detach-sign ../release-artifacts/checksums.txt
129
+
130
+ echo "release-artifacts-dir=./release-artifacts" >> $GITHUB_OUTPUT
131
+ echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT
132
+
133
+
134
+ - uses : ryand56/r2-upload-action@latest
135
+ if : steps.check-release.outputs.is-release == 'true'
136
+ with :
137
+ r2-account-id : ${{ secrets.R2_ACCOUNT_ID }}
138
+ r2-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID_CF }}
139
+ r2-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }}
140
+ r2-bucket : ${{ secrets.R2_BUCKET }}
141
+ source-dir : ${{ steps.prepare-release.outputs.release-artifacts-dir }}
142
+ destination-dir : ${{ steps.prepare-release.outputs.r2-destination-dir }}
143
+
144
+
58
145
- uses : ryand56/r2-upload-action@latest
146
+ if : steps.check-release.outputs.is-release != 'true'
59
147
with :
60
148
r2-account-id : ${{ secrets.R2_ACCOUNT_ID }}
61
149
r2-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID_CF }}
0 commit comments