-
Notifications
You must be signed in to change notification settings - Fork 44
152 lines (126 loc) · 4.28 KB
/
Copy pathrelease.yml
File metadata and controls
152 lines (126 loc) · 4.28 KB
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
name: Release
on:
push:
tags:
- "v*.*.*"
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
# Checkout repository
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
# Setup Node
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
# Install Rust
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
# Add WASM target
- name: Add wasm target
run: rustup target add wasm32-unknown-unknown
# Install Soroban CLI
- name: Install Soroban CLI
run: cargo install soroban-cli --locked
# Extract version from tag
- name: Get version from tag
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
# Generate changelog
- name: Generate changelog
id: changelog
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
PREVIOUS_TAG=$(git rev-list --max-parents=0 HEAD)
fi
echo "## What's Changed" > changelog.md
echo "" >> changelog.md
git log --pretty=format:"* %s (%h)" --no-merges ${PREVIOUS_TAG}..HEAD >> changelog.md
echo "" >> changelog.md
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_TAG}...${{ github.ref }}" >> changelog.md
{
echo 'changelog<<EOF'
cat changelog.md
echo EOF
} >> $GITHUB_OUTPUT
# Build Soroban contracts
- name: Build Rust contracts
working-directory: ./smart-contract
run: cargo build --release --target wasm32-unknown-unknown
# Install frontend dependencies
- name: Install frontend dependencies
working-directory: ./frontend
run: npm ci
# Build frontend
- name: Build frontend
working-directory: ./frontend
run: npm run build
# Package frontend build
- name: Package frontend build
run: |
tar -czf frontend-build.tar.gz -C frontend .next
# Prepare release artifacts
- name: Prepare release artifacts
run: |
mkdir release-artifacts
cp smart-contract/target/wasm32-unknown-unknown/release/*.wasm release-artifacts/
cp frontend-build.tar.gz release-artifacts/
# Zip artifacts
- name: Zip release artifacts
run: |
cd release-artifacts
zip -r ../chainlogistics-${{ steps.get_version.outputs.version }}.zip .
# Create GitHub Release
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ steps.get_version.outputs.version }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
# Upload release asset
- name: Upload release assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./chainlogistics-${{ steps.get_version.outputs.version }}.zip
asset_name: chainlogistics-${{ steps.get_version.outputs.version }}.zip
asset_content_type: application/zip
publish-frontend:
name: Publish Frontend
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: ./frontend
run: npm ci
- name: Build frontend
working-directory: ./frontend
run: npm run build
# Deploy to Vercel
- name: Deploy to Vercel
if: secrets.VERCEL_TOKEN != ''
run: |
npm install -g vercel
cd frontend
vercel --prod --yes --token ${{ secrets.VERCEL_TOKEN }}