Skip to content

Commit 5966768

Browse files
Merge pull request #37 from VenusProtocol/feat/slim-package
cd: publish slim package
2 parents 80b7e23 + 83990d3 commit 5966768

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

.github/prepare_slim_package.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Create a slim folder with the minium content we want, and remove unneeded files
2+
mkdir slim && cp -r artifacts* package.json README.md deployments slim && cd slim
3+
find deployments -mindepth 1 -depth -not -name "*_addresses.json*" -exec rm -r "{}" +
4+
find artifacts -mindepth 1 -depth -not -regex "artifacts/contracts.*" -exec rm -r "{}" +
5+
find artifacts-zk -mindepth 1 -depth -not -regex "artifacts-zk/contracts.*" -exec rm -r "{}" +
6+
find artifacts -mindepth 1 -depth -regex "artifacts/.*dbg\.json" -exec rm -r "{}" +
7+
8+
# Add "-slim" to the version in the npm package, keeping the tag "-dev" if it exists
9+
jq '.version |= sub("^(?<core>[0-9]+\\.[0-9]+\\.[0-9]+)"; "\(.core)-slim")' package.json > package.tmp.json && mv package.tmp.json package.json
10+
11+
# Remove the "prepare" and "postinstall" scripts, they won't work for this slim version
12+
jq 'del(.scripts.prepare)' package.json > package.tmp.json && mv package.tmp.json package.json
13+
jq 'del(.scripts.postinstall)' package.json > package.tmp.json && mv package.tmp.json package.json
14+
15+
# Empty devDependencies and dependencies
16+
jq '.dependencies = {}' package.json > package.tmp.json && mv package.tmp.json package.json
17+
jq '.devDependencies = {}' package.json > package.tmp.json && mv package.tmp.json package.json

.github/publish_slim_package.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cd slim
2+
3+
# Extract to PRE_RELEASE_TAG the tag in the version field of the package json, or the empty string if it doesn't exist
4+
PRE_RELEASE_TAG=$(jq -r '.version | if test("-") then capture("^[0-9]+\\.[0-9]+\\.[0-9]+-(?<tag>[a-zA-Z-]+)") | .tag else "" end' package.json)
5+
6+
# Publish the package to a custom tag for slim versions
7+
npm publish --access public --tag $PRE_RELEASE_TAG

.github/workflows/cd.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,9 @@ jobs:
4040
GIT_COMMITTER_NAME: Venus Tools
4141
GIT_COMMITTER_EMAIL: tools@venus.io
4242
run: yarn semantic-release
43+
44+
- name: Prepare slim package
45+
run: bash .github/prepare_slim_package.sh
46+
47+
- name: Publish slim package
48+
run: bash .github/publish_slim_package.sh

0 commit comments

Comments
 (0)