forked from lernza/lernza
-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (114 loc) · 4.29 KB
/
Copy pathrelease.yml
File metadata and controls
133 lines (114 loc) · 4.29 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
name: Release
# Automated release pipeline using Release Please.
#
# How it works:
# 1. You merge PRs to main with conventional commits
# 2. Release Please creates/updates a "Release PR" with version bump
# 3. You review and merge the Release PR
# 4. Tag created, release published, WASM built, notes rebuilt with
# ALL commit types + contributors + full changelog link
on:
push:
branches: [main]
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
release-type: simple
token: ${{ secrets.GITHUB_TOKEN }}
build-artifacts:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
runs-on: ubuntu-latest
env:
TAG: ${{ needs.release-please.outputs.tag_name }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install stellar-cli
run: |
curl -fsSL https://github.com/stellar/stellar-cli/releases/download/v25.2.0/stellar-cli-25.2.0-x86_64-unknown-linux-gnu.tar.gz \
| tar xz -C /usr/local/bin
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown,wasm32v1-none
- name: Build optimized WASM contracts
run: stellar contract build
- name: Upload WASM binaries to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for wasm in target/wasm32v1-none/release/*.wasm; do
[ -f "$wasm" ] || continue
gh release upload "$TAG" "$wasm" --clobber
echo "Uploaded: $(basename $wasm)"
done
- name: Rebuild release notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
HEAD_SHA=$(git rev-parse HEAD)
PREV_TAG=$(git tag --sort=-v:refname | grep -v "^${TAG}$" | head -1 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
RANGE="${PREV_TAG}..${TAG}"
else
RANGE="${TAG}"
fi
# Build changelog using external script (avoids YAML escaping)
git log "$RANGE" --pretty=format:"%s (%h)" --no-merges 2>/dev/null | \
grep -v "^chore(main): release" > /tmp/commits.txt || true
CHANGELOG=$(bash .github/scripts/categorize-commits.sh)
# Resolve contributors
cat > /tmp/contributors.jq << 'JQ_FILTER'
[
.[] |
select(.author != null) |
select(.author.login != "dependabot[bot]") |
select(.author.login != "web-flow") |
select(.author.login != "github-actions[bot]") |
{ login: .author.login, name: .commit.author.name }
] |
unique_by(.login) |
.[] |
"- **\(.name)** ([@\(.login)](https://github.com/\(.login)))"
JQ_FILTER
gh api "repos/${GITHUB_REPOSITORY}/commits" \
-X GET -f per_page=100 -f sha="${HEAD_SHA}" \
> /tmp/commits_api.json 2>/dev/null || echo "[]" > /tmp/commits_api.json
CONTRIBUTORS=$(jq -r -f /tmp/contributors.jq /tmp/commits_api.json 2>/dev/null || echo "")
# Build release body
{
echo "## ${TAG}"
echo ""
echo "$CHANGELOG"
if [ -n "$CONTRIBUTORS" ]; then
echo "## Contributors"
echo ""
echo "Thank you to everyone who contributed to this release:"
echo ""
echo "$CONTRIBUTORS"
fi
echo ""
echo "---"
echo ""
if [ -n "$PREV_TAG" ]; then
echo "**[View all code changes since ${PREV_TAG}](https://github.com/${GITHUB_REPOSITORY}/compare/${PREV_TAG}...${TAG})**"
else
echo "**[View all commits](https://github.com/${GITHUB_REPOSITORY}/commits/${TAG})**"
fi
} > /tmp/release_body.md
echo "=== Release notes ==="
cat /tmp/release_body.md
echo "=== End ==="
gh release edit "$TAG" --notes-file /tmp/release_body.md