-
Notifications
You must be signed in to change notification settings - Fork 42
154 lines (133 loc) · 5.39 KB
/
Copy pathrelease.yml
File metadata and controls
154 lines (133 loc) · 5.39 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
153
154
# Release workflow — triggered by a pushed semver tag (vX.Y.Z)
#
# Usage:
# 1. Decide on the next version per semver (MAJOR.MINOR.PATCH).
# 2. Create and push the tag:
# git tag vX.Y.Z
# git push origin vX.Y.Z
# 3. This workflow will build, create a GitHub Release, and
# generate a changelog from conventional-commit messages.
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Fetch all history so git-cliff / auto-changelog can read commits
fetch-depth: 0
- name: Query tag metadata
id: tag
run: |
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
# ── Install toolchains ────────────────────────────────
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: |
package-lock.json
frontend/package-lock.json
backend/package-lock.json
# ── Install dependencies ──────────────────────────────
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
- name: Install backend dependencies
working-directory: backend
run: npm ci
# ── Build all artifacts ───────────────────────────────
- name: Build frontend
working-directory: frontend
run: npm run build
- name: Build backend
working-directory: backend
run: npm run build
- name: Build onchain contracts
working-directory: onchain
run: cargo build --workspace --target wasm32-unknown-unknown --release --locked
- name: Run onchain tests
working-directory: onchain
run: cargo test --workspace --locked
- name: Verify wasm artifacts were produced
working-directory: onchain
run: |
for f in stellar_hunts stellar_hunts_nft stellar_hunts_receiver; do
test -s "target/wasm32-unknown-unknown/release/${f}.wasm" \
|| { echo "::error::missing or empty artifact: ${f}.wasm"; exit 1; }
done
# ── Generate changelog ────────────────────────────────
- name: Generate changelog
id: changelog
run: |
# Build a changelog from conventional-commit messages.
# Groups commits by type (feat, fix, chore, docs, ci, etc.)
# for readable release notes.
PREV_TAG=$(git describe --tags --abbrev=0 "${GITHUB_REF_NAME}^" 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
RANGE="${GITHUB_REF_NAME}"
else
RANGE="${PREV_TAG}..${GITHUB_REF_NAME}"
fi
{
echo "changelog<<EOF"
echo "# StellarHunts ${{ steps.tag.outputs.version }}"
echo ""
# Helper: print a section if there are matching commits
print_section() {
local label="$1" prefix="$2"
commits=$(git log "${RANGE}" --no-merges --pretty=format:"- %s (%h)" --grep="^${prefix}")
if [ -n "$commits" ]; then
echo ""
echo "### ${label}"
echo ""
echo "$commits"
fi
}
print_section "🚀 Features" "feat"
print_section "🐛 Bug Fixes" "fix"
print_section "📖 Documentation" "docs"
print_section "♻️ Refactoring" "refactor"
print_section "🧪 Tests" "test"
print_section "🔧 CI/CD" "ci"
print_section "📦 Chores" "chore"
print_section "💄 Style" "style"
# If no conventional commits matched, fall back to chronological list
ALL=$(git log "${RANGE}" --no-merges --pretty=format:"- %s (%h)")
if [ -z "$ALL" ]; then
echo ""
echo "No changes since previous release."
fi
echo ""
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG:+$PREV_TAG...}${GITHUB_REF_NAME}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
shell: bash
# ── Create GitHub Release ─────────────────────────────
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: v${{ steps.tag.outputs.version }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
generate_release_notes: false
files: |
onchain/target/wasm32-unknown-unknown/release/stellar_hunts.wasm
onchain/target/wasm32-unknown-unknown/release/stellar_hunts_nft.wasm
onchain/target/wasm32-unknown-unknown/release/stellar_hunts_receiver.wasm
fail_on_unmatched_files: true