forked from Snowfork/snowbridge
-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (164 loc) · 5.85 KB
/
npm-publish.yml
File metadata and controls
189 lines (164 loc) · 5.85 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: npm-publish
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version to publish"
required: false
type: "string"
permissions:
id-token: write
contents: write
jobs:
publish:
runs-on: snowbridge-runner
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
cache-dependency-path: web
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
working-directory: contracts
run: |
forge install https://github.com/foundry-rs/forge-std --no-git
forge install https://github.com/dapphub/ds-test --no-git
forge install https://github.com/PaulRBerg/prb-math --no-git
forge install https://github.com/OpenZeppelin/openzeppelin-contracts --no-git
forge install https://github.com/snowfork/canonical-weth --no-git
- name: Build Contracts
working-directory: contracts
run: |
forge build
- name: Test
working-directory: contracts
run: forge test
- name: Build
working-directory: web
run: |
pnpm install --frozen-lockfile
pnpm build
- name: Configure Git
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git fetch --tags
- name: Determine new version
id: new_version
if: github.event_name != 'release'
run: |
# Get the most recent tag in the format @snowbridge/api@<version>
current_tag=$(git tag --list "@snowbridge/api@*" --sort=-v:refname | grep -E '^@snowbridge/api@[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
echo "Current tag: $current_tag"
current_version=$(echo $current_tag | sed -E 's/@snowbridge\/api@//')
echo "Current version: $current_version"
# Install semver
npm install semver
if [ -n "${{ github.event.release.tag_name }}" ]; then
echo "Using version from release tag: ${{ github.event.release.tag_name }}"
new_version="${{ github.event.release.tag_name }}"
elif [ -n "${{ github.event.inputs.version }}" ]; then
echo "Using version from input: ${{ github.event.inputs.version }}"
new_version="${{ github.event.inputs.version }}"
elif [ -z "$current_version" ]; then
new_version="0.2.1"
else
echo "No release tag or input version provided, incrementing patch version."
new_version=$(npx semver $current_version -i patch)
fi
echo "New version: $new_version"
echo "version=$new_version" >> $GITHUB_OUTPUT
echo "from_tag=$current_tag" >> $GITHUB_OUTPUT
- name: Set version in package.json
working-directory: web
if: github.event_name != 'release'
run: |
/bin/bash set-version.sh ${{ steps.new_version.outputs.version }}
- name: Publish Base Types
working-directory: web/packages/base-types
env:
NODE_AUTH_TOKEN: ''
run: |
pnpm publish --no-git-checks --access public --tag latest
- name: Publish Contracts
working-directory: web/packages/contracts
env:
NODE_AUTH_TOKEN: ''
run: |
pnpm publish --no-git-checks --access public --tag latest
- name: Publish Contract Types
working-directory: web/packages/contract-types
env:
NODE_AUTH_TOKEN: ''
run: |
pnpm publish --no-git-checks --access public --tag latest
- name: Publish API
working-directory: web/packages/api
env:
NODE_AUTH_TOKEN: ''
run: |
pnpm publish --no-git-checks --access public --tag latest
- name: Publish Registry
working-directory: web/packages/registry
env:
NODE_AUTH_TOKEN: ''
run: |
pnpm publish --no-git-checks --access public --tag latest
- name: Create new tag
id: create_tag
if: github.event_name != 'release'
run: |
tag_name="@snowbridge/api@${{ steps.new_version.outputs.version }}"
echo "Tag name: $tag_name"
echo "tag=$tag_name" >> $GITHUB_OUTPUT
git tag $tag_name
- name: Push new tag
id: push_tag
if: github.event_name != 'release'
run: |
git push origin --tags
- name: Build Changelog
id: build_changelog
if: github.event_name != 'release'
uses: mikepenz/release-changelog-builder-action@v4
with:
configurationJson: |
{
"template": "#{{CHANGELOG}}\n\n<details>\n</details>",
"categories": [
{
"title": "## Web API Changes",
"labels": ["Component: Web API"]
}
]
}
fromTag: ${{ steps.new_version.outputs.from_tag }}
toTag: ${{ steps.create_tag.outputs.tag }}
- name: Create a GitHub Release
id: create_release
if: github.event_name != 'release'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.create_tag.outputs.tag }}
release_name: ${{ steps.create_tag.outputs.tag }}
body: |
${{steps.build_changelog.outputs.changelog}}
draft: false
prerelease: false