-
Notifications
You must be signed in to change notification settings - Fork 38
161 lines (139 loc) · 4.91 KB
/
release-plz.yml
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
name: Release-plz
permissions:
pull-requests: write
contents: write
on:
push:
branches:
- main
jobs:
release-plz:
name: Release-plz
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_PLZ_TOKEN }}
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.3"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install wasm-pack
uses: jetli/[email protected]
- name: Run release-plz
uses: MarcoIeni/[email protected]
id: release-plz
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Bump lumina-node npm version
if: steps.release-plz.outputs.prs_created == 'true'
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
run: |
set -eu
pr_branch_name="${{ fromJSON(steps.release-plz.outputs.pr).head_branch }}"
# switch to the branch created by release-plz
git fetch
git checkout "$pr_branch_name"
node_wasm_version="$(cargo pkgid --manifest-path=node-wasm/Cargo.toml | cut -d@ -f 2)"
cd node-wasm/js
# Update lumina-node version
if ! npm version $node_wasm_version >/dev/null; then
echo "Version up to date"
exit
fi
# Update the types definition for lumina-node
npm i
npm run tsc
# Update the readme for lumina-node
wasm-pack build ..
npm run update-readme
# Update the version of lumina-node-wasm dependency
npm pkg set "dependencies[lumina-node-wasm]=$node_wasm_version"
# push a commit to release-plz's pr
# prepare graphql query
branch_sha="$(git rev-parse "$pr_branch_name")"
package_json="$(base64 --wrap 0 package.json)"
readme="$(base64 --wrap 0 README.md)"
types_definitions="$(base64 --wrap 0 index.d.ts)"
query='{"query": "mutation {
createCommitOnBranch(input: {
branch: {
repositoryNameWithOwner: \"eigerco/lumina\",
branchName: \"'"$pr_branch_name"'\"
},
message: {
headline: \"update lumina-node npm package\"
},
expectedHeadOid: \"'"$branch_sha"'\",
fileChanges: {
additions: [
{
path: \"node-wasm/js/package.json\",
contents: \"'"$package_json"'\"
},
{
path: \"node-wasm/js/README.md\",
contents: \"'"$readme"'\"
},
{
path: \"node-wasm/js/index.d.ts\",
contents: \"'"$types_definitions"'\"
}
]
}
})
{ commit { commitUrl } }
}"}'
# create new commit with changes
result=$(curl -sS https://api.github.com/graphql \
-H "Accept: application/vnd.github+json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
--data "$(echo "$query" | tr -d '\n')")
if echo "$result" | jq -e '.errors | length != 0' >/dev/null; then
echo "Commit failed: $(echo "$result" | jq '.errors')" >&2
exit 1
else
echo "Version updated: ${node_wasm_version}"
fi
release-npm:
name: Release-npm
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_PLZ_TOKEN }}
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.3"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install wasm-pack
uses: jetli/[email protected]
- name: Release to npm
env:
NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
run: |
published_version=$(npm show lumina-node-wasm version)
local_version="$(cargo pkgid --manifest-path=node-wasm/Cargo.toml | cut -d@ -f 2)"
if [ "$published_version" == "$local_version" ] ; then
echo Latest version already in npm, exiting
exit
fi
# publish lumina-node-wasm
wasm-pack build node-wasm
wasm-pack publish --access public node-wasm
# publish lumina-node
cd node-wasm/js
npm publish --access public