Skip to content

Commit 1b56c6c

Browse files
authored
Add release workflow for contract wasms (#17)
* Add release workflow for contract wasms Builds contracts on version tag push and attaches wasm artifacts to a GitHub release. * Add cross-repo E2E trigger on release * Add auto-tag workflow on version bump Reads version from Cargo.toml on push to main and creates a git tag if it doesn't already exist.
1 parent 3b67db1 commit 1b56c6c

2 files changed

Lines changed: 94 additions & 0 deletions

File tree

.github/workflows/auto-tag.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Auto Tag
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "Cargo.toml"
8+
9+
jobs:
10+
tag:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Read version from Cargo.toml
20+
id: version
21+
run: |
22+
VERSION=$(grep -m1 '^version' Cargo.toml | sed 's/.*"\(.*\)"/\1/')
23+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
24+
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
25+
26+
- name: Check if tag exists
27+
id: check
28+
run: |
29+
if git rev-parse "refs/tags/${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
30+
echo "exists=true" >> "$GITHUB_OUTPUT"
31+
else
32+
echo "exists=false" >> "$GITHUB_OUTPUT"
33+
fi
34+
35+
- name: Create tag
36+
if: steps.check.outputs.exists == 'false'
37+
run: |
38+
git tag ${{ steps.version.outputs.tag }}
39+
git push origin ${{ steps.version.outputs.tag }}

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build-and-release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install Rust
17+
uses: dtolnay/rust-toolchain@stable
18+
with:
19+
targets: wasm32v1-none
20+
21+
- name: Cache cargo
22+
uses: actions/cache@v4
23+
with:
24+
path: |
25+
~/.cargo/registry
26+
~/.cargo/git
27+
~/.cargo/bin
28+
target
29+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
30+
31+
- name: Install Stellar CLI
32+
run: cargo install --locked stellar-cli --features opt
33+
34+
- name: Build contracts
35+
run: stellar contract build
36+
37+
- name: Prepare artifacts
38+
run: |
39+
mkdir -p artifacts
40+
cp target/wasm32v1-none/release/channel_auth_contract.wasm artifacts/
41+
cp target/wasm32v1-none/release/privacy_channel.wasm artifacts/
42+
43+
- name: Create release
44+
uses: softprops/action-gh-release@v2
45+
with:
46+
files: artifacts/*.wasm
47+
generate_release_notes: true
48+
49+
- name: Trigger E2E tests
50+
uses: peter-evans/repository-dispatch@v3
51+
with:
52+
token: ${{ secrets.E2E_TRIGGER_TOKEN }}
53+
repository: ${{ github.repository_owner }}/local-dev
54+
event-type: module-release
55+
client-payload: '{"module": "soroban-core", "version": "${{ github.ref_name }}"}'

0 commit comments

Comments
 (0)