Skip to content

Commit 0d32fd1

Browse files
Merge pull request #301 from VenusProtocol/chore/slim-package
chore: publish slim package
2 parents 2c89472 + dee1291 commit 0d32fd1

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Set npm authentication
2+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
3+
4+
cd slim
5+
6+
# Extract to PRE_RELEASE_TAG the tag in the version field of the package json, or the empty string if it doesn't exist
7+
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)
8+
9+
# Publish the package to a custom tag for slim versions
10+
npm publish --provenance --access public --tag $PRE_RELEASE_TAG

.github/workflows/cd.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
jobs:
1010
release:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write
1214
steps:
1315
- name: Checkout
1416
uses: actions/checkout@v3
@@ -35,3 +37,11 @@ jobs:
3537
GIT_COMMITTER_NAME: Venus Tools
3638
GIT_COMMITTER_EMAIL: [email protected]
3739
run: yarn semantic-release
40+
41+
- name: Prepare slim package
42+
run: bash .github/prepare_slim_package.sh
43+
44+
- name: Publish slim package
45+
run: bash .github/publish_slim_package.sh
46+
env:
47+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@venusprotocol/oracle",
33
"description": "Venus Protocol Price Oracle",
4+
"repository": "[email protected]:VenusProtocol/oracle.git",
45
"version": "2.15.0-dev.3",
56
"author": "Venus",
67
"engines": {

0 commit comments

Comments
 (0)