-
Notifications
You must be signed in to change notification settings - Fork 21
147 lines (124 loc) · 4.99 KB
/
release.yml
File metadata and controls
147 lines (124 loc) · 4.99 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
name: Release
on:
workflow_dispatch:
branches:
- release
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 20
environment: Release
steps:
- name: Checkout code
uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build everything
run: |
pnpm build
- name: Pack packages
run: |
pnpm pack -r --pack-destination release-artifacts
- name: Check if versions exist on npm
id: check_versions
run: |
# Detect npm tag from version (alpha, beta, rc, etc.)
get_npm_tag() {
local version=$1
if [[ "$version" == *"-alpha"* ]]; then
echo "alpha"
elif [[ "$version" == *"-beta"* ]]; then
echo "beta"
elif [[ "$version" == *"-rc"* ]]; then
echo "rc"
else
echo "latest"
fi
}
check_npm_version() {
local pkg_name=$1
local pkg_path=$2
local output_key=$3
LOCAL_VERSION=$(node -p "require('./${pkg_path}/package.json').version")
NPM_TAG=$(get_npm_tag "$LOCAL_VERSION")
echo "${pkg_name} local version: $LOCAL_VERSION (tag: $NPM_TAG)"
echo "${output_key}_tag=${NPM_TAG}" >> $GITHUB_OUTPUT
if npm view "${pkg_name}@${LOCAL_VERSION}" version 2>/dev/null; then
echo "${pkg_name}@${LOCAL_VERSION} already exists on npm"
echo "${output_key}_exists=true" >> $GITHUB_OUTPUT
else
echo "${pkg_name}@${LOCAL_VERSION} does not exist on npm"
echo "${output_key}_exists=false" >> $GITHUB_OUTPUT
fi
}
check_npm_version "@ton/walletkit" "packages/walletkit" "walletkit"
check_npm_version "@ton/appkit" "packages/appkit" "appkit"
check_npm_version "@ton/appkit-react" "packages/appkit-react" "appkit_react"
# Output walletkit version for release naming
WALLETKIT_VERSION=$(node -p "require('./packages/walletkit/package.json').version")
echo "walletkit_version=${WALLETKIT_VERSION}" >> $GITHUB_OUTPUT
- name: Prepare checksums for release
run: |
# Copy and rename Android bridge checksums
if [ -f "packages/walletkit-android-bridge/dist/checksums.json" ]; then
cp packages/walletkit-android-bridge/dist/checksums.json release-artifacts/walletkit-android-bridge.checksums.json
else
echo "Warning: Android bridge checksums not found at packages/walletkit-android-bridge/dist/checksums.json"
fi
# Copy and rename iOS bridge checksums
if [ -f "packages/walletkit-ios-bridge/dist/checksums.json" ]; then
cp packages/walletkit-ios-bridge/dist/checksums.json release-artifacts/walletkit-ios-bridge.checksums.json
else
echo "Warning: iOS bridge checksums not found"
fi
- name: Create Release Draft
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.check_versions.outputs.walletkit_version }}
name: Release v${{ steps.check_versions.outputs.walletkit_version }}
draft: true
files: |
release-artifacts/ton-walletkit-*.tgz
release-artifacts/walletkit-ios-bridge-*.tgz
release-artifacts/walletkit-android-bridge-*.tgz
release-artifacts/walletkit-android-bridge.checksums.json
release-artifacts/walletkit-ios-bridge.checksums.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish @ton/walletkit
if: steps.check_versions.outputs.walletkit_exists == 'false'
run: |
pnpm publish \
--filter="@ton/walletkit" \
--access=public \
--publish-branch=release \
--tag=${{ steps.check_versions.outputs.walletkit_tag }} \
--verbose
- name: Publish @ton/appkit
if: steps.check_versions.outputs.appkit_exists == 'false'
run: |
pnpm publish \
--filter="@ton/appkit" \
--access=public \
--publish-branch=release \
--tag=${{ steps.check_versions.outputs.appkit_tag }} \
--verbose
- name: Publish @ton/appkit-react
if: steps.check_versions.outputs.appkit_react_exists == 'false'
run: |
pnpm publish \
--filter="@ton/appkit-react" \
--access=public \
--publish-branch=release \
--tag=${{ steps.check_versions.outputs.appkit_react_tag }} \
--verbose