Skip to content

Commit a455e57

Browse files
authored
ci: add release workflow (#572)
* ci: add release workflow * ci: use PAT * ci: fix release assets upload issue * ci: rename wasm file with version on filename * ci: add changelog in release * ci: resolve conflicts * ci: resolve conflicts * ci: resolve conflicts * ci: check version bump label * ci: update github-action-required-labels action to latest * ci: add version bump * chore: update submodule HEAD * ci: add release template * ci: add auto PR labeler * ci: update labeler trigger * ci: update labeler trigger * ci: fix syntax error * ci: fix syntax error * ci: debug * Update labeler.yml * ci: debug * ci: add pr-number * ci: syntax error * ci: debug * ci: debug * ci: add glob * ci: debug * ci: add pr-number * ci: add pr-number * ci: update labeler * ci: run on push * ci: get pr number * ci: get pr number * ci: debug * ci: debug * ci: debug * ci: debug * ci: cleanup * ci: check version bump * ci: debug * ci: remove automatic version bump * ci:remove auto labeler
1 parent e6d5089 commit a455e57

File tree

9 files changed

+219
-2
lines changed

9 files changed

+219
-2
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ version: <log entry>
2323
- [ ] I have run the unit tests
2424
- [ ] I only have one commit (if not, squash them into one commit).
2525
- [ ] I have a descriptive commit message that adheres to the [commit message guidelines](https://github.com/icon-project/community/blob/main/guidelines/technical/software-development-guidelines.md#commit-messages)
26+
- [ ] I have added version bump label on PR.
2627

2728
> Please review the [CONTRIBUTING.md](/CONTRIBUTING.md) file for detailed contributing guidelines.

.github/release.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# .github/release.yml
2+
3+
changelog:
4+
exclude:
5+
labels:
6+
- cicd
7+
- scripts
8+
- test
9+
categories:
10+
- title: Breaking Changes 🛠
11+
labels:
12+
- Major
13+
- breaking-change
14+
- title: New Features 🎉
15+
labels:
16+
- Minor
17+
- enhancement
18+
- Feature
19+
20+
- title: Bug Fixes 🎉
21+
labels:
22+
- Patch
23+
- bug
24+
- title: Other Changes
25+
labels:
26+
- "*"

.github/workflows/release.yaml

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Pre-release
2+
on:
3+
push:
4+
tags:
5+
- 'v*.*.*-alpha.*'
6+
permissions:
7+
contents: write
8+
packages: write
9+
repository-projects: write
10+
11+
jobs:
12+
build_javascore:
13+
name: Build Javascore Contracts
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
with:
19+
submodules: true
20+
21+
- name: Build Javascore Contracts
22+
working-directory: contracts/javascore
23+
run: |
24+
./gradlew clean build
25+
./gradlew optimizedJar
26+
./gradlew zipOutputOptimizedJars
27+
- name: Upload Artifacts
28+
uses: actions/upload-artifact@v3
29+
with:
30+
name: javascore-contracts
31+
path: ./contracts/javascore/build/javascore-contracts.zip
32+
build_wasm:
33+
name: Build Cosmwasm Contracts
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout sources
37+
uses: actions/checkout@v3
38+
with:
39+
submodules: true
40+
- name: Install stable toolchain
41+
uses: actions-rs/toolchain@v1
42+
with:
43+
toolchain: 1.69.0
44+
target: wasm32-unknown-unknown
45+
override: true
46+
profile: minimal
47+
- name: Cache Rust dependencies
48+
uses: Swatinem/rust-cache@v2
49+
- name: Compile WASM
50+
run: |
51+
rustup component add rustfmt --toolchain 1.69.0-x86_64-unknown-linux-gnu
52+
rustup component add clippy --toolchain 1.69.0-x86_64-unknown-linux-gnu
53+
bash ./scripts/optimize-cosmwasm.sh
54+
cd artifacts/archway && zip -r ../../cosmwasm-contracts.zip . -j
55+
56+
- name: Upload Artifacts
57+
uses: actions/upload-artifact@v3
58+
with:
59+
name: cosmwasm-contracts
60+
path: cosmwasm-contracts.zip
61+
release:
62+
name: Release and Publish
63+
runs-on: ubuntu-latest
64+
needs:
65+
- build_javascore
66+
- build_wasm
67+
steps:
68+
- name: Initialize variables
69+
id: vars
70+
run: |
71+
echo «::set-output name=date::$(date +'%Y-%m-%d')»
72+
echo «::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)»
73+
- name: Download Javascore Artifacts
74+
uses: actions/download-artifact@v2
75+
with:
76+
name: javascore-contracts
77+
path: javascore-contracts
78+
79+
- name: Download Cosmwasm Artifacts
80+
uses: actions/download-artifact@v2
81+
with:
82+
name: cosmwasm-contracts
83+
path: cosmwasm-contracts
84+
85+
- name: Unzip Javascore Artifacts
86+
run: unzip javascore-contracts/javascore-contracts.zip -d javascore-contracts && rm -rf javascore-contracts/javascore-contracts.zip
87+
88+
- name: Unzip Cosmwasm Artifacts
89+
run: unzip cosmwasm-contracts/cosmwasm-contracts.zip -d cosmwasm-contracts && rm -rf cosmwasm-contracts/cosmwasm-contracts.zip
90+
91+
- name: Changelog
92+
uses: scottbrenner/generate-changelog-action@master
93+
id: Changelog
94+
env:
95+
REPO: ${{ github.repository }}
96+
97+
- name: Create Release
98+
id: create_release
99+
uses: actions/create-release@v1
100+
env:
101+
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
102+
with:
103+
tag_name: ${{ github.ref }}
104+
release_name: Prerelease ${{ github.ref }}
105+
body: |
106+
${{ steps.Changelog.outputs.changelog }}
107+
draft: false
108+
prerelease: true
109+
110+
- name: Upload Javascore contracts to release
111+
uses: svenstaro/upload-release-action@v2
112+
with:
113+
repo_token: ${{ secrets.GITHUB_TOKEN }}
114+
file: ./javascore-contracts/*
115+
tag: ${{ github.ref }}
116+
overwrite: true
117+
file_glob: true
118+
119+
- name: Upload Cosmwasm contracts to release
120+
uses: svenstaro/upload-release-action@v2
121+
with:
122+
repo_token: ${{ secrets.GITHUB_TOKEN }}
123+
file: ./cosmwasm-contracts/*
124+
tag: ${{ github.ref }}
125+
overwrite: true
126+
file_glob: true

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
| [Java](./contracts/javascore) | [![Java Cov][java-cov-badge]][java-cov-link] | [![Java Test][java-test-badge]][java-test-link] |
99
| [Rust](./contracts/cosmwasm-vm) | [![Rust Cov][rust-cov-badge]][rust-cov-link] | [![Rust Test][rust-test-badge]][rust-test-link] |
1010

11+
1112
[java-cov-link]: https://app.codecov.io/gh/icon-project/IBC-Integration/tree/main/contracts/javascore
1213

1314
[rust-cov-link]: https://app.codecov.io/gh/icon-project/IBC-Integration/tree/main/contracts/cosmwasm-vm
@@ -213,4 +214,4 @@ If you need assistance, have questions, or want to collaborate on this project,
213214

214215
---
215216

216-
Thank you for your interest in the IBC Integration for ICON Project. We look forward to your contributions and the positive impact they will bring to the ICON blockchain and its interoperability capabilities!
217+
Thank you for your interest in the IBC Integration for ICON Project. We look forward to your contributions and the positive impact they will bring to the ICON blockchain and its interoperability capabilities!

contracts/javascore/build.gradle

+33
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,36 @@ gradle.taskGraph.whenReady { taskGraph ->
9191
}
9292
}
9393
}
94+
95+
task printOptimizedJarOutputFiles {
96+
doLast {
97+
subprojects.each { subproject ->
98+
def optimizedJarOutputFiles = subproject.tasks.optimizedJar.outputs.files
99+
println "Optimized JAR files for subproject '${subproject.name}':"
100+
optimizedJarOutputFiles.each { file ->
101+
println " ${file}"
102+
}
103+
}
104+
}
105+
}
106+
107+
task collectOptimizedJars(type: Copy) {
108+
from subprojects.collect { subproject ->
109+
subproject.fileTree('build/libs') {
110+
include '**/*-optimized.jar'
111+
}
112+
}
113+
into "$buildDir/output-jars"
114+
}
115+
116+
task zipOutputOptimizedJars(type: Zip) {
117+
dependsOn collectOptimizedJars
118+
from("$buildDir/output-jars") {
119+
include '**/*-optimized.jar'
120+
}
121+
archiveFileName = "javascore-contracts.zip"
122+
destinationDirectory = file("$buildDir")
123+
}
124+
125+
126+

