@@ -19,103 +19,103 @@ inputs:
19
19
description : npm package access.
20
20
required : false
21
21
default : " public"
22
- api_token :
22
+ api_token :
23
23
description : npm API token.
24
24
required : false
25
25
26
26
runs :
27
27
using : " composite"
28
28
steps :
29
- - name : Check npm latest version
30
- id : check_version
31
- shell : bash
32
- run : |
33
- echo "Check crate latest published version for '${{ inputs.package}}' package"
29
+ - name : Check npm latest version
30
+ id : check_version
31
+ shell : bash
32
+ run : |
33
+ echo "Check crate latest published version for '${{ inputs.package}}' package"
34
34
35
- if [ "${{ inputs.tag }}" != "latest" -a "${{ inputs.tag }}" != "next" ]; then
36
- echo "Tag '${{ inputs.tag }}' is not valid. It should be one of 'latest' or 'next'"
37
- exit 1
38
- fi
35
+ if [ "${{ inputs.tag }}" != "latest" -a "${{ inputs.tag }}" != "next" ]; then
36
+ echo "Tag '${{ inputs.tag }}' is not valid. It should be one of 'latest' or 'next'"
37
+ exit 1
38
+ fi
39
39
40
- LOCAL_VERSION=$(cargo metadata --quiet --no-deps | jq -r '.packages[] | select(.name=="${{ inputs.package}}") | .version')
41
- NEXT_REMOTE_VERSION=$(npm view @${{ inputs.scope }}/${{ inputs.package }} dist-tags.next 2> /dev/null || true)
42
- LATEST_REMOTE_VERSION=$(npm view @${{ inputs.scope }}/${{ inputs.package }} dist-tags.latest 2> /dev/null || true)
40
+ LOCAL_VERSION=$(cargo metadata --quiet --no-deps | jq -r '.packages[] | select(.name=="${{ inputs.package}}") | .version')
41
+ NEXT_REMOTE_VERSION=$(npm view @${{ inputs.scope }}/${{ inputs.package }} dist-tags.next 2> /dev/null || true)
42
+ LATEST_REMOTE_VERSION=$(npm view @${{ inputs.scope }}/${{ inputs.package }} dist-tags.latest 2> /dev/null || true)
43
43
44
- echo "Latest crate.io version: '$LATEST_REMOTE_VERSION'"
45
- echo "Next crate.io version: '$NEXT_REMOTE_VERSION'"
46
- echo "Local version: '$LOCAL_VERSION'"
44
+ echo "Latest crate.io version: '$LATEST_REMOTE_VERSION'"
45
+ echo "Next crate.io version: '$NEXT_REMOTE_VERSION'"
46
+ echo "Local version: '$LOCAL_VERSION'"
47
47
48
- if [ "${{ inputs.tag }}" == "latest" ]; then
49
- if [ "$LOCAL_VERSION" == "$LATEST_REMOTE_VERSION" ]; then
50
- echo "Local version and remote version are the same: no need to publish to npm registry"
51
- DEPLOY_MODE='none'
52
- elif [ "$LOCAL_VERSION" == "$NEXT_REMOTE_VERSION" ]; then
53
- DEPLOY_MODE='promote'
54
- else
55
- DEPLOY_MODE='publish'
48
+ if [ "${{ inputs.tag }}" == "latest" ]; then
49
+ if [ "$LOCAL_VERSION" == "$LATEST_REMOTE_VERSION" ]; then
50
+ echo "Local version and remote version are the same: no need to publish to npm registry"
51
+ DEPLOY_MODE='none'
52
+ elif [ "$LOCAL_VERSION" == "$NEXT_REMOTE_VERSION" ]; then
53
+ DEPLOY_MODE='promote'
54
+ else
55
+ DEPLOY_MODE='publish'
56
+ fi
57
+ else # input.tag == 'next'
58
+ if [ "$LOCAL_VERSION" == "$LATEST_REMOTE_VERSION" ]; then
59
+ # A latest already published: no need to tag with next
60
+ echo "Local version and remote version are the same: no need to publish to npm registry"
61
+ DEPLOY_MODE='none'
62
+ elif [ "$LOCAL_VERSION" == "$NEXT_REMOTE_VERSION" ]; then
63
+ echo "Local version and remote version are the same: no need to publish to npm registry"
64
+ DEPLOY_MODE='none'
65
+ else
66
+ DEPLOY_MODE='publish'
67
+ fi
56
68
fi
57
- else # input.tag == 'next'
58
- if [ "$LOCAL_VERSION" == "$LATEST_REMOTE_VERSION" ]; then
59
- # A latest already published: no need to tag with next
60
- echo "Local version and remote version are the same: no need to publish to npm registry"
61
- DEPLOY_MODE='none'
62
- elif [ "$LOCAL_VERSION" == "$NEXT_REMOTE_VERSION" ]; then
63
- echo "Local version and remote version are the same: no need to publish to npm registry"
64
- DEPLOY_MODE='none'
65
- else
66
- DEPLOY_MODE='publish'
67
- fi
68
- fi
69
69
70
- echo "Deploy mode: '$DEPLOY_MODE'"
71
- echo "Dry run: '${{ inputs.dry_run }}'"
72
- echo "deploy_mode=$DEPLOY_MODE" >> $GITHUB_OUTPUT
73
- echo "package_version=$LOCAL_VERSION" >> $GITHUB_OUTPUT
70
+ echo "Deploy mode: '$DEPLOY_MODE'"
71
+ echo "Dry run: '${{ inputs.dry_run }}'"
72
+ echo "deploy_mode=$DEPLOY_MODE" >> $GITHUB_OUTPUT
73
+ echo "package_version=$LOCAL_VERSION" >> $GITHUB_OUTPUT
74
74
75
- - name : Build package
76
- shell : bash
77
- run : |
78
- echo "Build '@${{ inputs.scope }}/${{ inputs.package }}' package"
79
- cp ./LICENSE ./mithril-client-wasm/
80
- cp -f ./mithril-client-wasm/npm/README.md ./mithril-client-wasm/
81
- wasm-pack build ${{ inputs.package }} --release --target web --out-dir ./pkg --scope ${{ inputs.scope }} --out-name index
75
+ - name : Build package
76
+ shell : bash
77
+ run : |
78
+ echo "Build '@${{ inputs.scope }}/${{ inputs.package }}' package"
79
+ cp ./LICENSE ./mithril-client-wasm/
80
+ cp -f ./mithril-client-wasm/npm/README.md ./mithril-client-wasm/
81
+ wasm-pack build ${{ inputs.package }} --release --target web --out-dir ./pkg --scope ${{ inputs.scope }} --out-name index
82
82
83
- - name : List package
84
- shell : bash
85
- run : |
86
- echo "List '@${{ inputs.scope }}/${{ inputs.package }}' package"
87
- ls -al ${{ inputs.package }}/pkg
83
+ - name : List package
84
+ shell : bash
85
+ run : |
86
+ echo "List '@${{ inputs.scope }}/${{ inputs.package }}' package"
87
+ ls -al ${{ inputs.package }}/pkg
88
88
89
- - name : Publish package new version
90
- if : steps.check_version.outputs.deploy_mode == 'publish'
91
- shell : bash
92
- env :
93
- NPM_TOKEN : ${{ inputs.api_token }}
94
- run : |
95
- echo "Publish '@${{ inputs.scope }}/${{ inputs.package }}' package"
96
- npm set "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
97
- if [ -z "${NPM_TOKEN}" -a "${{ inputs.dry_run }}" == "true" ]; then
98
- echo "Warning: An NPM access token is required for authentication and has not been provided."
99
- else
100
- npm whoami
101
- fi
102
- cd ${{ inputs.package }}/pkg
103
- if [ "${{ inputs.dry_run }}" == "false" ]; then
104
- dry_run_option=""
105
- else
106
- dry_run_option="--dry-run"
107
- fi
108
- npm publish --tag ${{ inputs.tag }} --access ${{ inputs.access }} $dry_run_option
89
+ - name : Publish package new version
90
+ if : steps.check_version.outputs.deploy_mode == 'publish'
91
+ shell : bash
92
+ env :
93
+ NPM_TOKEN : ${{ inputs.api_token }}
94
+ run : |
95
+ echo "Publish '@${{ inputs.scope }}/${{ inputs.package }}' package"
96
+ npm set "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
97
+ if [ -z "${NPM_TOKEN}" -a "${{ inputs.dry_run }}" == "true" ]; then
98
+ echo "Warning: An NPM access token is required for authentication and has not been provided."
99
+ else
100
+ npm whoami
101
+ fi
102
+ cd ${{ inputs.package }}/pkg
103
+ if [ "${{ inputs.dry_run }}" == "false" ]; then
104
+ dry_run_option=""
105
+ else
106
+ dry_run_option="--dry-run"
107
+ fi
108
+ npm publish --tag ${{ inputs.tag }} --access ${{ inputs.access }} $dry_run_option
109
109
110
- - name : Promote package distribution tag to 'latest'
111
- if : inputs.dry_run == 'false' && steps.check_version.outputs.deploy_mode == 'promote'
112
- shell : bash
113
- env :
114
- NPM_TOKEN : ${{ inputs.api_token }}
115
- run : |
116
- echo "Publish '@${{ inputs.scope }}/${{ inputs.package }}' package"
117
- npm set "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
118
- npm whoami
119
- cd ${{ inputs.package }}/pkg
120
- npm dist-tag add @${{ inputs.scope }}/${{ inputs.package }}@${{ steps.check_version.outputs.package_version }} latest
121
- npm dist-tag rm @${{ inputs.scope }}/${{ inputs.package }}@${{ steps.check_version.outputs.package_version }} next
110
+ - name : Promote package distribution tag to 'latest'
111
+ if : inputs.dry_run == 'false' && steps.check_version.outputs.deploy_mode == 'promote'
112
+ shell : bash
113
+ env :
114
+ NPM_TOKEN : ${{ inputs.api_token }}
115
+ run : |
116
+ echo "Publish '@${{ inputs.scope }}/${{ inputs.package }}' package"
117
+ npm set "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
118
+ npm whoami
119
+ cd ${{ inputs.package }}/pkg
120
+ npm dist-tag add @${{ inputs.scope }}/${{ inputs.package }}@${{ steps.check_version.outputs.package_version }} latest
121
+ npm dist-tag rm @${{ inputs.scope }}/${{ inputs.package }}@${{ steps.check_version.outputs.package_version }} next
0 commit comments