contracts/javascore/ibc/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ optimizedJar {
5555
}
5656
}
5757

58-
5958
deployJar {
6059
endpoints {
6160
berlin {

contracts/javascore/modules/mockapp/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ optimizedJar {
5151
}
5252
}
5353

54+
5455
deployJar {
5556
endpoints {
5657
berlin {

contracts/javascore/xcall-connection/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ optimizedJar {
3030
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
3131
}
3232
}
33+
3334
deployJar {
3435
endpoints {
3536
berlin {

scripts/optimize-cosmwasm.sh

+29
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ RUSTC_VERS="1.69.0"
99

1010
MAX_WASM_SIZE=800 # 800 KB
1111

12+
PROJECTS=("cw-common" "cw-ibc-core" "cw-icon-light-client" "cw-integration" "cw-mock-ibc-core" "cw-xcall-ibc-connection")
13+
14+
1215
# Install wasm-opt binary
1316
if ! which wasm-opt; then
1417
curl -OL $BINARYEN_DWN
@@ -49,6 +52,32 @@ cosmwasm-check artifacts/archway/cw_icon_light_client.wasm
4952
cosmwasm-check artifacts/archway/cw_xcall_ibc_connection.wasm
5053

5154

55+
# Update version
56+
get_version() {
57+
local cargo_toml="contracts/cosmwasm-vm/$1/Cargo.toml"
58+
grep -m 1 "version" "$cargo_toml" | awk -F '"' '{print $2}'
59+
}
60+
61+
# Rename filename with version in it
62+
rename_wasm_with_version() {
63+
local project_path="$1"
64+
local version=$(get_version "$project_path")
65+
local wasm_file="artifacts/archway/${project_path//-/_}.wasm"
66+
67+
if [[ -f "$wasm_file" ]]; then
68+
mv "$wasm_file" "${wasm_file%.wasm}_${version}.wasm"
69+
echo "Renamed: ${wasm_file} -> ${wasm_file%.wasm}_${version}.wasm"
70+
else
71+
echo "Error: Wasm file not found: $wasm_file"
72+
fi
73+
}
74+
75+
# Loop through each project and rename wasm files
76+
for project in "${PROJECTS[@]}"; do
77+
rename_wasm_with_version "$project"
78+
done
79+
80+
5281
# validate size
5382
echo "Check if size of wasm file exceeds $MAX_WASM_SIZE kilobytes..."
5483
for file in artifacts/archway/*.wasm

0 commit comments

Comments
 (0)